Skip to main content
Karsten.G
Known Participant
March 11, 2025
質問

LR SDK: find out name of redirected URL ?

  • March 11, 2025
  • 返信数 1.
  • 406 ビュー

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.

返信数 1

johnrellis
Legend
March 11, 2025

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.

 

 

Karsten.G
Karsten.G作成者
Known Participant
March 24, 2025

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).

johnrellis
Legend
March 24, 2025

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)