rob_cole_2221866's profile

4.5K Messages


76.3K Points

Thu, Jan 23, 2014 3:27 PM


Lightroom SDK 5: Bug in ftpConnection:exists method.

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
return exists, errm

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.



4.5K Messages


76.3K Points

8 y ago

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