Repository navigation
fix(organize): 5.3.1 — Preview and the move agree on numbered names - #137
Merged
Merged
Conversation
… 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.
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.
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:r.pdfr_1, b →r_1r_1, a →r_2r.pdf,r_1.pdfr_2, b →r_1_1r_1.pdfr, b →r_1_1No 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
renumbered: true(allowed in the IPC schema).collisionNames.js(new, dependency-free) holdsformatNumberedCollisionCandidate(moved here) andnumberingBaseOf, which strips Organize's_Nfrom 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.performFileMoveand 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._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.Tests
test/batchOrganize.batchNumbering.realfs.test.jsruns 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_1name is still numbered as before. Two more tests check that the batch runs in order only when a name is taken.OrganizeResumeService.collisionRecovery.test.js(both fail on 5.3.0), plus schema and renderer assertions.npm run ciparts: static, Jest with coverage, the verify suite and the build.