mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Add trailing slashes to directories at the source
This commit is contained in:
@@ -12,7 +12,7 @@ local util = require("util")
|
||||
local _ = require("gettext")
|
||||
|
||||
-- Date at which the last migration snippet was added
|
||||
local CURRENT_MIGRATION_DATE = 20250601
|
||||
local CURRENT_MIGRATION_DATE = 20250629
|
||||
|
||||
-- Retrieve the date of the previous migration, if any
|
||||
local last_migration_date = G_reader_settings:readSetting("last_migration_date", 0)
|
||||
@@ -888,6 +888,28 @@ if last_migration_date < 20250601 then
|
||||
SettingsMigration:migrateSettings(G_reader_settings)
|
||||
end
|
||||
|
||||
-- 20250629, Fix trailing slashes in wallabag directories #13987
|
||||
-- https://github.com/koreader/koreader/issues/13987
|
||||
if last_migration_date < 20250629 then
|
||||
logger.info("Performing one-time migration for 20250629")
|
||||
|
||||
local wb_lua = DataStorage:getSettingsDir() .. "/wallabag.lua"
|
||||
if lfs.attributes(wb_lua, "mode") == "file" then
|
||||
local wb_settings = LuaSettings:open(wb_lua)
|
||||
wb_settings:readSetting("wallabag")
|
||||
|
||||
if wb_settings.data.wallabag.directory:sub(-1) ~= "/" then
|
||||
wb_settings.data.wallabag.directory = wb_settings.data.wallabag.directory .. "/"
|
||||
end
|
||||
|
||||
if wb_settings.data.wallabag.archive_directory:sub(-1) ~= "/" then
|
||||
wb_settings.data.wallabag.archive_directory = wb_settings.data.wallabag.archive_directory .. "/"
|
||||
end
|
||||
|
||||
wb_settings:saveSetting("wallabag", wb_settings.data.wallabag)
|
||||
wb_settings:flush()
|
||||
end
|
||||
end
|
||||
|
||||
-- We're done, store the current migration date
|
||||
G_reader_settings:saveSetting("last_migration_date", CURRENT_MIGRATION_DATE)
|
||||
|
||||
@@ -566,11 +566,6 @@ function Wallabag:getBearerToken()
|
||||
return false
|
||||
end
|
||||
|
||||
-- Add trailing slash if it is missing
|
||||
if string.sub(self.directory, -1) ~= "/" then
|
||||
self.directory = self.directory .. "/"
|
||||
end
|
||||
|
||||
-- Check if token is valid for at least 5 minutes. If so, no need to renew
|
||||
local now = os.time()
|
||||
if self.token_expiry - now > 300 then
|
||||
@@ -1528,9 +1523,9 @@ end
|
||||
function Wallabag:setDownloadDirectory(touchmenu_instance)
|
||||
require("ui/downloadmgr"):new{
|
||||
onConfirm = function(path)
|
||||
self.directory = path
|
||||
self.directory = path .. "/"
|
||||
self:saveSettings()
|
||||
logger.dbg("Wallabag:setDownloadDirectory: set download directory to", path)
|
||||
logger.dbg("Wallabag:setDownloadDirectory: set download directory to", self.directory)
|
||||
if touchmenu_instance then
|
||||
touchmenu_instance:updateItems()
|
||||
end
|
||||
@@ -1542,9 +1537,9 @@ end
|
||||
function Wallabag:setArchiveDirectory(touchmenu_instance)
|
||||
require("ui/downloadmgr"):new{
|
||||
onConfirm = function(path)
|
||||
self.archive_directory = path
|
||||
self.archive_directory = path .. "/"
|
||||
self:saveSettings()
|
||||
logger.dbg("Wallabag:setArchiveDirectory: set archive directory to", path)
|
||||
logger.dbg("Wallabag:setArchiveDirectory: set archive directory to", self.archive_directory)
|
||||
if touchmenu_instance then
|
||||
touchmenu_instance:updateItems()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user