Copy link to clipboard
Copied
For a LrC plugin I'd like to implement an "Update available" check. The plugin is located on Github, releases are labeled (e.g. "v2.4.960", which is identical to the major.minor.revison version number in Info.lua). The latest version can be accessed through https://github.com/capricorn8/Focus-Points/releases/latest.
When accessing the latest version, "latest" is resolved to "tag/v2.4.960". So, the most convenient way to implement an "Update available" check would be if there was a Lua function that takes "latest" URL as input and returns "tag/v2.4.960" as a result.
The LrHttp functions do not seem to offer a solution for this. Using LrHttp, I could use LrHttp.get() and parse the lengthy response to (hopefully) catch the right piece of information. Not really convincing.
Does anyone know of a way to do this inside Lua?
Right now, to me it seems that the best options is an external call to "curl.exe" which should work on both WIN and MAC platforms.
Copy link to clipboard
Copied
LrHttp.get() automatically follows redirects, and there's no documented way to stop it. (Otherwise, it would be trivial and robust to do a GET and read the Location header in the 302 response.)
So using "curl" is one option.
Another simple option, which I use with my plugins: My web site has a text file for each plugin, e.g.
https://johnrellis.com/lightroom/anyfilter-version.txt
that provides the latest version number. My release scripts automatically create that file from Info.lua.
Copy link to clipboard
Copied
I like the text file approach since it is more straightforward and also allows for more flexible testing of the update check feature (by simply editing the version file). However, it took me quite some time to understand that LrC obviously caches LrHttp.get() calls - it takes a few mins before an update of version.txt becomes visible. I spend a few hours debugging my code since I thought there was some concurrency issue (get() needs to be run an Async task when called during initialization of the plugin or opening the preferences).
Copy link to clipboard
Copied
It could also be the web server (or proxies in between) that is caching the contents. My plugins pass the Pragma: no-cache and Cache-Control: no-cache headers:
LrHttp.get (url,
{{field = "Pragma", value = "no-cache"},
{field = "Cache-Control", value = "no-cache"}},
15)
Copy link to clipboard
Copied
Thanks for the explanation! I tried your code but it in my case it doesn't make a difference. Now that I know that the delay is due to caching and it's not a programming / concurreny issue I don't consider this as a problem. Perhaps for the tester but not for users 😉
Find more inspiration, events, and resources on the new Adobe Community
Explore Now