Repository navigation
Fix uniqueName hanging on extensionless file names - #1
Merged
Merged
Conversation
When a dropped photo has no extension (macOS Photos sometimes drops one) and that name is already taken, the old replace left the candidate unchanged and the save loop never finished. Append -N when there is no extension.
Owner
|
Nice catch, thanks! Merged 😁 |
Contributor
Author
|
Thanks for merging — glad it was useful! |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
uniqueNamebuilds a free name by inserting-Nbefore the file extension. When the name has no extension, that replace leaves the candidate unchanged, so a collision (for example saving two JPEGs both namedexportinto the same folder or ZIP) loops forever and the save never finishes.droppedPhotosalready accepts files with an empty MIME type and no extension (macOS Photos / HEIC in Chrome), and the change-date tool keeps a JPEG's original name viaredatedFileName, so the hang is reachable.Fix
If the name has an extension, keep inserting
-Nbefore it. Otherwise append-Nto the whole name.Test
Added a unit case for an extensionless collision (
export/export-2→export-3). Before the fix that case never returned; after it, all 143 unit tests pass (npm test).