Repository navigation
Reserve the name with an exclusive create when hard links are unavailable (#1503) - #1580
Merged
Merged
Conversation
Member
|
Thank you @MarekSpodBiedry! This landed on main in integration batch 35 (#1682). If you haven't already, please join our Discord: https://discord.gg/artcraft. We'd love to have you there. |
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.
Fixes #1503.
safe_file::publish_newgives a finished temp file its final name without replacing anything. It uses a hard link, which fails on a taken name. On volumes without hard links (FAT/exFAT, some shares) it fell back to "check that the name is free, thenfs::rename".renamereplaces an existing file, so a file that another writer created between the check and the rename was overwritten. This affectswrite_new/write_new_unique, which DNG conversion (Convert / Copy as DNG) and merges use.Fix (fallback path only; the hard-link path is unchanged): the fallback now claims the name with
OpenOptions::create_new(atomic, fails withAlreadyExistson a taken name). Then it renames the complete temp file over its own empty placeholder. A failed claim returnsAlreadyExists, sowrite_new_uniquetries the next candidate name as before. If the rename fails, the placeholder is removed. The temp file is cleaned up by the existing code inwrite_new_unique. The module docs describe the new fallback.Test:
fallback_publish_never_replaces_a_file_that_appears_at_the_same_timecalls the fallback directly (on the volumes CI uses, hard links always work). A hook makes a competing file appear right before the step that takes the name. The publish must fail withAlreadyExistsand the other file must keep its content. Once the name is free, the publish succeeds and the temp file is gone. With the old check-then-rename, the same hook placed before the rename lets the other file be replaced.