-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add occ command files:list #46352
base: master
Are you sure you want to change the base?
Conversation
60c5d0c
to
86dfbfc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
@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 |
This is not the same thing, After discussing with the team: |
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 |
b934eac
to
be1f059
Compare
be1f059
to
363c391
Compare
8267c6d
to
8921fb8
Compare
Signed-off-by: yemkareems <[email protected]>
Signed-off-by: yemkareems <[email protected]>
Signed-off-by: yemkareems <[email protected]>
… converted, user check removed Signed-off-by: yemkareems <[email protected]>
Signed-off-by: yemkareems <[email protected]>
Signed-off-by: yemkareems <[email protected]>
… breaking the listing, inputPath check removed as path is mandatory, sorting done only when sort param is there, writeTableInOutputFormat done Signed-off-by: yemkareems <[email protected]>
Signed-off-by: yemkareems <[email protected]>
Signed-off-by: yemkareems <[email protected]>
…directory. Add path to get the list based on the path or else list the user folder. Signed-off-by: yemkareems <[email protected]>
Signed-off-by: yemkareems <[email protected]>
Signed-off-by: yemkareems <[email protected]>
…ngly Signed-off-by: yemkareems <[email protected]>
8921fb8
to
2dd5854
Compare
} | ||
} 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"<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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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