mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
[fix] util.isEmptyDir() crashes on non-existent dir
lfs.dir will crash rather than return nil if directory doesn't exist
Proper fix for 9f5e446701 which is nothing but a workaround. However, I do think creating more of those data dirs automatically is more user-friendly because otherwise Android users will have to look it up or guess.
This commit is contained in:
@@ -288,7 +288,10 @@ end
|
||||
---- @treturn bool
|
||||
function util.isEmptyDir(path)
|
||||
local lfs = require("libs/libkoreader-lfs")
|
||||
for filename in lfs.dir(path) do
|
||||
-- lfs.dir will crash rather than return nil if directory doesn't exist O_o
|
||||
local ok, iter, dir_obj = pcall(lfs.dir, path)
|
||||
if not ok then return end
|
||||
for filename in iter, dir_obj do
|
||||
if filename ~= '.' and filename ~= '..' then
|
||||
return false
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user