Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
027d692
files:list added as a occ command. filter added based on type and siz…
yemkareems Feb 3, 2024
b9caee2
basic sorting added to list, could be improvised
yemkareems Feb 4, 2024
f90b106
listing files and folders separately as sorting is not working as exp…
yemkareems Feb 4, 2024
1503053
general refactoring to remove unused variables and functions, edge ca…
yemkareems Feb 4, 2024
2b915f3
Update ListFiles.php
yemkareems Feb 7, 2024
7e27fbe
composer run cs:fix
yemkareems Feb 7, 2024
d82b3b3
Update ListFiles.php
yemkareems Feb 7, 2024
a035d41
type hinting
yemkareems Feb 7, 2024
ac4efa8
PR review comments by Louis done
yemkareems Feb 9, 2024
92e5516
path made a argument and user extraction logic based on path changed
yemkareems Feb 9, 2024
d59769e
help doc content changed to start with all first caps
yemkareems Feb 9, 2024
1764794
removed the user loop since only one user is there and copy right aut…
yemkareems Feb 12, 2024
5638ef2
type hinting corrected
yemkareems Feb 12, 2024
79b5410
cs fix ran
yemkareems Feb 13, 2024
4058838
array multisort assigning to var and passing it
yemkareems Feb 13, 2024
90f5d26
userFolder type hint to fix psalm error
yemkareems Feb 13, 2024
351d671
Update apps/files/lib/Command/ListFiles.php
yemkareems Feb 13, 2024
0cfb4dd
updated the description of path
yemkareems Feb 16, 2024
fc20909
making changes to list folders as directory type
yemkareems Feb 18, 2024
14078fc
cs fix run for the file
yemkareems Feb 18, 2024
9b129a6
telling psalm correct path of folder
yemkareems Apr 4, 2024
57752e6
feat: tell psalm the correct type associated with userFolder
yemkareems Apr 4, 2024
e8573aa
feat: tell psalm the correct type associated with userFolder
yemkareems Apr 4, 2024
c5ded86
feat: license wording changed as suggested
yemkareems Apr 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
listing files and folders separately as sorting is not working as exp…
…ected
  • Loading branch information
yemkareems committed Feb 4, 2024
commit f90b1065f07c822593a8c73c0c0edf710b9b87c0
21 changes: 17 additions & 4 deletions apps/files/lib/Command/ListFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@
use OC\FilesMetadata\FilesMetadataManager;
use OC\ForbiddenException;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Events\FileCacheUpdated;
use OCP\Files\Events\NodeAddedToCache;
use OCP\Files\Events\NodeRemovedFromCache;
use OCP\Files\IRootFolder;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\NotFoundException;
Expand All @@ -60,6 +57,7 @@
class ListFiles extends Base {

protected array $fileInfo = [];
protected array $dirInfo = [];
public function __construct(
private IUserManager $userManager,
private IRootFolder $rootFolder,
Expand Down Expand Up @@ -196,7 +194,8 @@ protected function scanFiles(

$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) {
$node = $this->rootFolder->get($path);
$this->fileInfo[] = [

$this->dirInfo[] = [
"name" => $node->getName(),
'path' => $path,
"size" => $node->getSize() . " bytes",
Expand All @@ -205,6 +204,7 @@ protected function scanFiles(
"created-at" => $node->getCreationTime(),
"type" => 'dir'
];

$this->abortIfInterrupted();
});

Expand Down Expand Up @@ -362,6 +362,7 @@ protected function presentStats(InputInterface $input, OutputInterface $output):
$sortKey = array_key_exists($input->getOption('sort'), $this->fileInfo[0]) ? $input->getOption('sort') : 'name';
$order = ($input->getOption('order') == 'ASC') ? SORT_ASC : SORT_DESC;
array_multisort (array_column($this->fileInfo, $sortKey), $order, $this->fileInfo);
array_multisort (array_column($this->dirInfo, $sortKey), $order, $this->dirInfo);

foreach ($this->fileInfo as $k => $item) {
$rows[$k] = [
Expand All @@ -374,6 +375,18 @@ protected function presentStats(InputInterface $input, OutputInterface $output):
$item['type']
];
}
foreach ($this->dirInfo as $k => $item) {
$rows[] = [
$item['perm'],
$item['size'],
$item['owner'],
$item['created-at'],
$item['name'],
$item['path'],
$item['type']
];
}

$table = new Table($output);
$table
->setHeaders($headers)
Expand Down