Skip to content

fix(organize): 5.3.1 — Preview and the move agree on numbered names - #137

Merged
iLevyTate merged 2 commits into
mainfrom
fix/v5.3.1-numbering
Nov 15, 2026
Merged

iLevyTate merged 2 commits into
mainfrom
fix/v5.3.1-numbering

Conversation

@iLevyTate

Copy link
Copy Markdown
Owner

What

5.3.1: Preview and the Move now give the same names when a run numbers two same-named files apart and the folder already holds a file of that name. A taken numbered name is no longer numbered twice (report_1_1.pdf).

Why

5.3.0 lets Organize number two files of one run that get the same new name (report.pdf, report_1.pdf) instead of refusing the run. Main's own collision walk did not know about those names:

Already in the folder Preview showed The move did
r.pdf a → r_1, b → r_1 b → r_1, a → r_2
r.pdf, r_1.pdf a → r_2, b → r_1_1 the same
r_1.pdf a → r, b → r_1_1 the same

No file was lost (rename-no-replace and the path lock prevent overwrites). The Complete list, the CSV and undo always used the real names.

How

  • The renderer marks the ops it numbered renumbered: true (allowed in the IPC schema).
  • collisionNames.js (new, dependency-free) holds formatNumberedCollisionCandidate (moved here) and numberingBaseOf, which strips Organize's _N from the validated destination. Because it works from the destination itself, the base is always in the same folder, and no second raw path is trusted.
  • performFileMove and the dry-run preview count from that base and skip every name the batch is headed for. The preview also skips the names it has already handed out.
  • New _numberingOrder: when ops share a numbering base and that name or one of their names is already taken on disk, only those ops move one after another, in batch order (the order Preview walked), so each file gets the number Preview showed. Each waits for the op before it before it queues for a slot, so waiting never holds a slot. Every other file keeps the normal 5-at-a-time concurrency, and when a group's names are all free nothing waits.
  • Preview's numbering budget counts disk lookups, not the number, so skipping the batch's own names cannot make Preview give up before the move does.
  • The crash-resume walk and its moved-sibling search use the same base.

Tests

  • test/batchOrganize.batchNumbering.realfs.test.js runs the real handler and preview on a temp directory, covering the three cases above plus a three-file case. Four of them fail on 5.3.0. A file's own _1 name is still numbered as before. Two more tests check that the batch runs in order only when a name is taken.
  • Two resume tests are added to OrganizeResumeService.collisionRecovery.test.js (both fail on 5.3.0), plus schema and renderer assertions.
  • Full local npm run ci parts: static, Jest with coverage, the verify suite and the build.

… a name is taken

Organize numbers two files of one run headed for the same name apart
(report.pdf, report_1.pdf). When the folder already held report.pdf, the
move's collision walk did not know report_1.pdf was meant for the other
file, so Preview and the move disagreed, and a taken report_1.pdf became
report_1_1.pdf.

The renderer marks the ops it numbered (renumbered). The move and the
dry-run preview count a taken name from the name before that number and
skip every name the batch is headed for. Files numbered from one name that
is taken on disk move one after another in batch order; every other file
keeps the batch's concurrency. Crash resume numbers and finds moved files
the same way. formatNumberedCollisionCandidate and numberingBaseOf live in
collisionNames.js so the resume service can use them.
@iLevyTate
iLevyTate merged commit 6e7bb05 into main Nov 15, 2026
8 checks passed
@iLevyTate
iLevyTate deleted the fix/v5.3.1-numbering branch November 15, 2026 01:05
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.

1 participant