Repository navigation
Rename to a Free Name on Collision and Pad Odd GIF Dimensions - #286
Conversation
An extension rename in `process` no longer deletes or backs up a file already holding its target name. The renamed file takes the next free `_N` name, the way `import` does, and a warning names both files. This holds with and without `--skipbackup`. The extension-conflict deferral in ProcessCommand only kept same-stem files out of one parallel pass, so it never reserved the name on disk. The re-encode tier pads to even dimensions with `pad=ceil(iw/2)*2:ceil(ih/2)*2`, since libx264 at yuv420p rejects an odd width or height. GUIDE.md drops both known-issue entries, and ARCHITECTURE.md describes the new behaviour. Co-Authored-By: Claude Opus 5.5 <[email protected]>
With `--skipbackup` the original stayed on disk while the output name was chosen, so a PCM `.mp4` collided with itself and its output became `_1.mp4`. The original now moves to its `.bak` name in both modes, and `--skipbackup` deletes that `.bak` once its metadata is copied. BackupFile's rename now goes through RenameFile, and the padding comment names a column as well as a row. A test covers a case-only rename on a case-insensitive filesystem, skipped where the filesystem is case-sensitive. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The README now says a renamed file takes the next free name when its target is taken, that `--skipbackup` leaves no `.bak` behind, and that the re-encode pads to even dimensions. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Only an extension mixing upper and lower case is lowercased, so `.Jpg` becomes `.jpg` and an all-uppercase `.JPG` is kept. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
|
A recorded local strict-review pass covers head |
A GIF keeps every pixel under the pad. An odd-sized subsampled source, such as a yuv420p AVI, loses its last odd row or column to the pad color, so the docs and the comment no longer claim every pixel is kept. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #286 +/- ##
===========================================
- Coverage 43.37% 41.15% -2.23%
===========================================
Files 28 27 -1
Lines 3896 4148 +252
Branches 306 362 +56
===========================================
+ Hits 1690 1707 +17
- Misses 2154 2371 +217
- Partials 52 70 +18
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
Active issues remain: the filename-generation logic can reuse stale backup paths and race with parallel renames, risking data loss, while the documentation overstates pixel preservation.
3 open issues
What changed in this PR
This PR makes process safer when renaming colliding media files, improves conversion handling under --skipbackup, and pads odd video dimensions before re-encoding.
Changes:
- Renames colliding extension variants to the next available
_Nfilename without displacing existing files. - Stages conversion sources through backup paths consistently and updates related undo behavior.
- Pads odd-width or odd-height video frames in the shared re-encode path.
- Updates documentation and adds coverage for collisions, filesystem case behavior, odd dimensions, and PCM conversion.
| File | Description |
|---|---|
| README.md | Documents free-name collision handling, padded dimensions, and revised backup and --skipbackup behavior. |
| PhotoCleanerTests/ProcessTaskTests.cs | Adds tests for rename collisions, case-sensitive and case-insensitive filesystems, odd GIF dimensions, and PCM conversion. |
| PhotoCleaner/ProcessTask.cs | Implements free-name renames, unified conversion backup handling, and even-dimension padding. |
| GUIDE.md | Updates cloud-export guidance and removes resolved known-issue documentation. |
| ARCHITECTURE.md | Describes the revised rename, conversion, backup, undo, and dimension-padding behavior. |
Review effort: Lite
|
A recorded local strict-review pass covers head |


Summary
ProcessTaskno longer delete (--skipbackup) or back up (default) a file that already holds the target name. The renamed file takes the next free_Nname fromMediaUtilities.GetUniqueFileName, the wayimportdoes, and a warning names both files. A case-only rename on a case-insensitive filesystem is not treated as a collision with itself. The oldMoveFiledisplacement is gone.ProcessCommand's "Deferring N extension conflict(s)" only keeps same-stem files out of one parallel pass, so two tasks never race on one stem. It reserves no name on disk. The deferred file ran in the next pass, while the other file still held the name. No change toProcessCommand.cswas needed.--skipbackup. The original used to stay on disk while the output name was chosen. So a PCM.mp4collided with its own name and its output became_1.mp4. The original now moves to its.bakname in both modes.--skipbackupdeletes that.bakonce its metadata is copied and writes no.bak.out..bak, soundohas nothing to restore for it. Before this change, the default mode moved the unrelated file to.bak.undothen deleted the renamed file in its place. Conversion.bak/.bak.outhandling in the default mode is unchanged.-vf pad=ceil(iw/2)*2:ceil(ih/2)*2, the maintainer's recorded answer on Process Fails to Convert an Animated GIF With an Odd Width or Height #281. The filter sits on the shared re-encode branch (.asf,.wmv,.avi,.3gp,.gif). It does nothing to even dimensions, and an odd-dimension AVI or WMV hit the same libx264 failure.GUIDE.mddrops its "Known Issues" section and its two issue link definitions. Its cloud-export checklist now says a taken name gets the next free name.ARCHITECTURE.mdandREADME.mddescribe the free-name rule, the padding, the--skipbackupbehaviour, and the undo limitation.Tests
ExecuteAsync_MismatchedMimeExtensionNameTaken_RenamesToFreeName, with and without--skipbackup: JPEG bytes inphoto.dngbeside a differentphoto.jpg. Asserts thatphoto_1.jpgholds the renamed bytes andphoto.jpgis untouched. Also asserts there are no.bakfiles and that the warning is logged.ExecuteAsync_MixedCaseExtensionNameTaken_RenamesToFreeName, with and without--skipbackup, case-sensitive filesystems only.ExecuteAsync_MixedCaseExtensionCaseInsensitive_KeepsName, with and without--skipbackup, case-insensitive filesystems only.ExecuteAsync_GifFileOddDimensions_PadsToEvenDimensions: generates 25x70 and 64x33 GIFs with ffmpeg. Asserts that ffprobe reads the MP4 as 26x70 and 64x34.ExecuteAsync_Mp4WithPcmAudio_SkipBackup_KeepsSameName: the output keepspcm.mp4and no other file is left.Not executed on Windows or macOS. The case-insensitive branch of
IsNameTaken, which stopsphoto.Jpgcounting as a collision with itself, is covered only byExecuteAsync_MixedCaseExtensionCaseInsensitive_KeepsName. That test skips on Linux, and CI runs on Ubuntu only, so the branch has not been run on Windows or macOS.Local-pass findings handed to this pull request (pass 3, edit budget spent)
ARCHITECTURE.md"Even Dimensions", classintroduced. Fixed in e72be90. "Every source pixel is kept unscaled" holds for a GIF but not for an odd-sizedyuv420psource in the same re-encode tier. Checked locally: a 25x70 GIF padded with this filter keeps every pixel. A 25x70yuv420pFFV1 AVI loses its last column to the pad color. The bullet and the code comment now say so.PhotoCleaner/ProcessTask.csIsNameTaken/RenameToFreeName, classintroduced. Declined under "Trust Boundaries and Hardening Effort". A free name whose<name>.bakstill holds an earlier run's backup counts as free. A laterundowould then delete the renamed file and restore that backup in its place. Reaching it needs several things at once. A backup from an earlier run must still sit at exactly the chosen name. Only video steps write.bak, so that name is a video's. Thenundomust run after the later run. The input is the maintainer's own tree, and the case is not realistic in this deployment. The same gap exists for the canonical target name and the conversion output name, and that predates this change. It is declined on the same reasoning rather than filed.Pre-existing findings, not filed
README.mdlines 102-104 and the opening of "Undo Flow": classpre-existing, false statement. They say everyprocessmodification or deletion creates a.bak. Extension renames never did, as the section's own "Known limitation" states.Dropped findings
PhotoCleanerTests/ProcessTaskTests.cs, the skip message ofExecuteAsync_MixedCaseExtension_RenamesFile: wording, on text this change did not touch.Closes on promotion: #280, #281
🤖 Generated with Claude Code