Skip to content

fix(workspace): reuse WorkspaceService file lookup in direct()#8507

Open
joshtrichards wants to merge 6 commits intomainfrom
jtr/fix-workspace-getFile
Open

fix(workspace): reuse WorkspaceService file lookup in direct()#8507
joshtrichards wants to merge 6 commits intomainfrom
jtr/fix-workspace-getFile

Conversation

@joshtrichards
Copy link
Copy Markdown
Member

📝 Summary

The direct() action had a private getFile() helper that duplicated file-discovery logic already implemented in WorkspaceService::getFile().

This caused direct() to behave differently from folder() and publicFolder() in one important way: the private helper used continue rather than an early return, so it returned the last matched file in the priority-ordered filename list rather than the first. WorkspaceService::getFile() correctly returns on the first match.

By switching direct() to WorkspaceService::getFile(), it now also benefits from the service’s cache-based lookup and storage-invalid handling.

Changes

  • Remove WorkspaceController::getFile()
  • Replace its use in direct() with $this->workspaceService->getFile()
  • Remove the now-unused use OCP\Files\File import
  • Collapse the redundant legacy @copyright/@author/@license docblock into
    the existing SPDX header

Testing

Add minimal unit coverage for WorkspaceService::getFile() to verify:

  • first-match priority is preserved
  • directory cache entries are ignored
  • invalid storage returns null

direct() now reuses the same lookup implementation as folder() and publicFolder().

P.S. The namespaces used for our unit test classes in this repo are inconsistent; not a functional problem but some are in a clearly dedicated "test" space while others use production code namespaces.

🖼️ Screenshots

🏚️ Before 🏡 After
B A

🚧 TODO

  • ...

🏁 Checklist

  • Code is properly formatted (npm run lint / npm run stylelint / composer run cs:check)
  • Sign-off message is added to all commits
  • Tests (unit, integration and/or end-to-end) passing and the changes are covered with tests
  • Documentation (README or documentation) has been updated or is not required

…ervice

Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant