• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

LrFileUtils.delete not working on OSX

Explorer ,
May 18, 2017 May 18, 2017

Copy link to clipboard

Copied

Hi,

I'm trying to delete files on OSX. My commands work fine on Win, but I'm not able to delete any files on the mac. First I tried wildcard delete (/abc/*.png) which is not working. Also single file delete or moveToTrash is not working:

for filePath in LrFileUtils.files( path ) do
  

   myLogger:trace("filepath = " .. filePath )  --> shows correct path like /tmp/test

  local success, reason = LrFileUtils.moveToTrash( filepath )

   if not success then
   myLogger:trace("delete command = " .. filepath )

   myLogger:trace(reason) -> no message if .delete, moveToTrash gives "file not exists"

   end
 
end

Also not working:

if LrFileUtils.exists(filepath ) then  --> plugin exit without reason
   myLogger:trace( "file eexists" .. filePath)

end

Any ideas?

TOPICS
SDK

Views

388

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , May 19, 2017 May 19, 2017

I guess I found the error. As I'm performing some command line tasks and folders usually contain white spaces I added quotes around the path string. So for example home = "'"' .. "/my home is my/castle" .. '"'. Quotes works fine under windows and are required for command line tasks both on Win & Mac. But neither LrFileUtils nor direct Lua IO  commands like the additional quotes if used on OSX.

Will do do some more testing tomorrow and the close the issue.

Votes

Translate

Translate
LEGEND ,
May 18, 2017 May 18, 2017

Copy link to clipboard

Copied

Have you verified with the Finder that the volume containing the file paths actually supports moving to trash?  Not all volumes do.

Regarding LrFileUtils.exists(), you said "plugin exits without reason".  When a plugin terminates abruptly, that's usually because an error has been thrown and not caught with pcall() or an LrFunctionContext cleanup handler.  After it exits, go to FIle > Plug-In Manager, select the plugin, and look in Plug-in Author Tools for any diagnostic messages.

More generally, are you using a debugger? Trying to program a plugin without a debugger is very difficult. Either get my debugging toolkit or find the post in this forum that talks about how to connect a particular IDE's debugger to LR.  If you try to debug using just print statements, you'll soon end up spending many hours in frustration, given how limited the LR execution environment is.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 19, 2017 May 19, 2017

Copy link to clipboard

Copied

Thanks for the tip with the debugging toolkit, will have a look into it.

The Plugin-Manager gives me no diagnostic messages. So far I resolved the issue by executing "rm" if the plugin runs on a Mac. I've no glue why LrFileUtils.delete works fine on Win but not on Mac.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 19, 2017 May 19, 2017

Copy link to clipboard

Copied

The Plugin-Manager gives me no diagnostic messages.

It generally won't unless the error occurs in the main task of the plugin.  If an uncaught error occurs in other tasks or in a callback (e.g. in an LrView callback for a button action), the task will exit silently, without a message in the diagnostic log.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 19, 2017 May 19, 2017

Copy link to clipboard

Copied

I guess I found the error. As I'm performing some command line tasks and folders usually contain white spaces I added quotes around the path string. So for example home = "'"' .. "/my home is my/castle" .. '"'. Quotes works fine under windows and are required for command line tasks both on Win & Mac. But neither LrFileUtils nor direct Lua IO  commands like the additional quotes if used on OSX.

Will do do some more testing tomorrow and the close the issue.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 19, 2017 May 19, 2017

Copy link to clipboard

Copied

LATEST

Glad you identified the cause.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines