2
0
mirror of https://github.com/koreader/koreader synced 2024-11-10 01:10:34 +00:00

CloudSync: handles potentially incompatible backup and incoming dbs (#12470)

This pr removes the backup db (sync db) of the cloud syncing strategy when a different server location is used. This is to avoid the situation when later incoming db is not based on previously uploaded sync db.
This commit is contained in:
weijiuqiao 2024-09-14 20:08:03 +08:00 committed by GitHub
parent d3beecd3f5
commit 04aa0cbde3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 0 deletions

View File

@ -97,6 +97,10 @@ function SyncService.getReadablePath(server)
return url
end
function SyncService.removeLastSyncDB(path)
os.remove(path .. ".sync")
end
-- Prepares three files for sync_cb to call to do the actual syncing:
-- * local_file (one that is being used)
-- * income_file (one that has just been downloaded from Cloud to be merged, then to be deleted)

View File

@ -1229,6 +1229,11 @@ Time is in hours and minutes.]]),
UIManager:close(this)
end
sync_settings.onConfirm = function(sv)
if server and (server.type ~= sv.type
or server.url ~= sv.url
or server.address ~= sv.address) then
SyncService.removeLastSyncDB(db_location)
end
self.settings.sync_server = sv
touchmenu_instance:updateItems()
end
@ -1252,6 +1257,7 @@ Time is in hours and minutes.]]),
ok_text = _("Delete"),
ok_callback = function()
self.settings.sync_server = nil
SyncService.removeLastSyncDB(db_location)
touchmenu_instance:updateItems()
end,
})

View File

@ -234,6 +234,7 @@ function MenuDialog:setupPluginMenu()
text = _("Delete"),
callback = function()
settings.server = nil
SyncService.removeLastSyncDB(DB.path)
UIManager:close(self.sync_dialogue)
end
},
@ -248,6 +249,11 @@ function MenuDialog:setupPluginMenu()
end
sync_settings.onConfirm = function(chosen_server)
if settings.server.type ~= chosen_server.type
or settings.server.url ~= chosen_server.url
or settings.server.address ~= chosen_server.address then
SyncService.removeLastSyncDB(DB.path)
end
settings.server = chosen_server
end
UIManager:show(sync_settings)