mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
NewsDownloader: Remove NewsDownloader files from history (#3424)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user