jonniek / mpv-filenavigator

Navigate and open your local files in mpv
The Unlicense
69 stars 9 forks source link

isfolder fails to detect ordinary files, thus appending is impossible #8

Closed 0ion9 closed 5 years ago

0ion9 commented 5 years ago

This might be caused by a Lua change. Not sure. Anyway, the fix is easy -- add == 0 to the end of the line:

function isfolder(dir)
  return os.execute('test -d "'..escapepath(dir, '"')..'"') == 0
end

Without this fix, it was impossible to append files to the playlist -- I could only replace them, because the replace action doesn't check folder status.

The interface also displayed the file I was trying to add as if it were an empty directory :)

jonniek commented 5 years ago

Did this start to happen recently? I'm still on an old mpv version so os.execute('test -d "'..escapepath(dir, '"')..'"') is still returning either true or nil so the == 0 will break that. I also noticed some bugs with path joining that would probably be fixed with using the utils.path_join. I think this script is in a dire need of a big rewrite, I'll try to find some time to do it.

0ion9 commented 5 years ago

Ah, I tend to run trunk version of mpv, so ..

mpv --version

mpv 0.29.0-75-gda1073c247 [redacted copyright notice]
 built on Thu Oct 25 12:51:31 ACDT 2018

Long period of no non-trivial use of mpv, so it's hard to say anything about how recently it really began happening.

Anyway os.execute is part of Lua standard libraries, unless mpv modified it:

aurman -Qi mpv-git |ag Depends

Depends On      : [..] lua51 [..]

The current Lua documentation -- that is, Lua 5.3.5 -- asserts that what you say is true, roughly speaking. However, check the docs for 5.1 :

It returns a status code, which is system-dependent. If command is absent, then it returns nonzero if a shell is available and zero otherwise.

This was in line with my implicit assumption, based on the fact that executing a command in your shell will normally return 0 if the command succeeded. Guess I got lucky.

jonniek commented 5 years ago

Thanks for finding the cause for the issue. Seems like I have Lua52. Fixed this now.