Skip to content

Clashing file names are numbered by one rule, and a name that can't be numbered fails instead of reusing a taken one - #1842

Merged
emmertex merged 1 commit into
emmertex:stagingfrom
blwfish:fix/fx-235-free-file-names
Dec 2, 2026
Merged

emmertex merged 1 commit into
emmertex:stagingfrom
blwfish:fix/fx-235-free-file-names

Conversation

@blwfish

@blwfish blwfish commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Part of #1838 (entry 16).

In short: five places pick "the next free numbered name" (-2, -3…) separately: export, Edit In, publish to a folder, copying originals into the library, and the tether download. They disagreed on where to start, how far to go and what to do when there is none. Three of them fell back to a name that was already taken: copying an original into the library's Originals folder, publish, and tether (name-x.ext, which may itself be taken). The copy into Originals then overwrote the existing file. They now share one helper and fail with "no free file name" instead.

Change

  • lcc_catalog::safe_file gains split_extension, numbered_name, first_free_numbered and NUMBERED_NAME_TRIES (1,000,000). Export's placer, Edit In, publish and the library's transfer use them.
  • When no number is free: catalog transfer, publish and tether fail with "no free file name" (transfer: a line in the failed list) instead of using a taken name.
  • Edit In reserves a copy's file and sidecar names together: an OpenEXR copy's .xmp was searched on its own, so it could be named for an older copy.
  • Names that change: a hidden file copied to Originals (.hid becomes .hid-2, was -2.hid) and that Edit In EXR sidecar (a-3.xmp beside a-3.exr, was a.xmp). Names produced by the cases that worked are otherwise unchanged.
  • Tether has no lcc-* dependencies, so it keeps its own loop, with the same limit and the same failure.
  • Not changed: Edit In and publish check that a name is free and then write with replace semantics, so a file that appears in between is replaced.
  • Manual: library/stacks, output/publish-services. What's new and changelog entries.

How it was checked

numbered_names_split_at_the_last_dot_and_start_where_asked, a_copied_original_takes_a_free_name_and_never_a_taken_one, hard_drive_free_name_steps_over_taken_numbers_and_fails_when_none_is_left, a_download_takes_a_free_name_and_never_a_taken_one and a_copy_takes_the_first_free_number_and_a_sidecar_goes_with_its_file fail with the old behaviour put back. Exhaustion at 1,000,000 can't be built on disk, so each caller has a variant with a small bound (at, below and above pinned). The four sites that look at the disk ask the volume, so they inherit its case rule; no case divergence was found.

Questions: see the umbrella (entry 16).

  • cargo xtask ci --quick --base origin/staging on this branch (macOS, staging d4c89211f merged): fmt, brand, quarantine, docs, notes, i18n, windows, clippy and stamp pass. Tests of lcc-catalog, lcc-engine, lcc-publish and lcc-tether: all pass except device_sync::tests::a_shared_collection_brings_photos_files_and_edits_both_ways (environmental on that machine) and ptp::tests::session_capture_download_delete_over_every_transport (a 5-second wait in the tether simulator: it fails about one run in three on plain staging too, and passed three of three alone on this branch). Parity, layers, assets, wasm and deny: pass.

  • The five branches of this batch (this one and its neighbours) were also merged together on current staging and gated as one: fmt, brand, quarantine, docs, notes, i18n, windows, clippy, heif, stamp, parity, layers, assets, wasm and deny pass; the tests fail only where plain staging fails too (device_sync, translated_catalogs_do_not_use_missing_menu_triangles, tests_phone_menus), plus one timing test in io_sched that passes alone.

🤖 Generated with Claude Code

…back to a taken name

Export, Edit In, Hard Drive publishing, a catalog's copied originals and a tethered
download each numbered a clashing name with a copy of the rule, and the copies had
drifted. Trigger -> wrong outcome: a catalog export with 10,000 same-named originals
returned the taken name after the last number (`unwrap_or(first)`), and the copy then
overwrote the file there; a tethered download fell back to `name-x.ext` and renamed
over it when that was taken; publishing fell back to the wanted name; Edit In named an
OpenEXR copy's XMP sidecar by its own search (`a.xmp` beside `a-3.exr`), so the sidecar
was named for an older copy; the limits were 10,000, 10,000, unbounded, 10,000 and
1,000,000, and one site split a hidden file's name differently.

Change: `lcc_catalog::safe_file` gets `split_extension`, `numbered_name`,
`first_free_numbered` and `NUMBERED_NAME_TRIES` (1,000,000). The export Placer (and its
`split_file_name`), Edit In (`unique_path`, with a group variant that reserves the
sidecar's name with the file's), Hard Drive publishing and catalog transfer consume
them. Transfer, publishing and the tethered download now fail with "no free file name"
when every number is taken instead of using a taken name. The tether crate sits below
the catalog and cannot depend on it, so it keeps its own loop (starting at -1 as ever)
with the same limit and the same failure. Names given in the cases that worked are
unchanged; the one name that differs is a hidden file copied to a catalog's Originals
(`.hid` is now `.hid-2`, was `-2.hid`).

Tests (each fails with the old behaviour put back: fallback to the taken name in
transfer, publish and tether; sidecar reservation in Edit In; an inclusive bound in the
helper): `numbered_names_split_at_the_last_dot_and_start_where_asked`,
`a_copied_original_takes_a_free_name_and_never_a_taken_one`,
`hard_drive_free_name_steps_over_taken_numbers_and_fails_when_none_is_left`,
`a_download_takes_a_free_name_and_never_a_taken_one`,
`a_copy_takes_the_first_free_number_and_a_sidecar_goes_with_its_file`.

Manual: library/stacks, output/publish-services

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@emmertex
emmertex merged commit a49b2b5 into emmertex:staging Dec 2, 2026
3 checks passed
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.

2 participants