Skip to content

Keep a File Found When a Multi-Step Rename Fails Partway #1109

Closed

Description

@ptr727

Behavior

Two steps move a file in more than one filesystem operation, and an exception between the operations leaves the media where the next run can lose it.

  • ProcessFile.MakeExtensionLowercase() moves name.MKV to name.tmp7, then moves name.tmp7 to name.mkv. When the second move throws, the media stays at name.tmp7. The result row names name.MKV, which no longer exists. On the next run name.tmp7 is not an MKV file, so with DeleteUnwantedExtensions on, DeleteNonMkvFile() deletes it.
  • Convert.ReMuxToMkv() moves the remuxed output to the .mkv name before it deletes the input. When the delete throws, the step fails before the caller records the new path or sets modified. The new MKV exists, but the result row reports the old path as not modified.

Reproduction shape

  1. Process name.MKV with DeleteUnwantedExtensions on.
  2. Make the second move in MakeExtensionLowercase() throw, for example with an IO error on a network share.
  3. The media is left at name.tmp7, and the next run deletes it.

Expected

When the second move fails, the step moves the file back to its original name where it can, and reports the path the file is actually at. A remux whose input delete fails reports the output path and the modification.

Found in the review of the per-file exception fix, which keeps processing after such an exception rather than ending the run. The stranding itself does not depend on that fix.

Activity

  1. added
    bug
    pre-existing
    on Oct 30, 2026
  2. ptr727 commented on Oct 31, 2026

    @ptr727
    OwnerAuthor

    Decision from the maintainer (2026-10-30): include Convert.ConvertToMkv(), which has the same move-then-delete pattern, in this fix.

    Claim (backlog burndown round 1, fixed together with #1073): branch feature/1073-1109-rename-collisions, files PlexCleaner/ProcessFile.cs, PlexCleaner/Convert.cs, new PlexCleanerTests/RenameCollisionTests.cs. ARCHITECTURE.md and HISTORY.md are deferred to one final docs pull request by the maintainer's choice, so this group does not touch them.

  3. added a commit that references this issue on Oct 31, 2026
    2bb797b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpre-existing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions