Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Sync staging db: reset/re-stage to drop pre-ActivityWatch/aw-server-rust#713 duplicate copies (item 2 of ActivityWatch/aw-server-rust#717)

Open
#296 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
kotlin, rust
Domain
databases, mobile

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:

  1. JNI SyncInterface.resetStaging(hostname) in aw-sync/src/android.rs: delete test.db, test.db-wal, test.db-shm for the own device dir only. Resolve the path from the same get_sync_dir() + hostname/device id the push uses and refuse anything not under that dir. Never touch a peer's dir.
  2. Kotlin: run it under the existing syncInFlight guard (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.
  3. 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-unlock buckets 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 + data fingerprint 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ActivityWatch/aw-android

All issues in ActivityWatch/aw-android

Similar issues

More Kotlin issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.