Skip to content

fix(fingerprint): name the leaked temp file when rename fails and cleanup fails - #1202

Open
rootsiemen wants to merge 1 commit into
crazy-goat:masterfrom
rootsiemen:fix-1176-fingerprint-unlink
Open

rootsiemen wants to merge 1 commit into
crazy-goat:masterfrom
rootsiemen:fix-1176-fingerprint-unlink

Conversation

@rootsiemen

Copy link
Copy Markdown
Contributor

Closes #1176

MasterFingerprint::writeTo() handled a failed rename() with @unlink($tempPath) but ignored the unlink result and did not name the temp path in the exception. If both failed, the temp file leaked silently.

  • When the cleanup unlink fails, writeTo() now logs the temp path with error_log() and includes it in the RuntimeException message, so the leaked file is visible and removable. The message is unchanged when the unlink succeeds.
  • The fingerprintfail:// test wrapper gains an unlinkFails option, and a new test testWriteToNamesTempFileWhenRenameAndUnlinkBothFail asserts the exception and the log both name the temp path (verified to fail on the old code: the message carried no temp path).

Verified locally: tests/MasterFingerprintTest.php 23 tests green, composer lint green except pre-existing shellcheck (untouched bin/worktree-done.sh) and missing hadolint in this environment.

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.

[Bug] MasterFingerprint::writeTo() leaks the temp file silently when rename() and unlink() both fail

1 participant