Skip to content
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

fix(files): files:scan error ouput when user_id is not found + return correct exit status on error #49412

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

joshtrichards
Copy link
Member

@joshtrichards joshtrichards commented Nov 20, 2024

Summary

Note: This looks like a lengthier change than it really is due to moving the location of execute() for readability.

TODO

  • Determine whether exit code addition means this can't be backported (or whether it's a non-event since it's technically correcting a bug and/or adjusting undocumented behavior)

Notes

There are two behavior changes here to be aware of (in order order of probably significance in terms of being classified as a "breaking change"):

Exit code

Previously even where there were errors the exit code (i.e. echo $?) was still 0. Now any errors mean the code will be 1.

Output is slightly different when user_id is not found (e.g. see #27031 for existing behavior):

Now it is:

www-data@83e3407f887c:~/html$ ./occ files:scan -p "/a"
User 1 out of 1 not found (a)
+---------+-------+-----+---------+---------+--------+--------------+
| Folders | Files | New | Updated | Removed | Errors | Elapsed time |
+---------+-------+-----+---------+---------+--------+--------------+
| 0       | 0     | 0   | 0       | 0       | 1      | 00:00:00     |
+---------+-------+-----+---------+---------+--------+--------------+

Output

Output of occ files with this PR:

Available commands for the "files" namespace:
[...]  
  files:repair-tree                Try and repair malformed filesystem tree structures
  files:scan                       Scans the filesystem for new files and updates the file cache
  files:scan-app-data              rescan the AppData folder
[...]

Output of occ files:scan --help with this PR:

Description:
  Scans the filesystem for new files and updates the file cache

Usage:
  files:scan [options] [--] [<user_id>...]

Arguments:
  user_id                                      Rescan all files of the specified user(s)

Options:
      --output[=OUTPUT]                        Output format (plain, json or json_pretty, default is plain) [default: "plain"]
  -p, --path=PATH                              Limit rescan to the specified path, eg. --path="/alice/files/Music". Overrides the user_id and --all parameters.
      --generate-metadata[=GENERATE-METADATA]  Generate metadata for all scanned files; if specified only generate for named value. [default: ""]
      --all                                    Rescan all files of all known users
      --unscanned                              Only scan files which are marked as not fully scanned
      --shallow                                Do not scan folders recursively
      --home-only                              Only scan the home storage, ignoring any mounted external storage or share
  -h, --help                                   Display help for the given command. When no command is given display help for the list command
  -q, --quiet                                  Do not output any message
  -V, --version                                Display this application version
      --ansi|--no-ansi                         Force (or disable --no-ansi) ANSI output
  -n, --no-interaction                         Do not ask any interactive question
      --no-warnings                            Skip global warnings, show command output only
  -v|vv|vvv, --verbose                         Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
  You can rescan all files or only those of select user(s) or a select path. Statistics will be shown at the end of the scan by default.

Checklist

Also:

Fixes #27031 (improves error output)
Fixes #27029 (adds exit status 1 if any errors during a run)
Refactor: moved main "worker" function location for readability

Signed-off-by: Josh <[email protected]>
@joshtrichards joshtrichards added bug enhancement 3. to review Waiting for reviews feature: files feature: occ ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring) labels Nov 20, 2024
@joshtrichards joshtrichards added this to the Nextcloud 31 milestone Nov 20, 2024
)
->addOption(
'path',
'p',
InputOption::VALUE_REQUIRED,
'limit rescan to this path, eg. --path="/alice/files/Music", the user_id is determined by the path and the user_id parameter and --all are ignored'
'Limit rescan to the specified path, eg. --path="/alice/files/Music". Overrides the user_id and --all parameters; the user_id is determined from the path.'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'Limit rescan to the specified path, eg. --path="/alice/files/Music". Overrides the user_id and --all parameters; the user_id is determined from the path.'
'Limit rescan to the specified path, eg. --path="/alice/files/Music". Overrides the user_id and --all parameters.'

@joshtrichards joshtrichards requested review from icewind1991, kesselb, a team, artonge and yemkareems and removed request for a team November 20, 2024 20:10
@joshtrichards joshtrichards changed the title feat(files): Add help + update description of files:scan + misc fixes fix(files): files:scan error ouput when user_id is not found + return correct exit status on error Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug enhancement feature: files feature: occ ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring)
Projects
None yet
1 participant