Links in chrome.storage.local statt storage.sync (v1.2.0)
Bestehende Daten werden einmalig aus storage.sync übernommen. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
a04aaae859
commit
2bcb625c11
@@ -1,5 +1,5 @@
|
||||
// WebDAV-/Nextcloud-Sync. Gemeinsam genutzt von Popup und Einstellungsseite.
|
||||
// Lokale Daten: chrome.storage.sync {links, deleted, modified}
|
||||
// Lokale Daten: chrome.storage.local {links, deleted, modified}
|
||||
// Zugangsdaten: chrome.storage.local {webdav: {url, user, pass}} (nie über Google synchronisiert)
|
||||
const LabSync = (() => {
|
||||
const FILE = "lablinks.json";
|
||||
@@ -67,12 +67,25 @@ const LabSync = (() => {
|
||||
const setConfig = (cfg) =>
|
||||
cfg ? chrome.storage.local.set({ webdav: cfg }) : chrome.storage.local.remove("webdav");
|
||||
|
||||
const KEYS = ["links", "deleted", "modified"];
|
||||
|
||||
// Bis v1.1.1 lagen die Daten in chrome.storage.sync (Limit ~8 KB) -> einmalig übernehmen.
|
||||
async function migrateFromSyncStorage() {
|
||||
const old = await chrome.storage.sync.get(KEYS);
|
||||
if (old.links) await chrome.storage.local.set(old);
|
||||
await chrome.storage.sync.remove(KEYS);
|
||||
}
|
||||
|
||||
async function readLocal() {
|
||||
const d = await chrome.storage.sync.get(["links", "deleted", "modified"]);
|
||||
let d = await chrome.storage.local.get(KEYS);
|
||||
if (!d.links) {
|
||||
await migrateFromSyncStorage();
|
||||
d = await chrome.storage.local.get(KEYS);
|
||||
}
|
||||
return cleanState(d);
|
||||
}
|
||||
const writeLocal = (s) =>
|
||||
chrome.storage.sync.set({ links: s.links, deleted: s.deleted, modified: s.modified });
|
||||
chrome.storage.local.set({ links: s.links, deleted: s.deleted, modified: s.modified });
|
||||
|
||||
const baseUrl = (cfg) => cfg.url.trim().replace(/\/+$/, "");
|
||||
const fileUrl = (cfg) => baseUrl(cfg) + "/" + FILE;
|
||||
|
||||
Reference in New Issue
Block a user