fix(aw-sync): default sync dir to documented data dir, migrate legacy ~/ActivityWatchSync - #667
TimeToBuildBob wants to merge 6 commits into
Conversation
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #667 +/- ##
==========================================
+ Coverage 70.81% 80.06% +9.24%
==========================================
Files 51 74 +23
Lines 2916 8260 +5344
==========================================
+ Hits 2065 6613 +4548
- Misses 851 1647 +796 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@greptileai review |
|
@greptileai review |
|
@greptileai review |
|
@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. |
🤖 AI code reviewThis PR changes aw-sync's default sync directory resolution. On desktop, get_sync_dir() now prefers the platform data dir (data_dir()/activitywatch/aw-sync) unless a non-empty legacy ~/ActivityWatchSync exists, in which case the legacy path is kept. Android keeps the historical home-dir location. The PR adds a resolve_sync_dir() helper with unit tests covering legacy/documented precedence, and updates README and CLI help text accordingly. Safe to merge — no P0/P1 findingsConfidence 5/5 ✅ No findings in this PR's changed files. What follows is outside them — not about this change, and not scored. 1 out-of-scope finding (outside this PR's changed files)Each item here is an observation about the PR as a whole — informational only, not scored. The unit test 1 advisory finding (summary-only, not scored)These P2 guard, heuristic, trade-off, or documentation claims are retained for judgment without opening review threads.
This is a How this was verified: static preflight: fix-commit + touched-files scan (rule 7) Files changed (3) — the diff as I read it
Previous review passes
Reviewed Maintainer commands
|
edb1879 to
0b93c10
Compare
|
Rebased onto current master ( |
… ~/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
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. Git-Session-Id: aa450161-741c-5b1f-afe9-6bd926372afe
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. Git-Session-Id: aa450161-741c-5b1f-afe9-6bd926372afe
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. Git-Session-Id: aa450161-741c-5b1f-afe9-6bd926372afe
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. Git-Session-Id: aa450161-741c-5b1f-afe9-6bd926372afe
0b93c10 to
cd2d3cb
Compare
|
Rebased again onto current master ( |
Git-Session-Id: d3c0
|
@greptileai review |
|
CI-green and mergeable (Greptile 5/5) — waiting only on a maintainer click. This PR is ready to merge, but the bot has pull-only access to this repo and can't self-merge — surfacing it here so it isn't lost. The monitoring loop will stop re-flagging it now that this note is posted. |
|
@TimeToBuildBob The reason for keeping this is that the folder is expected to be set under sync by the user (with Syncthing, rsync, Dropbox, or something else). Putting it under the data dir makes it difficult to see/understand/locate. |
|
@TimeToBuildBob But tauri shouldn't ship with sync enabled by default, it's still under development/preview. |
|
Makes sense, thanks for the context — I hadn't weighed the "folder needs to be easy to find/point Syncthing/Dropbox at" requirement, and moving it into the OS data dir works against that on purpose. Root cause per your second comment: Closing this PR (the sync-dir-under-Syncthing default should stay as-is) and opening the aw-tauri fix now. |
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