Repository navigation
Conversation
…own staging Before ActivityWatch#648 the push path re-exported buckets that had themselves been imported from a peer. Nothing re-creates them any more and every reader skips them, but they still sit in this device's staging dbs, which every peer replicates (hundreds of thousands of events on affected setups). `aw-sync status --clean-legacy [--dry-run]` lists the `-synced-from-` buckets in databases scan_sync_dir classifies as own staging, and deletes them followed by VACUUM so the file actually shrinks. Peers' files are never opened for writing, first-hand bucket ids are refused, and a missing db is not recreated. The status warning now points at the flag for own staging and says only the owner can prune a peer's copy. Staging dbs themselves are not deleted: the daemon still stages at {device_id}/test.db and `aw-sync sync` at {hostname}/{device_id}/test.db, so neither is an orphan yet. That retirement belongs with the v2 layout.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #723 +/- ##
==========================================
+ Coverage 70.81% 79.93% +9.11%
==========================================
Files 51 76 +25
Lines 2916 8566 +5650
==========================================
+ Hits 2065 6847 +4782
- Misses 851 1719 +868 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
… on skipped dbs - An own staging db whose freelist is >= 1/10 of the file stays a target and VACUUM runs whenever the freelist is non-empty, so a prune whose VACUUM failed is finished by the next run instead of reporting nothing to do. - Refuse any staging path that resolves outside the sync dir layout through a symlink: own vs peer is decided from the path, but sqlite opens whatever it points at. - An own staging db that was skipped (uninspectable or symlinked) makes the command exit non-zero, in dry runs too. - Test temp dirs get a counter so parallel tests cannot share one.
Member
Author
Replace the free-space heuristic with a key_value marker written in the same transaction as the deletes and removed once VACUUM succeeds. A db with free pages from ordinary deletes is no longer vacuumed by cleanup.
Member
Author
0xbrayo
marked this pull request as ready for review
September 24, 2026 09:00
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses item 2 of #689.
Draft: this is legacy-path cleanup, and it's parked until the v0.14.0 stable tag per ActivityWatch/activitywatch#1445.
What
aw-sync status --clean-legacy [--dry-run]…-synced-from-…buckets (from before fix(sync): never re-sync buckets synced from another host #648) that are still in this device's own staging dbs, with per-bucket event counts.--dry-run, deletes those buckets and their events, then runsVACUUMso the replicated file actually shrinks.Safety
scan_sync_dirclassifies asOwnStagingare opened for writing. That classification is bydevice_id, so the local server must be reachable; otherwise the command refuses. Peers' files are never touched.prune_synced_bucketsrefuses any id without the-synced-from-marker (via the newis_synced_bucket_id, whichis_synced_bucketnow delegates to).SQLITE_OPEN_CREATE, so a staging db that disappeared is not recreated.Not in this PR: #689 item 1 (the "orphaned" 2-level db)
The 2-level
{device_id}/test.dbisn't actually an orphan today. #685 was closed, so the default daemon still stages there, whileaw-sync syncstages at{hostname}/{device_id}/test.db. Either one can be the live copy depending on how the user runs aw-sync, so deleting either would force a full re-export. Retiring legacy staging belongs with the v2devices/{device_id}/switch.Tests
4 new unit tests on real sqlite staging dbs:
cargo test -p aw-syncpasses, as docargo clippy --workspace -- -D warningsandcargo fmt.