Lightroom SDK 5: Bug in ftpConnection:exists method.

  • 1
  • Problem
  • Updated 5 years ago
I finally found a bug that has been haunting me for years, and is at least partly responsible for difficulty creating reliable ftp'ing plugins.

In this code:

ftpConn.path = parentDir -- e.g. wwwroot/mydir/
local existsAs = ftpConn:exists( filename ) -- e.g. myfile.txt

if parentDir does not exist, but it's parent does, then ftpConn:exists does 2 things wrong:

1. changes the path in ftpConn to that of the existing grand-parent.
2. returns 'file' (as if file existed there, when it doesn't).

Totally repeatable.

Work-arounds, either:
1. assure all parental dirs exist before checking if file exists in a particular directory, or
2. something like this:

local savePath = ftpConn.path
local exists, errm = ftpConn:exists( filename )
if savePath ~= ftpConn.path then
ftpConn.path = savePath
return false
else
return exists, errm
end

It's "funny" - now that I'm writin' it up, I remember this bug from before - I had removed the code that fixed it for some reason, thinking the problem was gone: it's not, or at least not any more.

win7/64

Rob
Photo of Rob Cole

Rob Cole

  • 4831 Posts
  • 382 Reply Likes

Posted 5 years ago

  • 1
Photo of Rob Cole

Rob Cole

  • 4831 Posts
  • 382 Reply Likes
The work-arounds solve the problem at hand, but I still can not make a reliable FTP-synchronizing plugin. Such plugins work, but exercising them makes Lightroom noticably and undeniably more prone to crashing. Such has been the case since Lr2 (never tried Lr1, but have retried in every major version since). Such problem may not be evident on all systems, but is evident on a fair share of them (dunno how many).

To be clear: I am aware that simple ftp export/upload plugins may be fine, but when pushing the ftp functionality a little harder (e.g. doing downloads & deletes & checks for existence along with those uploads), it makes Lr unstable. Note: from the best I can tell, the problem is not due to bug(s) in those other functions per se, but something that happens intermittently, something more inherent... - maybe problem dealing with errors on iffy connections or something - dunno.

If anybody has better luck, I'd love to see sample plugin/source code, however I believe the problem is deeper in Lightroom's FTP handling code, so such plugin source code probably won't help, still... (I'm open).

As it stands, I just use external app for FTP sync instead (no problem that way), but I'd prefer to have FTP synchronization handled by plugin too, and I'm sure Adobe would prefer if Lightroom's FTP code was more reliable...

Rob