NewsDownloader: Remove NewsDownloader files from history (#3424)

This commit is contained in:
mwoz123
2017-10-27 23:00:49 +02:00
committed by Frans de Jonge
parent 9000ed1bd3
commit 424593ca7c
2 changed files with 27 additions and 1 deletions

View File

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