Uh oh!
There was an error while loading. Please reload this page.
feat: add occ command files:list - #46352
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
60c5d0c to
86dfbfcCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
come-nc
left a comment
There was a problem hiding this comment.
I’m not sure I understand the reasoning behind the path handling.
Would it not be better to have a user argument and a path argument inside this user folder?
Here it forces a path starting with a username, that feels unexpected. Did you try it with groupfolders and such?
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
yemkareems
commented
Jul 9, 2024
@come-nc this was implemented similar to files:scan which had both user_id and path. Since user was extracted from the path it was omitted and path was made a required argument |
come-nc
commented
Jul 9, 2024
This is not the same thing, After discussing with the team: |
Uh oh!
There was an error while loading. Please reload this page.
yemkareems
commented
Jul 29, 2024
Did it as suggested. Now user is a mandatory argument and path may or may not be present. Used getUserFolder in place of get and then get is used on top of getUserFolder instance |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
b934eac to
be1f059Compare| try { | ||
| $userFolder = $this->rootFolder->getUserFolder($user); | ||
| /** @var Folder $pathList **/ | ||
| $pathList = $userFolder->get('/' . $path); |
Check notice
Code scanning / Psalm
PossiblyNullOperand
Signed-off-by: yemkareems <yemkareems@gmail.com>
Signed-off-by: yemkareems <yemkareems@gmail.com>
…directory. Add path to get the list based on the path or else list the user folder. Signed-off-by: yemkareems <yemkareems@gmail.com>
Signed-off-by: yemkareems <yemkareems@gmail.com>
Signed-off-by: yemkareems <yemkareems@gmail.com>
…ngly Signed-off-by: yemkareems <yemkareems@gmail.com>
8921fb8 to
2dd5854Compare| } | ||
| } catch (ForbiddenException $e) { | ||
| $output->writeln( | ||
| "<error>Home storage for user $user not writable or 'files' subdirectory missing</error>" |
There was a problem hiding this comment.
| "<error>Home storage for user $user not writable or 'files' subdirectory missing</error>" | |
| "<error>Home storage for user $user not readable or 'files' subdirectory missing</error>" |
| protected function listFiles( | ||
| string $user, | ||
| OutputInterface $output, | ||
| ?string $path = "", |
There was a problem hiding this comment.
| ?string $path = "", | |
| string $path = "", |
| } catch (\Exception $e) { | ||
| $output->writeln( | ||
| "<error>Exception during list: " . $e->getMessage() . "</error>" | ||
| ); | ||
| $output->writeln("<error>" . $e->getTraceAsString() . "</error>"); | ||
| } |
There was a problem hiding this comment.
| } catch (\Exception $e) { | |
| $output->writeln( | |
| "<error>Exception during list: " . $e->getMessage() . "</error>" | |
| ); | |
| $output->writeln("<error>" . $e->getTraceAsString() . "</error>"); | |
| } | |
| } |
You can simply let unexpected exceptions bubble up, parent class takes care of showing the trace depending on verbosity if I recall correctly.
| /** | ||
| * Initialises some useful tools for the Command | ||
| */ | ||
| protected function initTools(OutputInterface $output): void { | ||
| // Convert PHP errors to exceptions | ||
| set_error_handler( | ||
| fn ( | ||
| int $severity, | ||
| string $message, | ||
| string $file, | ||
| int $line | ||
| ): bool => $this->exceptionErrorHandler( | ||
| $output, | ||
| $severity, | ||
| $message, | ||
| $file, | ||
| $line | ||
| ), | ||
| E_ALL | ||
| ); | ||
| } | ||
| /** | ||
| * Processes PHP errors in order to be able to show them in the output | ||
| * | ||
| * @see https://www.php.net/manual/en/function.set-error-handler.php | ||
| * | ||
| * @param int $severity the level of the error raised | ||
| * @param string $message | ||
| * @param string $file the filename that the error was raised in | ||
| * @param int $line the line number the error was raised | ||
| */ | ||
| public function exceptionErrorHandler( | ||
| OutputInterface $output, | ||
| int $severity, | ||
| string $message, | ||
| string $file, | ||
| int $line | ||
| ): bool { | ||
| if ($severity === E_DEPRECATED || $severity === E_USER_DEPRECATED) { | ||
| // Do not show deprecation warnings | ||
| return false; | ||
| } | ||
| $e = new \ErrorException($message, 0, $severity, $file, $line); | ||
| $output->writeln( | ||
| "<error>Error during list: " . $e->getMessage() . "</error>" | ||
| ); | ||
| $output->writeln( | ||
| "<error>" . $e->getTraceAsString() . "</error>", | ||
| OutputInterface::VERBOSITY_VERY_VERBOSE | ||
| ); | ||
| return true; | ||
| } |
There was a problem hiding this comment.
Why all this?
This is the only command that do that to my knowledge.
Nextcloud already has an exception handler which logs them I think.
I suggest to remove this.
Duplicate pr of #43342 since CI CD issues are there in the original PR
Possible usage example with params
occ files:list admin --path abc --sort name --order ASC --minSize 100 --maxSize 1008400 --type application
Sample usage
occ files:list admin
if path is not mentioned list all files in the root directory of the user
occ files:list admin --path abc
if path is mentioned list all files in the path mentioned alone
occ files:list admin --sort name --order ASC
occ files:list alice --path Media --sort size --order DESC
occ files:list admin --type image
occ files:list admin --type application --minSize 2750 --maxSize 148415
Summary
TODO
Checklist