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

add command for getting fileinfo for debugging #37525

Merged
merged 2 commits into from
Apr 21, 2023
Merged

Conversation

icewind1991
Copy link
Member

@icewind1991 icewind1991 commented Mar 31, 2023

Attempts to provide information that might be useful when debugging issues as well as perform some sanity checks.
This hopefully allows people without knowledge of the Nextcloud internals to access debug information that is currently only accessible trough manual database querying or other convoluted steps.

occ info:file <fileid or path>

Currently includes:

  • basic file metadata
  • bucket + object info when using objectstore
  • validate object existence and size
  • list of users with access, their permissions and how they got their access
  • basic groupfolder and external storage info
  • option to list contents of folder
  • validate folder size against children

(Possible) future work

  • validate encrypted files
  • validate folder size
  • option to show versions
  • more details from storage backends
  • anything else that might be useful that currently isn't exposed

@icewind1991 icewind1991 added the 3. to review Waiting for reviews label Mar 31, 2023
@icewind1991 icewind1991 added this to the Nextcloud 27 milestone Mar 31, 2023
@icewind1991 icewind1991 requested review from a team, ArtificialOwl, blizzz and come-nc and removed request for a team March 31, 2023 17:10
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

Psalm found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.

Copy link
Contributor

@come-nc come-nc left a comment

Choose a reason for hiding this comment

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

Awesome tool.

Maybe instead of adding debug to the description, just remove debug mention from the command name since this may be useful in a whole number of usecase outside of debug? (like an admin wanting a list of shares of a file to check who has access)

@icewind1991
Copy link
Member Author

  • Changed the naming from debug:file to info:file
  • added (optional) listing of folder children
  • added size to output

$bucket = array_pop($parts);
$output->writeln(" bucket: " . $bucket);
if ($node instanceof \OC\Files\Node\File) {
$output->writeln(" object id: " . $storage->getURN($node->getId()));

Check notice

Code scanning / Psalm

PossiblyNullOperand

Cannot concatenate with a possibly null null|string
@icewind1991 icewind1991 force-pushed the file-debug-info branch 2 times, most recently from 7858d4b to bbb2474 Compare April 14, 2023 14:18
@icewind1991 icewind1991 force-pushed the file-debug-info branch 2 times, most recently from 1b6381a to 96f9c17 Compare April 14, 2023 15:07
Copy link
Member

Choose a reason for hiding this comment

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

In-place of the manual stdout formatting we could use the built-in Symfony methods https://symfony.com/doc/current/console/style.html#helper-methods ?

@icewind1991 icewind1991 merged commit 1bff4e2 into master Apr 21, 2023
@icewind1991 icewind1991 deleted the file-debug-info branch April 21, 2023 12:18
@nextcloud nextcloud deleted a comment from backportbot-nextcloud bot Apr 24, 2023
@nextcloud nextcloud deleted a comment from backportbot-nextcloud bot Apr 24, 2023
@nextcloud nextcloud deleted a comment from backportbot-nextcloud bot May 1, 2023
@nextcloud nextcloud deleted a comment from backportbot-nextcloud bot May 1, 2023
@icewind1991
Copy link
Member Author

/backport to stable26

@icewind1991
Copy link
Member Author

/backport to stable25

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants