Skip to content

fix(installations): report expired folder approval separately from write failure (#742) - #794

Merged
Zaldaryon merged 2 commits into
devfrom
fix/issue-742-installation-folder-approval-expired
Nov 10, 2026
Merged

Zaldaryon merged 2 commits into
devfrom
fix/issue-742-installation-folder-approval-expired

Conversation

@Zaldaryon

Copy link
Copy Markdown
Collaborator

Summary

When adding an Installation with an external folder selected via Browse, waiting more than ten minutes before clicking Add caused the notification:
"Couldn't create the folder for this Installation. Check that RiftLauncher can write to that location, then try again."

In that scenario, filesystem permissions are fine; the user approval in isUserApprovedPath expired past its 10-minute TTL. ENSURE_PATH_EXISTS previously returned a boolean, swallowing the assertManagedPath refusal and grouping it with generic creation errors.

This change:

  1. Updates ENSURE_PATH_EXISTS to return `{ ok: true } | { ok: false; reason: "unauthorized-path" | "failed" }`.
  2. In AddInstallation, inspects the failure reason and notifies `t("features.installations.pickFolderAgain")` when authorization expired, matching the phrasing used by Look for a VS Version.
  3. Preserves the write permission error for genuine filesystem failures (ensureDir throwing EACCES or EEXIST).
  4. Adds unit and DOM regression tests for both expired approval and filesystem failure cases.

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

Ran all 5 local gate commands:

  • `npm run typecheck`: clean pass across node, web, and tests.
  • `npm run lint:ci`: 0 errors.
  • `npm run format:check`: all matched files match Prettier code style.
  • `npm run test:coverage`: 304 test files passed (5934 tests passed, 5 skipped), coverage: Statements 95.08%, Branches 91.31%, Functions 95.89%, Lines 97.03%.
  • `npm run build:unpack`: Linux unpacked build generated successfully.

Related issues

Fixes #742

…ite failure (#742)

Add Installation previously reported any ENSURE_PATH_EXISTS failure as a write permission error. When the player picks an external folder with Browse and waits more than ten minutes before submitting, the path approval TTL expires and assertManagedPath refuses with an unauthorized path rather than an OS filesystem failure.

Update ENSURE_PATH_EXISTS to return a result object with a failure reason ("unauthorized-path" vs "failed"). In Add Installation, notify the player to pick the folder again when authorization expired, matching the behavior in Look for a VS Version.
@Zaldaryon
Zaldaryon requested a review from Pixnop October 27, 2026 16:29
@github-actions

Copy link
Copy Markdown

Translation status

en-US is the source and carries 958 keys.

Locale Keys Missing Stale To review on Weblate
be-BY 882 113 0 Needs editing
de-DE 855 103 0 Needs editing
es-ES 882 113 0 Needs editing
fr-FR 995 0 0 Needs editing
hu-HU 855 103 0 Needs editing
it-IT 882 113 0 Needs editing
nl-NL 855 103 0 Needs editing
pl-PL 882 113 0 Needs editing
pt-BR 883 112 0 Needs editing
pt-PT 882 113 0 Needs editing
ru-RU 996 1 2 Needs editing
uk-UA 882 113 0 Needs editing
zh-CN 828 93 0 Needs editing

The links open the strings Weblate marks Needs editing for each language: the machine drafts made before Weblate, plus any string whose English changed since it was translated. See #496.

@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 42fb8529 against dev adab6b96: ran your new tests against dev's code, followed every caller of the new ENSURE_PATH_EXISTS shape, and put the #742 handler test through a mutation.

The split is where #742 needs it. The first assertManagedPath refusal used to be swallowed into false, and Add Installation turned every false into the write-permission message. Since #411 that field only changes through Browse, so in practice that first refusal is the expired pick. Every caller moved to the new type: AddInstallation, the ensure branch of useOpenPathInExplorer, the packaged e2e, the mock window API and the DOM tests. translation-status.md matches the generator. On dev's code the 6 changed handler tests and both DOM tests fail, and on this head the three touched test files pass, 144 tests.

Approving. Notes 1 and 2 are worth taking here, since note 1 is a message this PR makes untrue and note 2 removes a string translators would otherwise have to do twice. The rest can wait.

Not blocking

  1. A symbolic link refusal now reads as an expired pick. The second catch (pathsHandlers.ts:403) maps every TypeError to unauthorized-path, and that includes the strict assertManagedPath refusing a link among the existing ancestors (validation.ts:237/242). Scenario: the player's Installations folder is a link to another drive, and they keep the suggested <Installations>/My-New-Installation. The first check passes with allowSymlinks, stat finds nothing, the strict check throws, and Add Installation says the ten minutes are up, although nothing was picked. Picking again changes nothing, so the player gets that message every time. On dev it was the vaguer write-permission message, which was at least not false. The updated test "refuses to create a folder through the link" now pins unauthorized-path. I'd keep unauthorized-path for the first refusal only, and let anything in the second block return failed (or a reason of its own if you want a dedicated message). The message.includes("Symbolic links are not allowed") arm then goes too. It never decided anything anyway, since both symlink refusals are already TypeErrors.

  2. The new string already exists. features.installations.pickFolderAgain is word for word features.versions.pickFolderAgain, which ru-RU has already translated. With a second key, ru-RU goes from 0 to 1 missing and the other eleven locales get one more string to do. Pointing AddInstallation at the existing key, or moving it to a shared one, avoids that. It also takes this PR out of the locale files, which matters for merge order: #793 also adds a key and regenerates translation-status.md, and whichever of the two lands second leaves the page at 958 keys where there are 959, unless it is regenerated after the rebase.

  3. The #742 handler test doesn't show the approval ever applied. With registerUserSelectedPaths([picked]) removed, "returns unauthorized-path when user folder approval has expired (#742)" still passes, because nothing grants that folder anyway. Calling ENSURE_PATH_EXISTS on picked itself and asserting { ok: true } before moving the clock makes it hold. I tried it, and it passes. A child of picked would not do: picked doesn't exist when it is registered, so the approval covers that one path only. vi.useRealTimers() also sits after the assertion, so a failure leaves Date faked for the rest of the file. A try/finally fixes that.

  4. Add VS Version has the same problem. A folder outside the configured ones, picked on Add VS Version and left more than ten minutes before Install, fails in DOWNLOAD_ON_PATH's strict assertManagedPath. That comes back as download-failed, and the player is told to check their connection. That is outside #742, so it can be its own issue.

  5. Two stale comments. In pathsHandlers.ts:386-389 the "Only a directory counts as present" paragraph still says the plain-file case "lands on false", and it now sits above the first check while the stat/ensureDir it describes moved to the second try. In pathsHandlers.test.ts:467 the comment you rewrote still says AddInstallation's folder field is free text, which hasn't been true since #411 (the field is readOnly).

@Zaldaryon
Zaldaryon merged commit 33e45b2 into dev Nov 10, 2026
11 checks passed
@Zaldaryon
Zaldaryon deleted the fix/issue-742-installation-folder-approval-expired branch November 10, 2026 22:55
@Pixnop

Pixnop commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

I reviewed 8ac1f566 against 42fb8529: read the new commit, ran the touched handler and DOM tests on this head, and put each fixed bug back to see which test catches it.

Round one

A link refusal no longer claims the ten minutes are up. Only the first, relaxed assertManagedPath refusal returns unauthorized-path now (pathsHandlers.ts:388). Everything in the second block, including the strict walk refusing a linked Installations folder, returns failed (pathsHandlers.ts:402). With the old TypeError arm put back, "ENSURE_PATH_EXISTS refuses to create a folder through the link" (pathsHandlers.test.ts:611) goes red.

The duplicate string is gone. AddInstallation uses features.versions.pickFolderAgain (AddInstallation.tsx:107), so the PR no longer touches any locale file or translation-status.md, and ru-RU stays at 0 missing. The wording fits both forms. Making AddInstallation ignore reason turns "notifies to pick the folder again when user approval has expired (#742)" red.

The #742 handler test now proves the approval applied. It asserts { ok: true } on picked before moving the clock (pathsHandlers.test.ts:500), and the fake timers sit in try/finally. Removing registerUserSelectedPaths([picked]) now fails it.

Thanks for opening #807 for the Add VS Version case.

Both stale comments are fixed and now match the code.

The translation table the bot posted on this PR is from the old head and still says 958 keys. It no longer refreshes because the PR left the locale files. The page in the repository is right.

Still approved.

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