Repository navigation
Sanitized device hostname forks the sync identity and never migrates bucket hostnames #272
Description
Activity
- added 3 commits that reference this issue
on Sep 16, 2026 #273 merged (
2add24f7) and covers the migration half of this:buckets.hostnamerows carrying the unsanitizedDEVICE_NAME/Build.MODEL/Unknownvalue are rewritten to the sanitized hostname, run againstsqlite.dbbefore the datastore worker opens it.- A leftover sync folder for this
device_idunder the old name is renamed when the sanitized name is absent, or the stale fork is dropped when both exist. Both cases trigger a one-time full re-push from local sqlite (~273 MB on the device that prompted this). - After a fully successful SAF mirror, the matching
<hostname>/<device_id>tree is deleted so Syncthing stops replicating the fork. Scoped to this device'sdevice_id; a tree holding another install's id is never removed.
Leaving this issue open, because the root of the title still holds: identity is still hostname-keyed, so a future sanitizer/casing change forks again and needs another one-shot like #273. The robust fix is keying sync on
device_idwith hostname demoted to a display label — direction decided at ActivityWatch/activitywatch#302, with the aw-sync-side data-loss view at ActivityWatch/aw-server-rust#683.When #302 lands, the migration machinery added in #273 should be deletable rather than maintained.
- added a commit that references this issue
on Sep 18, 2026 - added a commit that references this issue
on Sep 18, 2026 @TimeToBuildBob closing this, open a new issue for remaining stuff that needs tracking.
Closing per Erik's request. Remaining work (keying sync on device_id with hostname as display label) is already tracked in:
- ActivityWatch/activitywatch#302 — direction decision for device_id-keyed sync
- ActivityWatch/aw-server-rust#683 — aw-sync data-loss view from duplicate folders
When ActivityWatch/activitywatch#302 lands, the migration machinery from #273 becomes deletable.
Opening #302 to track the aw-android-specific cleanup: removing
SanitizedHostnameMigration.ktand its test once device_id-keyed sync lands upstream (ActivityWatch/activitywatch#302 / ActivityWatch/aw-server-rust#683).
DeviceHostname.ktsanitizes the device name used for sync:so
Settings.Global.DEVICE_NAME="POCO F8 Ultra"becomespoco_f8_ultra, and that is whatSyncInterface.syncPush(port, hostname)passes to the Rust side as the sync folder name.The sanitization itself is right. The problem is that it changed the sync identity of already-syncing devices without migrating anything, and it only renamed the folder — not the hostname recorded on the buckets.
Symptom 1: the folder forks
A device that synced before and after the change ends up with two directories in the shared sync folder, both holding a database for the same
device_id:The old folder is orphaned — nothing writes to it again, nothing cleans it up, and Syncthing keeps replicating it to every peer forever. Worse, desktop peers import both, which can silently truncate ~5 years of history depending on directory walk order; filed as ActivityWatch/aw-server-rust#683.
Symptom 2: the bucket hostname is never migrated
Inside both databases, every bucket row still carries the unsanitized name:
aw-server-rust derives sync provenance from the bucket's
hostnamefield (get_or_create_sync_bucketinaw-sync/src/sync.rs), not from the folder name. So after a successful pull the desktop creates buckets named:— spaces and mixed case in a bucket ID that then has to survive REST paths (
/api/0/buckets/{id}), the/#/activity/{host}/route, and query strings. Which is exactly what the sanitization was introduced to avoid; it just doesn't reach the data that ends up on other machines.(Also note these buckets have no
_{hostname}suffix at all, unlike theaw-watcher-android_$hostnameconvention thatUpgradeWithHistoryTestexpects — so on this device the sanitized name currently appears nowhere except the folder.)Suggested fix
device_id, rename it (and remove the stale one) instead of leaving both. AWatcherAndroidBucketMigration-style one-shot would fit.hostnameon local buckets to the sanitized value as part of that migration, so the sanitized identity is what actually propagates to peers.device_idand carryhostnameonly as a display label — then renaming a device is free and this class of bug disappears. That also addresses Any way to rename the host? I want to merge my devices #133 ("Any way to rename the host? I want to merge my devices"). Tracked in aw-sync: duplicate folders for one device_id silently truncate history on pull aw-server-rust#683.Found on v0.14.2b1 syncing to a macOS desktop via Syncthing. Related: #133, ActivityWatch/aw-server-rust#682, ActivityWatch/aw-server-rust#683.
cc @TimeToBuildBob