This commit is contained in:
team3
2026-09-19 21:20:17 +02:00
parent a6cc15984f
commit a5b92054dc
7 changed files with 97 additions and 4 deletions

View File

@@ -17,7 +17,8 @@ export class Sync {
this._store = store;
this._config = readJson(GLib.build_filenamev([store.dir, 'sync.json']), null);
this._statePath = GLib.build_filenamev([store.dir, 'sync-state.json']);
this._state = readJson(this._statePath, {cursor: 0, pushed: {events: {}, todos: {}, notes: {}}});
this._state = readJson(this._statePath, {cursor: 0, pushed: {events: {}, todos: {}, notes: {}, folders: {}}});
this._state.pushed.folders ??= {};
this._session = new Soup.Session({timeout: 10});
this._busy = false;
this._failing = false;
@@ -81,6 +82,7 @@ export class Sync {
events: changed('events', store.events),
todos: changed('todos', store.todos),
notes,
folders: changed('folders', store.listFolders()),
};
}
@@ -115,6 +117,16 @@ export class Sync {
}
for (const note of payload.notes)
pushed.notes[note.id] = note.updated;
for (const folder of payload.folders)
pushed.folders[folder.id] = folder.updated;
// Ordner: neuester Eintrag gewinnt, Anlegen und Löschen wirken auf das Dateisystem.
for (const folder of response.folders ?? []) {
const mine = store.folders[folder.id];
if (!mine || mine.updated < folder.updated)
store.applyRemoteFolder(folder);
pushed.folders[folder.id] = store.folders[folder.id].updated;
}
// Notizen: ganze Datei, neuere Änderungszeit gewinnt. Eine offene Notiz bleibt unangetastet,
// dann rückt der Stand nicht vor und der Server liefert sie beim nächsten Lauf erneut.