Skip to content

Persist the per-folder root ETag across restarts (#195) - #196

Merged
gnacho merged 1 commit into
mainfrom
feat/195-persist-etag
Aug 26, 2026
Merged

Persist the per-folder root ETag across restarts (#195)#196
gnacho merged 1 commit into
mainfrom
feat/195-persist-etag

Conversation

@gnacho

@gnacho gnacho commented Aug 26, 2026

Copy link
Copy Markdown
Owner

Closes #195.

Problem

The root ETag gate (#189, v0.2.10) skips the full nextcloudcmd reconciliation when the remote tree is unchanged, but the per-folder ETag lived only in the engine's in-memory etag_slot. After an app restart the slot was empty, so the first RemoteInterval of every folder re-scanned fully even with zero remote changes. On the large folders (Fotos ~65k files) that is a full tree re-scan on every launch.

Change

Persist the ETag per folder and seed the engine from it:

  • New src/core/etag_store.rs: read_etag(folder_id) / write_etag(folder_id, etag) stored at state_dir()/etags/<folder_id>. Kept outside the synced folder - writing inside it would be seen by the FsWatcher and could requeue the folder (the Startup pass and queue discipline: folders re-run immediately instead of one clean pass each #181 vector). Reads/writes are best-effort; a missing/stale value degrades to "changed", which reconciles (the safe direction).
  • SyncEngine::new seeds etag_slot from the persisted value.
  • On a periodic-interval run that records a new ETag, the engine persists it (etag_store::write_etag) and fires an optional on_etag_change callback.
  • RuntimeConfig gained remote_etags: HashMap<String,String> (serde default + migration parse) for any future wiring, though the engine persists via etag_store directly.

Testing

4 new tests (etag_store, hermetic with injectable base dir) + existing engine ETag tests. Gate: 705 tests, clippy clean, fmt applied.

@gnacho
gnacho merged commit a19198f into main Aug 26, 2026
2 checks passed
@gnacho
gnacho deleted the feat/195-persist-etag branch August 26, 2026 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Persist the per-folder root ETag so restarts skip the first no-change reconciliation

1 participant