Update History and Last open document when move (cut and paste) file (#3607)

pull/3078/head
Robert 6 years ago committed by Frans de Jonge
parent b40bc53fc7
commit a66d657195

@ -545,6 +545,13 @@ function FileManager:pasteHere(file)
self:moveFile(DocSettings:getSidecarDir(orig), dest) -- dest is always a directory
end
if self:moveFile(orig, dest) then
--update history
local dest_file = string.format("%s/%s", dest, util.basename(orig))
require("readhistory"):updateItemByPath(orig, dest_file)
--update last open file
if G_reader_settings:readSetting("lastfile") == orig then
G_reader_settings:saveSetting("lastfile", dest_file)
end
UIManager:show(InfoMessage:new {
text = T(_("Moved to: %1"), dest),
timeout = 2,
@ -565,7 +572,7 @@ function FileManager:pasteHere(file)
info_file = infoCopyFile
end
local basename = util.basename(self.clipboard)
local mode = lfs.attributes(dest .."/" .. basename, "mode")
local mode = lfs.attributes(string.format("%s/%s", dest, basename), "mode")
if mode == "file" or mode == "directory" then
local text
if mode == "file" then
@ -590,7 +597,7 @@ function FileManager:pasteHere(file)
end
function FileManager:createFolder(curr_folder, new_folder)
local folder = curr_folder .. "/" .. new_folder
local folder = string.format("%s/%s", curr_folder, new_folder)
local code = util.execute(self.mkdir_bin, folder)
local text
if code == 0 then

@ -155,6 +155,21 @@ function ReadHistory:removeItemByPath(path)
end
end
function ReadHistory:updateItemByPath(old_path, new_path)
assert(self ~= nil)
for i = #self.hist, 1, -1 do
if self.hist[i].file == old_path then
self.hist[i].file = new_path
self:_flush()
self.hist[i].callback = function()
local ReaderUI = require("apps/reader/readerui")
ReaderUI:showReader(new_path)
end
break
end
end
end
function ReadHistory:removeItem(item)
assert(self ~= nil)
table.remove(self.hist, item.index)

Loading…
Cancel
Save