Sync staging db: reset/re-stage to drop pre-ActivityWatch/aw-server-rust#713 duplicate copies (item 2 of ActivityWatch/aw-server-rust#717)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Start by verifying that the local android-test and android-unlock buckets are not duplicated, then inspect aw-sync/src/android.rs, the existing syncInFlight guard, and the Kotlin push flow. Implement and verify a one-shot staging reset for the phone's own sync directory, followed by a push; done means a pull on erb-m2 adds zero events.
Written by the indexing model from the issue text.
Description
Follow-up to ActivityWatch/aw-server-rust#717, item 2. Item 1 (aw-sync dedupe for -synced-from- buckets on desktops) merged in ActivityWatch/aw-server-rust#718. This is the phone side.
Problem
The phone's push staging db ({sync_dir}/{hostname}/{device_id}/test.db) still holds the copies written by pre-ActivityWatch/aw-server-rust#713 pushes: 293 of one finished stopwatch event, plus the counts from the desktop dry run on erb-m2 (android-test 155,316 of 306,738, android-unlock 4,797, android 2,349). ActivityWatch/aw-android#295 (bump to 70ba50d) stops the growth, but every fresh desktop import of this phone still pulls the existing copies once.
aw-sync dedupe does not reach this: it deliberately refuses non--synced-from- buckets, goes over the aw-server HTTP API (ms precision), and staging is a separate sqlite file that no server serves.
Proposal
The staging db is derived data (the local datastore is the source of truth), so drop it and re-stage rather than dedupe it in place:
- JNI
SyncInterface.resetStaging(hostname)inaw-sync/src/android.rs: deletetest.db,test.db-wal,test.db-shmfor the own device dir only. Resolve the path from the sameget_sync_dir()+ hostname/device id the push uses and refuse anything not under that dir. Never touch a peer's dir. - Kotlin: run it under the existing
syncInFlightguard (never concurrent with a push), once, before the first push after upgrading to a build carrying ActivityWatch/aw-server-rust#713. Gate with a SharedPreferences flag so it doesn't repeat. - The next push rebuilds staging from the local datastore. Push resume is derived from the staging bucket's last event, so an empty staging means one full re-push (small on a phone).
Trigger choice for Erik: automatic one-shot (nobody has to know) versus a "Reset sync staging" button in Sync Settings. I lean automatic one-shot since there is no reason a user would ever decline it.
Verify before building
- Confirm the phone's local
android-test/android-unlockbuckets are not themselves duplicated. If they are, re-staging reproduces the copies and the local buckets need the cleanup instead. Erik's dry run only proved the staging db matches the desktop counts. - After reset, pull on erb-m2 should add zero events (the
end_time + datafingerprint from ActivityWatch/aw-server-rust#713 covers re-imported rows). Worth one check on the real pair before calling it done.
Out of scope: sync v2 makes this class impossible by construction (idempotency by source event id).
- Dominant language
- Kotlin
- Stars
- 270
- Forks
- 57
- Avg merge
- 23h 47m
- Merged PRs (30d)
- 39
Getting set up
We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ActivityWatch/aw-android
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ActivityWatch/aw-android#306 ·
Maintainers usually reply within 1 day
-
AuthSettingsActivity crashes on launch (InflateException: Material attributes under AppCompat theme)Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
ActivityWatch/aw-android#210 · 7 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
ActivityWatch/aw-android#302 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
ActivityWatch/aw-android#300 · 6 comments ·
Maintainers usually reply within 1 day
-
bug
Difficulty 5/5 Over a week Newbie friendliness 35/100
ActivityWatch/aw-android#291 · 7 comments ·
Maintainers usually reply within 1 day
All issues in ActivityWatch/aw-android
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
detekt/detekt#9761 · 1 comment · 2 reactions ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
yschimke/compose-preview-server#1163 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
T31n/YagniLauncher#1051 ·
Maintainers usually reply within 1 day