FileManager: added button to purge sidecar directory (#2391)

Also move its sidecar directory when moving a file.
This commit is contained in:
poire-z
2016-12-03 14:27:32 +01:00
committed by Qingping Hou
parent 0aa19d72a0
commit 949e5ba54d

View File

@@ -157,6 +157,24 @@ function FileManager:init()
UIManager:close(self.file_dialog)
end,
},
{
text = _("Purge .sdr"),
enabled = DocSettings:hasSidecarDir(util.realpath(file)),
callback = function()
local full_path = util.realpath(file)
util.purgeDir(DocSettings:getSidecarDir(full_path))
self:refreshPath()
-- also remove from history if present
local readhistory = require("readhistory")
for _, hist_item in ipairs(readhistory.hist) do
if hist_item.file == full_path then
readhistory:removeItem(hist_item)
break
end
end
UIManager:close(self.file_dialog)
end,
},
},
{
{
@@ -359,6 +377,10 @@ function FileManager:pasteHere(file)
local dest = lfs.attributes(file, "mode") == "directory" and
file or file:match("(.*/)")
if self.cutfile then
-- if we move a file, also move its sidecar directory
if DocSettings:hasSidecarDir(orig) then
self:moveFile(DocSettings:getSidecarDir(orig), dest) -- dest is always a directory
end
self:moveFile(orig, dest)
else
util.execute(self.cp_bin, "-r", orig, dest)