Skip to content

feat(mutagen): retire a pairing once it holds nothing - #183

Merged
gapul merged 1 commit into
mainfrom
feat/mutagen-prune-empty
Aug 9, 2026
Merged

feat(mutagen): retire a pairing once it holds nothing#183
gapul merged 1 commit into
mainfrom
feat/mutagen-prune-empty

Conversation

@gapul

@gapul gapul commented Aug 9, 2026

Copy link
Copy Markdown
Owner

#182 stopped directories from being recreated on a schedule, but said nothing about the ones already there: a session lives forever once created, so ~/Sync still accumulated an empty directory per host, which is the clutter the whole rule was meant to avoid.

A pairing is now retired on the next ssh when all of these hold:

  • empty on both sides (files 0, symlinks 0, directories ≤ 1 — the root itself counts as 1). Nothing can be lost by construction; anything with content is left alone.
  • untouched for an hour, by the local directory's own mtime. A directory never disappears while it is being used, including the case where you pair a host now and drop a file in shortly after.
  • not the host being paired in this very run, and rooted under ~/Sync — sessions created by hand elsewhere are not this module's business.

Terminating also removes the local directory and the state marker, so the next ssh to that host pairs it again from scratch.

Checked against stub mutagen with three sessions in different states:

macmini  empty both sides, mtime old     -> retiring empty pair macmini   (dir + marker gone)
rpi4     one file                        -> kept
pve      empty both sides, mtime fresh   -> kept
ispc     the host being ssh'd to         -> created

Pairing on ssh only fixed half of it: every host we ever reached still kept a directory
in ~/Sync forever. A pair that is empty on both sides and has been still for an hour is
terminated on the next ssh, which cannot lose anything by construction.
@gapul
gapul enabled auto-merge (squash) August 9, 2026 11:37
@gapul
gapul merged commit a18b470 into main Aug 9, 2026
3 checks passed
@gapul
gapul deleted the feat/mutagen-prune-empty branch August 9, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant