Lightroom SDK: LrFileUtils.moveToTrash is returning bogus values.

  • 2
  • Problem
  • Updated 7 years ago
LrFileUtils.moveToTrash says it didn't move file to trash but it did.

(Its returning false with no accompanying reason, yet file has been successfully moved to recycle-bin).

Lightroom version: 3.5 [775451]
Operating system: Windows 7 Ultimate Edition
Version: 6.1 [7601]
Application architecture: x64
System architecture: x64
Physical processor count: 4
Processor speed: 3.4 GHz
Built-in memory: 7934.1 MB
Real memory available to Lightroom: 7934.1 MB
Real memory used by Lightroom: 1751.8 MB (22.0%)
Virtual memory used by Lightroom: 2104.5 MB
Memory cache size: 1258.0 MB
System DPI setting: 96 DPI
Desktop composition enabled: Yes
Displays: 1) 1920x1200, 2) 1920x1200

Its happening all the time now, but I swear it has worked before (not sure which version), although it seems like I had some doubts about it once before too - memory fuzzy...
Photo of Rob Cole

Rob Cole

  • 4831 Posts
  • 379 Reply Likes

Posted 7 years ago

  • 2
Photo of John R. Ellis

John R. Ellis, Champion

  • 3589 Posts
  • 928 Reply Likes
I just tested Any File's Delete command, which uses LrFileUtils.moveToTrash(). In that context on my machine (LR 3.5, Windows 7 64-bit) it is operating correctly. So perhaps something more specific to your configuration?
Photo of Rob Cole

Rob Cole

  • 4831 Posts
  • 379 Reply Likes
Thanks for checking John.
Photo of jdv

jdv, Champion

  • 728 Posts
  • 56 Reply Likes
How many items already in your trash? Are you trying to move a file to a trash on a removable drive, or some other non-local volume?

Do you have journalling enabled on the volume (assuming Win7 NTFS supports some notion of journalling.)
Photo of Rob Cole

Rob Cole

  • 4831 Posts
  • 379 Reply Likes
17,955
No
No
No

i.e. lots, and reglar local, but non-system drive.

My present workaround is to ignore status and test for file's existence after moving, which does seem to work reliably.
Photo of John R. Ellis

John R. Ellis, Champion

  • 3589 Posts
  • 928 Reply Likes
Does the problem still occur when the Recycle Bin is empty? There was the performance problem mentioned in LR 3.2(?) release notes triggered by a "ful" recycle bin. Hard to see how that would cause this issue, but you know bugs...
Photo of Rob Cole

Rob Cole

  • 4831 Posts
  • 379 Reply Likes
Stupid mistake - I was calling it twice for the same file. Sorry for the false alarm...

Note: contrary to the documentation, if file not found, move-to-trash returns false with no reason.

PS - move-to-trash always fails if file is on network-share - something to watch out for...
Photo of Rob Cole

Rob Cole

  • 4831 Posts
  • 379 Reply Likes
Bottom line:
----------------
The original problem report was due to operator error, *but* the documentation should be augmented to stipulate what happens when file not found, or file on network share....

Bonus Idea:
---------------
Consider a second parameter: "OK to just delete if file on network share...".
i.e. move-to-trash (or bust) vs. move-to-trash (if possible).
Photo of John R. Ellis

John R. Ellis, Champion

  • 3589 Posts
  • 928 Reply Likes
I just tried Any File with a file on a network share, and moveToTrash() returned false, with the error message "cantFindTrash".

I agree that the documentation should be improved, since it never occurred to me either that this would fail with a file on a network share.

I also agree that it would be more convenient to have a second parameter, "alwaysDelete".