fix(aw-sync): default sync dir to documented data dir, migrate legacy ~/ActivityWatchSync - #667
Conversation
… ~/ActivityWatchSync aw-sync's default sync location was `~/ActivityWatchSync`, which a stock install (aw-tauri first-run autostarts `aw-sync daemon`) created in the user's home directory, clashing with the documented data directories (ActivityWatch/activitywatch#1418). - get_sync_dir() now defaults to data_dir()/activitywatch/aw-sync on desktop, matching aw-server's data_dir()/activitywatch/<component> convention and aw-sync's own config dir. Android keeps its app-scoped historical location; AW_SYNC_DIR/--sync-dir overrides are unchanged. - One-time migration moves an existing ~/ActivityWatchSync into the new location at daemon/CLI startup so synced data is preserved. It no-ops when an explicit location is set or no legacy dir exists, and refuses to auto-merge if both locations already have data (leaves both in place, logs a warning) rather than risk losing data. - Adds unit tests for the migrate, no-op, and refuse-to-merge paths. Closes ActivityWatch/activitywatch#1418 Git-Session-Id: fd9c
Greptile SummaryThe PR changes aw-sync’s desktop default from
Confidence Score: 4/5The PR should not merge until empty legacy directories reliably defer to the documented sync root without risking a split from temporarily unreadable documented state. The resolver still returns an empty legacy directory whenever the documented directory is absent, empty, or unreadable, contradicting the new default and leaving a path that can separate synchronization from existing documented state. Files Needing Attention: aw-sync/src/dirs.rs Important Files Changed
Reviews (5): Last reviewed commit: "fix(aw-sync): fail closed when legacy sy..." | Re-trigger Greptile |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #667 +/- ##
==========================================
+ Coverage 70.81% 79.18% +8.36%
==========================================
Files 51 67 +16
Lines 2916 5789 +2873
==========================================
+ Hits 2065 4584 +2519
- Misses 851 1205 +354 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Auto-migration on startup had two failure modes Greptile flagged: a failed cross-device rename left the daemon writing a fresh empty tree beside live data, and a successful rename disconnected any Syncthing/ Dropbox transport still watching the old path. New installs still default to data_dir()/activitywatch/aw-sync. If ~/ActivityWatchSync already exists, keep using it. AW_SYNC_DIR and --sync-dir are unchanged.
|
@greptileai review |
An empty leftover of the legacy default was enough to switch every sync operation away from remote databases already in the documented directory. Prefer the documented path when it has content and the legacy dir does not.
|
@greptileai review |
A read_dir error on the legacy path must not be treated as emptiness. That silently switched the daemon onto the documented data dir while Syncthing/Dropbox still watched the old path.
|
@greptileai review |
Path::exists() maps IO/permission errors to false, which selected the documented data dir and abandoned a Syncthing/Dropbox root we could not stat. Use try_exists() and keep the legacy path on Err.
|
@greptileai review |
Greptile convergence adjudicationHit the review-attempt cap. Not retriggering Greptile. Verified against: CI: all green (ubuntu, windows, macOS, Android, clippy, format, coverage). Convergence: Fixed (already on this head)
Remaining (non-blocking)
This session: no code change. Resolved the six leftover Greptile threads (five outdated+fixed, one withdrawn). Did not retrigger review. Domain risk (maintainer glance)
The product call in (remaining) is whether an empty leftover with no documented content should keep the old folder. I would keep it. Switching is a silent transport break for anyone who created the folder from old docs before the first sync. Not auto-merging (cross-repo, no merge rights). Waiting on maintainer judgment. |
Problem
aw-sync's default sync location was
~/ActivityWatchSync, created in the user'shome directory. A stock install makes this visible immediately: aw-tauri's
first-run autostart module list ships
{ name = "aw-sync", args = "daemon" }, so afresh install runs the sync daemon and writes
~/ActivityWatchSync/<uuid>/test.dbwithout the user opting into sync at all — clashing with the documented data
directories (ActivityWatch/activitywatch#1418).
What changed
get_sync_dir()now defaults todata_dir()/activitywatch/aw-syncon desktop,matching aw-server's
data_dir()/activitywatch/<component>convention(
aw-server/src/dirs.rs::get_data_dir) and aw-sync's own config dir(
config_dir()/activitywatch/aw-sync). Android keeps its app-scoped historicallocation, and the
AW_SYNC_DIR/--sync-diroverrides are unchanged.~/ActivityWatchSyncalready has content, that path is kept. aw-sync'stransport is an external folder synchronizer (Syncthing/Dropbox/etc) watching
that directory; auto-renaming it would disconnect existing setups, and a failed
cross-device rename would start a fresh empty tree beside live data. New
installs with no legacy dir get the documented location. An empty leftover of
~/ActivityWatchSyncdoes not displace live data already in the documenteddir. Existing users can delete the old folder or set
AW_SYNC_DIRto switch.Testing
Unit tests in
aw-sync/src/dirs.rscover the resolution paths:prefers_existing_legacy_sync_diruses_documented_dir_when_no_legacyprefers_legacy_even_if_documented_also_existsempty_legacy_does_not_displace_populated_documentedCloses ActivityWatch/activitywatch#1418