NewsDownloader: Remove NewsDownloader files from history (#3424)

pull/3442/head
mwoz123 7 years ago committed by Frans de Jonge
parent 9000ed1bd3
commit 424593ca7c

@ -5,6 +5,8 @@ local lfs = require("libs/libkoreader-lfs")
local DataStorage = {}
local data_dir
local full_data_dir
function DataStorage:getDataDir()
if data_dir then return data_dir end
@ -33,6 +35,19 @@ function DataStorage:getSettingsDir()
return self:getDataDir() .. "/settings"
end
function DataStorage:getFullDataDir()
if full_data_dir then return full_data_dir end
if string.sub(self:getDataDir(), 1, 1) == "/" then
full_data_dir = self:getDataDir()
elseif self:getDataDir() == "." then
full_data_dir = lfs.currentdir()
end
return full_data_dir
end
local function initDataDir()
local sub_data_dirs = {
"cache", "clipboard",

@ -1,4 +1,5 @@
local DataStorage = require("datastorage")
local ReadHistory = require("readhistory")
local FFIUtil = require("ffi/util")
local InfoMessage = require("ui/widget/infomessage")
local LuaSettings = require("frontend/luasettings")
@ -115,7 +116,7 @@ function NewsDownloader:lazyInitialization()
if news_downloader_settings:has(config_key_custom_dl_dir) then
news_download_dir_path = news_downloader_settings:readSetting(config_key_custom_dl_dir)
else
news_download_dir_path = ("%s/%s/"):format(DataStorage:getDataDir(), news_download_dir_name)
news_download_dir_path = ("%s/%s/"):format(DataStorage:getFullDataDir(), news_download_dir_name)
end
if not lfs.attributes(news_download_dir_path, "mode") then
@ -343,4 +344,14 @@ function NewsDownloader:setCustomDownloadDirectory()
}:chooseDir()
end
function NewsDownloader:onCloseDocument()
local document_full_path = self.ui.document.file
if document_full_path and news_download_dir_path == string.sub(document_full_path, 1, string.len(news_download_dir_path)) then
logger.dbg("NewsDownloader: document_full_path:", document_full_path)
logger.dbg("NewsDownloader: news_download_dir_path:", news_download_dir_path)
logger.dbg("NewsDownloader: removing NewsDownloader file from history.")
ReadHistory:removeItemByPath(document_full_path)
end
end
return NewsDownloader

Loading…
Cancel
Save