diff --git a/frontend/apps/filemanager/filemanager.lua b/frontend/apps/filemanager/filemanager.lua index 7ab3bd75d..8929cb8a7 100644 --- a/frontend/apps/filemanager/filemanager.lua +++ b/frontend/apps/filemanager/filemanager.lua @@ -161,10 +161,10 @@ function FileManager:init() }, { text = _("Purge .sdr"), - enabled = DocSettings:hasSidecarDir(util.realpath(file)), + enabled = DocSettings:hasSidecarFile(util.realpath(file)), callback = function() local full_path = util.realpath(file) - util.purgeDir(DocSettings:getSidecarDir(full_path)) + os.remove(DocSettings:getSidecarFile(full_path)) self:refreshPath() -- also remove from history if present local readhistory = require("readhistory") diff --git a/frontend/docsettings.lua b/frontend/docsettings.lua index a58f4d701..5ff2d05e7 100644 --- a/frontend/docsettings.lua +++ b/frontend/docsettings.lua @@ -32,12 +32,10 @@ function DocSettings:getSidecarFile(doc_path) return self:getSidecarDir(doc_path) .. "/metadata." .. doc_path:match(".*%.(.+)") .. ".lua" end -function DocSettings:hasSidecarDir(doc_path) - -- We may be called with items from FileManager, which may not be a document - if lfs.attributes(doc_path, "mode") == "directory" then - return false - end - return lfs.attributes(self:getSidecarDir(doc_path), "mode") == "directory" +function DocSettings:hasSidecarFile(doc_path) + local file = self:getSidecarFile(doc_path) + if file == nil or file == '' then return false end + return lfs.attributes(file, "mode") == "file" end function DocSettings:getHistoryPath(fullpath) diff --git a/frontend/ui/widget/filechooser.lua b/frontend/ui/widget/filechooser.lua index a4b99a6c4..38caa5968 100644 --- a/frontend/ui/widget/filechooser.lua +++ b/frontend/ui/widget/filechooser.lua @@ -144,7 +144,7 @@ function FileChooser:genItemTableFromPath(path) path = full_path } if show_file_in_bold ~= false then - file_item.bold = DocSettings:hasSidecarDir(full_path) + file_item.bold = DocSettings:hasSidecarFile(full_path) if show_file_in_bold ~= "opened" then file_item.bold = not file_item.bold end