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

Feature/files list occ command #43342

Closed

Conversation

yemkareems
Copy link
Contributor

@yemkareems yemkareems commented Feb 5, 2024

files:list implemented based on files:scan
List of possible usage

all user based search
occ files:list --all

path based search
occ files:list --path /admin/files
scans the directory and sub directory also

Filter by type

occ files:list --path /admin/files/Media --type video
occ files:list --path /admin/files/Media --type image
occ files:list --path /admin/files/ --type application

Filter by file size

occ files:list --path /admin/files/Media --minSize 9622690
occ files:list --path /admin/files/Media --maxSize 9622690

default sort order is desc
occ files:list --all --sort name
to do asc
occ files:list --all --sort name --order ASC

Non recursive scan and list
occ files:list --path /admin/files/ --shallow
The above does not scan sub directories recursively

All the above params can be combined to have different result sets

  • Resolves: #

Summary

TODO

  • ...

Checklist

@yemkareems
Copy link
Contributor Author

@AndyScherzinger @sorbaugh Please find the above file list implemented based on files:scan. I am not able add you as reviewers so tagged both of you in the comment here.

@yemkareems yemkareems marked this pull request as ready for review February 5, 2024 01:20
@szaimen szaimen removed their request for review February 5, 2024 07:21
apps/files/lib/Command/ListFiles.php Fixed Show fixed Hide fixed
apps/files/lib/Command/ListFiles.php Fixed Show fixed Hide fixed
apps/files/lib/Command/ListFiles.php Fixed Show fixed Hide fixed
apps/files/lib/Command/ListFiles.php Fixed Show fixed Hide fixed
apps/files/lib/Command/ListFiles.php Fixed Show fixed Hide fixed
apps/files/lib/Command/ListFiles.php Fixed Show fixed Hide fixed
apps/files/lib/Command/ListFiles.php Fixed Show fixed Hide fixed
apps/files/lib/Command/ListFiles.php Fixed Show fixed Hide fixed
apps/files/lib/Command/ListFiles.php Fixed Show fixed Hide fixed
apps/files/lib/Command/ListFiles.php Fixed Show fixed Hide fixed
Psalm errors fixed

Signed-off-by: yemkareems <[email protected]>
composer run cs:fix

Signed-off-by: yemkareems <[email protected]>
exectime variable removed to fix psalm error

Signed-off-by: yemkareems <[email protected]>
type hinting corrected

Signed-off-by: yemkareems <[email protected]>
apps/files/lib/Command/ListFiles.php Outdated Show resolved Hide resolved
apps/files/lib/Command/ListFiles.php Outdated Show resolved Hide resolved
apps/files/lib/Command/ListFiles.php Outdated Show resolved Hide resolved
apps/files/lib/Command/ListFiles.php Outdated Show resolved Hide resolved
apps/files/lib/Command/ListFiles.php Outdated Show resolved Hide resolved
apps/files/lib/Command/ListFiles.php Outdated Show resolved Hide resolved
apps/files/lib/Command/ListFiles.php Outdated Show resolved Hide resolved
apps/files/lib/Command/ListFiles.php Outdated Show resolved Hide resolved
apps/files/lib/Command/ListFiles.php Outdated Show resolved Hide resolved
apps/files/lib/Command/ListFiles.php Outdated Show resolved Hide resolved
Scan files replaced with listFiles and all methods refactored accordingly

Signed-off-by: yemkareems <[email protected]>
path made a argument and user extraction logic based on path changed

Signed-off-by: yemkareems <[email protected]>
help doc content changed to start with all first caps

Signed-off-by: yemkareems <[email protected]>
apps/files/lib/Command/ListFiles.php Outdated Show resolved Hide resolved
apps/files/lib/Command/ListFiles.php Outdated Show resolved Hide resolved
apps/files/lib/Command/ListFiles.php Fixed Show resolved Hide resolved
apps/files/lib/Command/ListFiles.php Fixed Show fixed Hide fixed
apps/files/lib/Command/ListFiles.php Fixed Show fixed Hide fixed
apps/files/lib/Command/ListFiles.php Fixed Show fixed Hide fixed
apps/files/lib/Command/ListFiles.php Fixed Show fixed Hide fixed
"name" => $node->getName(),
"size" => $node->getSize() . " bytes",
"perm" => $node->getPermissions(),
"owner" => $node->getOwner()->getDisplayName(),

Check notice

Code scanning / Psalm

PossiblyNullReference Note

Cannot call method getDisplayName on possibly null value
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"owner" => $node->getOwner()->getDisplayName(),
"owner" => $node->getOwner()?->getDisplayName(),

apps/files/lib/Command/ListFiles.php Fixed Show fixed Hide fixed
…hors removed

removed the user loop since only one user is there and copy right authors removed

Signed-off-by: yemkareems <[email protected]>
type hinting corrected

Signed-off-by: yemkareems <[email protected]>

$this->initTools($output);

if (is_object($user)) {

Check notice

Code scanning / Psalm

PossiblyUndefinedVariable Note

Possibly undefined variable $user, first seen on line 167
cs fix ran 

Signed-off-by: yemkareems <[email protected]>
userFolder type hint to fix psalm error

Signed-off-by: yemkareems <[email protected]>
Co-authored-by: Andy Scherzinger <[email protected]>
Signed-off-by: yemkareems <[email protected]>
->addArgument(
"path",
InputArgument::REQUIRED,
'Limit list to this path, eg. path="/alice/files/Music", the user_id is determined by the path parameter'
Copy link
Member

Choose a reason for hiding this comment

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

The description no longer matches with it being moved to and argument. (the path=)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@icewind1991 Updated the description of the path argument

Copy link
Member

Choose a reason for hiding this comment

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

I mean the path=... doesn't match anymore as it's no longer an option, so you no longer specify the path= part

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @icewind1991 not sure if i understood it correctly because i still do occ files:list path=/admin/files/Media --type=video where path is required and the above lists all the video files in the path

updated the description of path

Signed-off-by: yemkareems <[email protected]>
making changes to list folders as directory type

Signed-off-by: yemkareems <[email protected]>
cs fix run for the file

Signed-off-by: yemkareems <[email protected]>
@@ -0,0 +1,301 @@
<?php
/**
* @copyright Copyright (c) 2024, ownCloud, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @copyright Copyright (c) 2024, ownCloud, Inc.
* @copyright Copyright (c) 2024 Kareem <[email protected]>

"name" => $node->getName(),
"size" => $node->getSize() . " bytes",
"perm" => $node->getPermissions(),
"owner" => $node->getOwner()->getDisplayName(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"owner" => $node->getOwner()->getDisplayName(),
"owner" => $node->getOwner()?->getDisplayName(),

apps/files/lib/Command/ListFiles.php Outdated Show resolved Hide resolved
$files = $userFolder->getDirectoryListing();
foreach ($files as $file) {
$includeType = $includeMin = $includeMax = true;
$nodeInfo = $this->getNodeInfo($file);

Check notice

Code scanning / Psalm

ArgumentTypeCoercion Note

Argument 1 of OCA\Files\Command\ListFiles::getNodeInfo expects OCP\Files\File|OCP\Files\Folder, but parent type OCP\Files\Node provided
@susnux susnux added this to the Nextcloud 30 milestone Apr 18, 2024
@artonge
Copy link
Contributor

artonge commented Jul 8, 2024

Closing as it move here: #46352

@artonge artonge closed this Jul 8, 2024
@AndyScherzinger AndyScherzinger removed this from the Nextcloud 30 milestone Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants