This commit is contained in:
team3
2026-09-22 14:02:36 +02:00
parent 139663819c
commit 24efa2f4ee
4 changed files with 17 additions and 11 deletions

View File

@@ -84,14 +84,15 @@ export class Sync {
this._dbus.export(Gio.DBus.session, '/de/marha/desktop');
}
// Dateiabgleich sofort, die Antwort kommt erst, wenn er durch ist
// Dateiabgleich sofort und erzwungen: auch Dateien, die noch keine Stunde ruhen.
// Die Antwort kommt erst, wenn er durch ist.
SyncFilesAsync(_params, invocation) {
const reply = text => invocation.return_value(new GLib.Variant('(s)', [text]));
if (!this._filesRoot) {
reply('Dateiabgleich ist aus ("files": false in sync.json)');
return;
}
this._filesCycle()
this._filesCycle(true)
.then(r => reply(r ? `hoch ${r.uploaded}, gelöscht gemeldet ${r.removed}, runter ${r.written}, lokal gelöscht ${r.deleted}` : 'läuft gerade schon'))
.catch(e => reply(`Fehler: ${e.message}`));
}
@@ -278,7 +279,8 @@ export class Sync {
// Eigener Lauf mit eigenem Stand: die Antwort enthält nur Dateien, der Takt der Einträge bleibt unberührt.
// Gibt zurück, was übertragen wurde, oder null, wenn gerade ein Lauf aktiv ist.
async _filesCycle() {
// force: Ruhezeit ignorieren, alles Geänderte geht hoch.
async _filesCycle(force = false) {
if (this._filesBusy || !this._filesRoot)
return null;
this._filesBusy = true;
@@ -287,7 +289,7 @@ export class Sync {
const state = this._state.files;
const local = scanFiles(this._filesRoot);
const now = Math.floor(GLib.get_real_time() / 1e6);
const {upload, remove} = planPush(local, state.pushed, now, FILES_IDLE_SECONDS);
const {upload, remove} = planPush(local, state.pushed, now, force ? 0 : FILES_IDLE_SECONDS);
const items = [];
for (const entry of upload) {
const content = readText(GLib.build_filenamev([this._filesRoot, entry.id]));