Skip to content

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

Open
joshtrichards wants to merge 1 commit into
masterfrom
jtr/desc-and-help-plus-minor-fixes-files-scan
Open

fix(files): files:scan error ouput when user_id is not found + return correct exit status on error#49412
joshtrichards wants to merge 1 commit into
masterfrom
jtr/desc-and-help-plus-minor-fixes-files-scan

Conversation

@joshtrichards

@joshtrichardsjoshtrichards commented Nov 20, 2024

Copy link
Copy Markdown
Member

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 <josh.t.richards@gmail.com>
@joshtrichardsjoshtrichards 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
@joshtrichardsjoshtrichards added this to the Nextcloud 31 milestone Nov 20, 2024
'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
Copy Markdown
MemberAuthor

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 a team, artonge, icewind1991, kesselb and yemkareems and removed request for a teamNovember 20, 2024 20:10
@joshtrichardsjoshtrichards changed the title feat(files): Add help + update description of files:scan + misc fixesfix(files): files:scan error ouput when user_id is not found + return correct exit status on errorNov 21, 2024

@artongeartonge left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe do not move the execute method to ease the review, or do that in a different commit :)

$this
->setName('files:scan')
->setDescription('rescan filesystem')
->setDescription('Scans the filesystem for new files and updates the file cache')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe more explicit, as it does not only detect new files.

Suggested change
->setDescription('Scans the filesystem for new files and updates the file cache')
->setDescription('Scans the filesystem and updates the file cache acording to the detected additions, deletions and updates.')

@blizzzblizzz mentioned this pull request Jan 8, 2025
This was referenced Jan 14, 2025
This was referenced Jan 21, 2025
@blizzzblizzz mentioned this pull request Jan 29, 2025
1 task
@blizzzblizzz modified the milestones: Nextcloud 31, Nextcloud 32Jan 29, 2025
This was referenced Aug 22, 2025
This was referenced Sep 2, 2025
@nextcloud-botnextcloud-bot mentioned this pull request Sep 27, 2025
This was referenced Jan 7, 2026
This was referenced Jan 14, 2026
@nextcloud-botnextcloud-bot mentioned this pull request Jan 22, 2026
This was referenced Jan 29, 2026
This was referenced Feb 11, 2026
@blizzzblizzz modified the milestones: Nextcloud 33, Nextcloud 34Feb 16, 2026
@DorraJaouad
DorraJaouad requested a review from a team as a code ownerApril 23, 2026 09:41
@DorraJaouad
DorraJaouad requested review from artonge, leftybournes and nfebe and removed request for a team and yemkareemsApril 23, 2026 09:41
@nextcloud-botnextcloud-bot mentioned this pull request May 27, 2026
@nextcloud-botnextcloud-bot mentioned this pull request Jun 4, 2026
This was referenced Jun 5, 2026
@susnuxsusnux added the community pull requests from community label Jun 9, 2026
@susnuxsusnux removed this from the Nextcloud 34.0.1 milestone Jun 9, 2026
@salmart-dev

Copy link
Copy Markdown
Contributor

Hey @joshtrichards this PR is quite old, do you want to keep it still open? If so, could you please rebase it and split the changes in different commits, so it's easier to review the changes?

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to reviewWaiting for reviewsbugcommunitypull requests from communityenhancementfeature: filesfeature: occ♻️ refactorRefactor code (not a bug fix, not a feature just refactoring)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

occ files:scan misinterprets wrong path as username occ output not quiet when it should be, exit code not proper

7 participants

@joshtrichards@salmart-dev@artonge@susnux@blizzz@skjnldsv@nextcloud-bot