Skip to content

fix(organize): a run stopped by failures lists the files it did not try - #127

Open
iLevyTate wants to merge 1 commit into
mainfrom
fix/stopped-run-reports-untried-files
Open

iLevyTate wants to merge 1 commit into
mainfrom
fix/stopped-run-reports-untried-files

Conversation

@iLevyTate

Copy link
Copy Markdown
Owner

Follow-up to #126, which listed this under "Not in this PR": a run stopped by failures before any move was confirmed has nothing to roll back, and its result left out the files it never tried.

What changes

The batch handler (batchOrganizeHandler.js)

  • Three failures in a row of a kind that counts as systemic (or the first failure in strict mode) stop the run. Before, files that were mid-move got an interrupted row, files that had not started got no row, and the summary counted neither ("0 successful, 4 failed" for a run of 8).
  • Every op of the batch now gets exactly one row. An op the run did not reach is notAttempted: true. It is not interrupted, because the journal batch is closed and nothing resumes it.
  • A stopped run with nothing to roll back returns stoppedOnFailure: true, stopReason and notAttemptedCount, and its summary ends with the count: Processed 8 files: 0 successful, 3 failed, 5 not attempted. success stays false.
  • A rolled-back result carries notAttemptedCount and the same rows.
  • A file an earlier run already moved keeps its resumed row when the resumed run is stopped. It had no row before.
  • Runs that are not stopped, and runs the user cancels or that are interrupted, return what they returned before.

The Organize screen (useOrganization.js)

  • A stopped run with nothing moved shows one error: "Organization was stopped; no files were moved.", then the first failure, then "The run was stopped after 3 failures; 5 files were not attempted." Before, it read "No files were organized" with the first failure only.
  • Untried files are not counted as failures.
  • The rolled-back message ends with how many files were not attempted.

Undo history (UndoRedoSystem.jsx)

  • A stopped batch adds no undo entry and shows no "completed" toast. Main records no undo for it, so a local entry would point Undo at the previous action.

Not in this PR

  • A run in which every file fails on its own, without being stopped, still gets a local undo entry and an "Organize N files completed" toast beside the error. Main records no undo for it. This is on main today (observed with a throwaway test, not committed) and needs its own change, because the same toast also appears beside the warning for a partly failed run.
  • The dashboard's move-failure count, the last-run summary surviving a restart, and the Dashboard "Organized" figure excluding duplicates.

Checks

Windows 11 x64, on this branch's tree:

  • npm run local:gate, every step: 957 test suites, 14169 tests passed, 11 skipped, coverage thresholds met, production build, native modules.
  • New tests (11). test/batchOrganizeHandler.failureHandling.test.js (6, mocked filesystem): a stopped run with nothing moved, the same with several files at a time, strict mode, a run that was not stopped, a stopped run with a move to undo, and a resumed run. test/batchOrganize.moveCheckFailsAlone.realfs.test.js (1, real filesystem in a temp folder): a destination that takes every temporary copy stops the run, every one of the 8 files has a row and all 8 are still in the input folder. test/useOrganization.runOutcome.test.js (2), test/useOrganization.rolledBackBatch.test.js (1) and test/components/UndoRedoSystem.rolledBackBatch.test.js (1) cover the messages and the undo history.
  • Nine one-line reversals of the change (untried rows marked interrupted again, the stop fields dropped, the count left out of the rollback result and of the summary, untried rows counted as failures, the stop sentence and the headline dropped, the count left out of the rolled-back message, the undo guard removed) each fail at least one of the new tests. The files were restored after each.

Not checked: macOS and Ubuntu (this PR's CI runs Ubuntu; macOS runs when main next builds), a packaged build, and the Organize screen in the running app. The messages are checked through the hook's tests, not by eye.

Three failures in a row of a kind that counts as systemic (or the first
failure in strict mode) stop a batch. When no move had been confirmed
there is nothing to roll back, so the result carried no rolledBack flag.
Files that were mid-move got an "interrupted" row, files that had not
started got no row, and the summary counted neither ("0 successful, 4
failed" for a run of 8). The Organize screen showed "No files were
organized" with the first failure only.

- The batch handler writes one row for every op. An op the run did not
  reach is `notAttempted`, not `interrupted`: nothing resumes it. The
  result has stoppedOnFailure, stopReason and notAttemptedCount, and the
  summary ends with "N not attempted".
- A rolled-back result carries notAttemptedCount and the same rows.
- A file an earlier run already moved keeps its row when the resumed run
  is stopped.
- The Organize screen says "Organization was stopped; no files were
  moved", then the first failure, the number of failures and the number
  of files not attempted. Untried files are not counted as failures. The
  rolled-back message also says how many files were not attempted.
- The undo provider adds no history entry and shows no "completed" toast
  for a stopped batch. Main records no undo for it.

This branch has not been deployed

No deployments
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