11<?php
2+ declare (strict_types=1 );
23/**
34 * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
45 * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
89
910use OC \Core \Command \Base ;
1011use OC \Core \Command \InterruptedException ;
12+ use OC \Files \Node \Node ;
1113use OC \FilesMetadata \FilesMetadataManager ;
1214use OC \ForbiddenException ;
1315use OCP \EventDispatcher \IEventDispatcher ;
@@ -49,13 +51,13 @@ protected function configure(): void {
4951 ->addOption ("type " , "" , InputArgument::OPTIONAL , "Filter by type like application, image, video etc " )
5052 ->addOption (
5153 "minSize " ,
52- ' 0 ' ,
54+ 0 ,
5355 InputArgument::OPTIONAL ,
5456 "Filter by min size "
5557 )
5658 ->addOption (
5759 "maxSize " ,
58- ' 0 ' ,
60+ 0 ,
5961 InputArgument::OPTIONAL ,
6062 "Filter by max size "
6163 )
@@ -68,7 +70,7 @@ protected function configure(): void {
6870 ->addOption ("order " , "ASC " , InputArgument::OPTIONAL , "Order is either ASC or DESC " );
6971 }
7072
71- private function getNodeInfo (File | Folder $ node ): array {
73+ private function getNodeInfo (Node $ node ): array {
7274 $ nodeInfo = [
7375 "name " => $ node ->getName (),
7476 "size " => $ node ->getSize () . " bytes " ,
@@ -98,9 +100,11 @@ protected function listFiles(
98100
99101 $ files = $ userFolder ->getDirectoryListing ();
100102 foreach ($ files as $ file ) {
103+ /** @var Node $fileNode */
104+ $ fileNode = $ file ;
101105 $ includeType = $ includeMin = $ includeMax = true ;
102- $ nodeInfo = $ this ->getNodeInfo ($ file );
103- if ($ type != "" && $ type != $ nodeInfo ['type ' ]) {
106+ $ nodeInfo = $ this ->getNodeInfo ($ fileNode );
107+ if ($ type !== "" && $ type != = $ nodeInfo ['type ' ]) {
104108 $ includeType = false ;
105109 }
106110 if ($ minSize > 0 ) {
@@ -147,16 +151,14 @@ protected function execute(
147151 OutputInterface $ output
148152 ): int {
149153 $ inputPath = $ input ->getArgument ("path " );
154+ $ user = '' ;
150155 if ($ inputPath ) {
151156 $ inputPath = ltrim ($ inputPath , "path= " );
152157 [, $ user ] = explode ("/ " , rtrim ($ inputPath , "/ " ).'/ ' , 4 );
153158 }
154159
155160 $ this ->initTools ($ output );
156161
157- if (is_object ($ user )) {
158- $ user = $ user ->getUID ();
159- }
160162 $ path = $ inputPath ?: "/ " . $ user ;
161163
162164 if ($ this ->userManager ->userExists ($ user )) {
@@ -168,8 +170,8 @@ protected function execute(
168170 $ path ,
169171 $ output ,
170172 $ input ->getOption ("type " ),
171- $ input ->getOption ("minSize " ),
172- $ input ->getOption ("maxSize " )
173+ ( int ) $ input ->getOption ("minSize " ),
174+ ( int ) $ input ->getOption ("maxSize " )
173175 );
174176 } else {
175177 $ output ->writeln (
0 commit comments