Skip to content

fix(worlds): preserve world date on transfer, log delete errors, and keep live region mounted (#630) - #795

Merged
Zaldaryon merged 2 commits into
devfrom
fix/issue-630-worlds-mtime-and-delete-log
Nov 10, 2026
Merged

Zaldaryon merged 2 commits into
devfrom
fix/issue-630-worlds-mtime-and-delete-log

Conversation

@Zaldaryon

Copy link
Copy Markdown
Collaborator

Summary

Addresses three issues reported in #630 across world operations and accessibility:

  1. When transferring a world (copy or move), fse.stat retrieves the source world's timestamps and fse.utimes restores the original access and modification times on the target file, preventing copied saves from appearing at the top of the date-sorted world list. Restoring timestamps catches and ignores errors so restrictive filesystem environments do not abort the transfer.
  2. In deleteWorld, both the inner removal failure and the outer path guard failure now log a warning and a debug line matching the error logging convention established for backup, restore, and transfer operations.
  3. In ManageInstallationWorlds, the version compatibility warning paragraph stays mounted in the DOM with id="target-installation-version-warning", role="status", and aria-live="polite". The target dropdown references it via aria-describedby when active, and screen readers can detect text changes because the live region is already present in the DOM tree.

Type

  • Bug fix
  • Feature
  • Performance
  • Refactor or cleanup
  • Tests only
  • Docs or build

Checklist

  • Targets `dev`, not `main`.
  • `npm run typecheck` passes.
  • `npm run lint:ci` passes.
  • `npm run format:check` passes.
  • `npm run test:coverage` passes, coverage at or above the floor in `vitest.config.ts`.
  • `npm run build:unpack` passes.

Testing

Executed the full test suite and build verification:

  • `npm run typecheck`: 0 errors.
  • `npm run lint:ci`: 0 errors.
  • `npm run format:check`: all files formatted.
  • `npm run test:coverage`: 304 test files passed (1918 tests passed, 2 skipped). Coverage floors exceeded across all metrics:
    • Statements: 95.07% (floor: 94.0%)
    • Branches: 91.29% (floor: 89.0%)
    • Functions: 95.85% (floor: 94.0%)
    • Lines: 97.04% (floor: 96.0%)
  • `npm run build:unpack`: unpacked Linux binary built successfully in `dist/linux-unpacked`.
  • Added unit tests in `tests/ipc/worldsHandlers.test.ts` covering timestamp preservation during copy and move, and warning/debug logging on delete failures.
  • Added DOM tests in `tests/renderer-dom/manageInstallationWorlds.test.tsx` verifying live region persistence and `aria-describedby` association when selecting a target installation with a mismatched version.

Related issues

Fixes #630

@Zaldaryon
Zaldaryon requested a review from Pixnop October 27, 2026 16:56

@Pixnop Pixnop left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed a3da9e37 against dev adab6b96: ran your new tests against dev's code, read every path that copies, restores or deletes a world file, then made utimes fail during a copy and a move, with and without the .catch.

Each fix sits where the issue points. A move is a copy followed by a remove, so restoring the times right after copyFile (worldsHandlers.ts:415) covers both modes, and no other world operation copies a world file (restore goes through tar, which keeps the date). The stat runs after findWorld has refused links and inside the outer try, so a failure there is logged like any other transfer error and the lease is still released. Both delete branches now log at warn with the usual debug line. The warning paragraph is mounted with the page, so its text change gets announced, which is the same pattern as ManageModsSelectionBar. On dev's code the three new tests fail and the other 77 in those two files pass. On this head all 80 pass. It merges cleanly with #791, the other open PR that touches worldsHandlers.ts, and it touches no locale file.

Approving. Note 1 is worth taking here, since it is one line and one test. The rest can wait.

Not blocking

  1. A failed utimes leaves no trace, and nothing tests that it is tolerated. .catch(() => undefined) at worldsHandlers.ts:415 drops the error. On a share or a removable drive that refuses to set times, the copy jumps to the top of the list again, which is what #630 reports, and the log says nothing. I made utimes reject during a move: it returns ok, the source is gone, the copy is there, and nothing about the move is logged. Then I removed the .catch: the same move returns operation-failed and leaves the world in both Installations, and all 80 tests still pass. A debug line in the catch, something like [TRANSFER] Kept the transfer time on the copied world: ..., and one test with vi.spyOn(fse, "utimes").mockRejectedValueOnce(new Error("EPERM")) that expects ok and checks the source and target would pin both.

  2. A failed world backup delete is still silent. On the same page, removeWorldBackupArchive swallows every error (worldsHandlers.ts:150), and deleteWorldBackup turns that into operation-failed with no log call (worldsHandlers.ts:470). An archive held open by an antivirus on Windows gives the player an error and the log no reason, the same cost #630 describes for worlds. The issue doesn't name it, so a follow-up issue is fine. If you take it here, a [DELETE BACKUP] warn line in deleteWorldBackup when the result is not ok covers the manual delete. Pruning has the same gap: pruneOldestBackups returns prune-failed instead of throwing, and its caller only logs a throw (:266), so a prune that cannot remove an archive is silent too.

  3. The warning condition is written out three times. target && worldVersionWarning(installation.version, target.version) appears at ManageInstallationWorlds.tsx:289, :305 and :307, so a later edit to one copy can put the description, the visibility and the text out of step. One const showTargetWarning = ... after the if (!installation) guard would fix it. The id is also a literal (:302), while this component already takes ids from useId() (deleteNameId, :65). aria-live="polite" repeats what role="status" already implies, which is harmless.

  4. The outer delete line reads like a removal failure. The outer catch mostly fires when assertManagedDeletionPath refuses the path, before anything is removed, but "Could not finish deleting this world." (worldsHandlers.ts:308) is close to the inner "Could not finish removing this world save." (:303). The backup handler words its outer branch "Could not prepare this world backup." (:279). Something like "Could not prepare this world delete." would tell a guard refusal from a filesystem error without the debug line.

@Zaldaryon
Zaldaryon merged commit 71ae81f into dev Nov 10, 2026
11 checks passed
@Zaldaryon
Zaldaryon deleted the fix/issue-630-worlds-mtime-and-delete-log branch November 10, 2026 22:58
@Pixnop

Pixnop commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

I reviewed f38e05f6 against a3da9e37: ran both touched test files (81 pass), ran your new tests against a3da9e37, and put each change back to its old form one at a time. This head is what landed in dev, so the open points are for a small follow-up.

Round one

A failed utimes is now logged and tested. The .catch at worldsHandlers.ts:418 writes a [TRANSFER] debug line, and the new test at worldsHandlers.test.ts:987 makes utimes reject during a move. When I removed the .catch, that test failed and no other did. Against a3da9e37 it fails on the missing log line.

The outer delete line now reads as a preparation failure. Could not prepare this world delete. (worldsHandlers.ts:311) matches the backup handler, and the test at :1009 fails on the old string.

The warning condition is written once. showTargetWarning (ManageInstallationWorlds.tsx:251) drives the description, the class and the text. The id comes from useId() (:66), declared before the early return, and aria-live is gone.

A failed backup delete and a failed prune now warn, but no test notices if the lines go away. The warns at worldsHandlers.ts:261 and :476 are right. I removed both and all 81 tests still passed.

Still approved.

Not blocking

  1. Two assertions would pin the backup warn lines. Existing tests already reach both failure paths. In the test at worldsHandlers.test.ts:825, spy on logMessage around the inst-worlds-id delete and expect "warn" with expect.stringContaining("[DELETE BACKUP] Could not remove world backup inst-worlds-id."), since the logged line carries the handler prefix. In the World backups cannot be deleted one by one and have no limit #620 test at :879, expect "warn" with a string containing `[BACKUP] Could not prune world backup ${idPruned}.`, and restore each spy as your utimes test does. I tried both: they pass on this head and fail once the lines are removed.

  2. The warn lines name the backup but not the cause. removeWorldBackupArchive still ends in a bare catch { return false } (worldsHandlers.ts:150), so an archive held open by an antivirus looks the same in the log as a path the guards refused. A debug line with getErrorMessage(error) in that catch would cover the delete and the prune at once. Optional.

Zaldaryon added a commit that referenced this pull request Nov 16, 2026
* Address review follow-ups for merged pull requests

* Test recovery folder recheck after copy

* Align French config recovery messages
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