Skip to content

Delete the staged login copy when a project is deleted - #254

Merged
xroche merged 2 commits into
masterfrom
fix-orphan-login-tmp
Oct 21, 2026
Merged

xroche merged 2 commits into
masterfrom
fix-orphan-login-tmp

Conversation

@xroche

@xroche xroche commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

Saving a browser login stages the cookies under a .new name, then renames that onto the file the engine reads. That way a write failing halfway cannot truncate a good login. But if the app dies between the two, the staged file stays, and the pattern that picks what a project deletion removes never matched it. So deleting the project left a live session behind.

The suffix was a literal in BrowserLoginActivity and the pattern was in StoragePaths, so the two could disagree. Both now read one constant, and a test ties the matcher to the name the write stages.

Found while reviewing xroche/httrack#1992.

xroche and others added 2 commits October 21, 2026 08:00
BrowserLoginActivity.writeOwnerOnly stages the cookies under
<project>.txt.new and renames it onto <project>.txt, so a write that
fails halfway cannot truncate a good login. If the app dies between
the write and the rename, the staged file stays on disk.

CleanupActivity.forgetLogin deletes every file StoragePaths.isLoginSibling
accepts. Its pattern took the login name, an optional ".bak" and an
optional ".<pid>.tmp", which are the engine's own leftovers, and never
the staged name. So deleting the project left a full session in private
storage.

The suffix lived as a literal in BrowserLoginActivity and the pattern
lived in StoragePaths, which is how the two could disagree. Move the
staged name into StoragePaths.stagedLoginFile and build the pattern
from the same constant.

Reported by the engine-side session while reviewing httrack #1992.

Signed-off-by: Xavier Roche <xroche@gmail.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Xavier Roche <xroche@gmail.com>
Review found two mutations the first round's tests let through.

Staging into another directory under the same name kept the matcher
agreeing with itself, so the assertion passed while savedLoginFiles,
which lists only the logins directory, could no longer see the file.
The leak was back with nothing red. Assert the whole path.

Calling stagedLoginFile and then opening the stream on an open-coded
name left both grepped substrings in place, so the wiring test stayed
green while nothing was ever saved. Assert the stream is opened on the
staged file.

The test named a consequence it never read, so rename it after what it
checks. isLoginSibling's first argument takes a login file name, not a
project name, so say so in the name and state the summary in the
parameters' own order.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Xavier Roche <xroche@gmail.com>
@xroche xroche changed the title Delete the leftover login file when a project is deleted Delete the staged login copy when a project is deleted Oct 21, 2026
@xroche
xroche enabled auto-merge (squash) October 21, 2026 06:11
@xroche
xroche merged commit 5c3a420 into master Oct 21, 2026
7 checks passed
@xroche
xroche deleted the fix-orphan-login-tmp branch October 21, 2026 06:16
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