Skip to content

feat: clean up leftover staging folders from interrupted operations - #124

Merged
nextestudios merged 1 commit into
mainfrom
feature/82-staging-cleanup
Sep 27, 2026
Merged

nextestudios merged 1 commit into
mainfrom
feature/82-staging-cleanup

Conversation

@nextestudios

Copy link
Copy Markdown
Owner

Summary

  • New ITemporaryJournal (Core) and TemporaryJournal (Infrastructure.Windows): one small JSON entry per active temporary in <app data>/operations, written before the temporary is created and removed only after it no longer exists. Each entry records path, kind, manifest token (staging) and the owner process (PID + start time).
  • Registered temporaries: extraction staging .controlfs-staging-* (the manifest now carries a random token), the dedicated-folder placeholder .controlfs-new-*, partial copies .controlfs-copy-*.part (FileOperationService) and partial archives .controlfs-new-*.part (ArchiveCreator).
  • On startup (AppController.Start, background) entries whose owner process is gone are resolved: a staging folder is deleted only if it is a real folder (not a link) with the expected prefix and a manifest containing the registered token; partial files/empty placeholders only by their exact random name. Deletion never follows links. Entries of a still-running ControlFS instance are kept; anything not provably ours is left untouched and its entry dropped. The bottom bar reports the count and where.
  • Wired in MainWindow (same journal for archives, file operations and the controller). Guide (EN/pt-BR), security model, architecture, TESTING and both changelogs updated.

Tests

  • CI: LeftoverCleanupTests.Next_launch_removes_the_owned_leftovers_of_a_crashed_operation_and_nothing_else simulates a crashed process (journal with a dead PID) and checks that the next launch removes the owned staging folder and partial copy, keeps a look-alike folder that is not registered, a registered folder whose manifest token does not match, and the active staging of a live instance, and shows the status notice.
  • CI: Finished_operations_leave_no_journal_entries_behind (extract, compress, copy).
  • Manual (docs/TESTING.md): kill the app from Task Manager during a large extraction/copy and relaunch; two windows open at once.

Closes #82

🤖 Generated with Claude Code

Every temporary ControlFS creates in the user's folders (extraction
staging, dedicated-folder placeholder, partial copy and partial archive)
is registered in a journal in the app data folder before it is created,
and the entry is removed only once the temporary is gone. On startup,
entries whose owner process is no longer running are resolved: staging
folders are deleted only when their manifest carries the registered
token, partial files and empty placeholders only by their exact random
name; links are never followed. The bottom bar reports what was removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@nextestudios
nextestudios force-pushed the feature/82-staging-cleanup branch from 16f07e6 to 56487be Compare September 27, 2026 03:17
@nextestudios
nextestudios merged commit 6009867 into main Sep 27, 2026
1 check passed
@nextestudios
nextestudios deleted the feature/82-staging-cleanup branch September 27, 2026 03:19
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.

feat: clean up leftover staging folders from interrupted operations

1 participant