Removing metadata file instead of purging .sdr folder

pull/2534/head
Zijie He 7 years ago
parent bec5f46245
commit b502047635

@ -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")

@ -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)

@ -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

Loading…
Cancel
Save