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"), text = _("Purge .sdr"),
enabled = DocSettings:hasSidecarDir(util.realpath(file)), enabled = DocSettings:hasSidecarFile(util.realpath(file)),
callback = function() callback = function()
local full_path = util.realpath(file) local full_path = util.realpath(file)
util.purgeDir(DocSettings:getSidecarDir(full_path)) os.remove(DocSettings:getSidecarFile(full_path))
self:refreshPath() self:refreshPath()
-- also remove from history if present -- also remove from history if present
local readhistory = require("readhistory") local readhistory = require("readhistory")

@ -32,12 +32,10 @@ function DocSettings:getSidecarFile(doc_path)
return self:getSidecarDir(doc_path) .. "/metadata." .. doc_path:match(".*%.(.+)") .. ".lua" return self:getSidecarDir(doc_path) .. "/metadata." .. doc_path:match(".*%.(.+)") .. ".lua"
end end
function DocSettings:hasSidecarDir(doc_path) function DocSettings:hasSidecarFile(doc_path)
-- We may be called with items from FileManager, which may not be a document local file = self:getSidecarFile(doc_path)
if lfs.attributes(doc_path, "mode") == "directory" then if file == nil or file == '' then return false end
return false return lfs.attributes(file, "mode") == "file"
end
return lfs.attributes(self:getSidecarDir(doc_path), "mode") == "directory"
end end
function DocSettings:getHistoryPath(fullpath) function DocSettings:getHistoryPath(fullpath)

@ -144,7 +144,7 @@ function FileChooser:genItemTableFromPath(path)
path = full_path path = full_path
} }
if show_file_in_bold ~= false then 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 if show_file_in_bold ~= "opened" then
file_item.bold = not file_item.bold file_item.bold = not file_item.bold
end end

Loading…
Cancel
Save