refactor/file service - #9028
Conversation
max-nextcloud
commented
Aug 11, 2026
- refactor(backend): introduce FileService
- chore(refactor): separate file getters for share and user
- chore(refactor): get file in controller for apiService->create
- chore(refactor): use constructor promotion for DocumentServce
- chore(refactor): move file getters into FileService
f672b62 to
ccbb342
Compare
5faa125 to
d3f9fe3
Compare
d3f9fe3 to
c9d35f7
Compare
Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Max <max@nextcloud.com>
…vice Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Max <max@nextcloud.com>
c4cca9f to
7232808
Compare
* `checkSharePermissions` has not been throwing `NotPermittedException` for a while. See #3765 . * `InvalidArgumentException` was not being handled. * throw `NotFoundException` if file cannot be found and there is no share token. Signed-off-by: Max <max@nextcloud.com>
7232808 to
5907ff4
Compare
| } | ||
|
|
||
| public function unlock(File $file): void { | ||
| if (!$this->lockManager->isLockProviderAvailable()) { |
There was a problem hiding this comment.
nitpick: is there an advantage to calling this method here?
lockManager checks if there's a lockprovider as well, so if there is a lockProvider lockManager->getLockProvider is called twice?
same in the lock method
|
|
||
| // Workaround to always open files with edit permissions if multiple occurrences of | ||
| // the same file id are in the user home, ideally we should also track the path of the file when opening | ||
| usort($files, static fn (Node $a, Node $b) => ($b->getPermissions() & Constants::PERMISSION_UPDATE) <=> ($a->getPermissions() & Constants::PERMISSION_UPDATE)); |
There was a problem hiding this comment.
I think this can be done more efficient. If I get this right this sorts the array by comparing if the PERMISSION_UPDATE is present, so essentially is a search for an element in the array which has the PERMISSION_UPDATE without control over which of those comes first?
as afterwards it's checked if there's also PERMISSION_READ I think this can be simplified into a for loop that searches for a file with PERMISSION_READ and PERMISSION_UPDATE.
something like this:
foreach ($files as $file) {
if ($file->getPermissions() & (Constants::PERMISSION_UPDATE | Constants::PERMISSION_READ) === 3) {
return $file;
}
Addresses #9028 (comment) . Signed-off-by: Max <max@nextcloud.com>