Merge pull request #2534 from Hzj-jie/master

Removing metadata file instead of purging .sdr folder
pull/2536/head v2017.02.09-nightly
Frans de Jonge 7 years ago committed by GitHub
commit 6b5b426639

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

@ -29,15 +29,17 @@ end
function DocSettings:getSidecarFile(doc_path)
if doc_path == nil or doc_path == '' then return '' end
return self:getSidecarDir(doc_path) .. "/metadata." .. doc_path:match(".*%.(.+)") .. ".lua"
-- If the file does not have a suffix or we are working on a directory, we
-- should ignore the suffix part in metadata file path.
local suffix = doc_path:match(".*%.(.+)")
if suffix == nil then
suffix = ''
end
return self:getSidecarDir(doc_path) .. "/metadata." .. suffix .. ".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)
return lfs.attributes(self:getSidecarFile(doc_path), "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