@@ -61,24 +61,27 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6161 $ user = $ input ->getOption ('user ' );
6262 $ size = $ input ->getArgument ('size ' );
6363
64- if ($ size ) {
65- $ parsedSize = \OC_Helper::computerFileSize ($ size );
66- if ($ parsedSize === false ) {
67- $ output ->writeln ("<error>Failed to parse input size</error> " );
68- return self ::FAILURE ;
69- }
70- if ($ user ) {
71- $ this ->config ->setUserValue ($ user , 'files_trashbin ' , 'trashbin_size ' , (string )$ parsedSize );
72- $ this ->commandBus ->push (new Expire ($ user ));
73- } else {
74- $ this ->config ->setAppValue ('files_trashbin ' , 'trashbin_size ' , (string )$ parsedSize );
75- $ output ->writeln ("<info>Warning: changing the default trashbin size will automatically trigger cleanup of existing trashbins,</info> " );
76- $ output ->writeln ("<info>a users trashbin can exceed the configured size until they move a new file to the trashbin.</info> " );
77- }
78- } else {
64+ if (!$ size ) {
7965 $ this ->printTrashbinSize ($ input , $ output , $ user );
66+ return self ::SUCCESS ;
67+ }
68+
69+ $ parsedSize = \OC_Helper::computerFileSize ($ size );
70+ if ($ parsedSize === false ) {
71+ $ output ->writeln ("<error>Failed to parse input size</error> " );
72+ return self ::FAILURE ;
8073 }
8174
75+ if ($ user ) {
76+ $ this ->config ->setUserValue ($ user , 'files_trashbin ' , 'trashbin_size ' , (string )$ parsedSize );
77+ $ this ->commandBus ->push (new Expire ($ user ));
78+ return self ::SUCCESS ;
79+ }
80+
81+ $ this ->config ->setAppValue ('files_trashbin ' , 'trashbin_size ' , (string )$ parsedSize );
82+ $ output ->writeln ("<info>Warning: changing the default trashbin size will automatically trigger cleanup of existing trashbins,</info> " );
83+ $ output ->writeln ("<info>a users trashbin can exceed the configured size until they move a new file to the trashbin.</info> " );
84+
8285 return self ::SUCCESS ;
8386 }
8487
@@ -101,40 +104,45 @@ private function printTrashbinSize(InputInterface $input, OutputInterface $outpu
101104
102105 if ($ input ->getOption ('output ' ) == self ::OUTPUT_FORMAT_PLAIN ) {
103106 $ output ->writeln ($ userHumanSize );
104- } else {
105- $ userValue = ($ userSize < 0 ) ? 'default ' : $ userSize ;
106- $ globalValue = ($ globalSize < 0 ) ? 'default ' : $ globalSize ;
107- $ this ->writeArrayInOutputFormat ($ input , $ output , [
108- 'user_size ' => $ userValue ,
109- 'global_size ' => $ globalValue ,
110- 'effective_size ' => ($ userSize < 0 ) ? $ globalValue : $ userValue ,
111- ]);
107+ return ;
112108 }
113- } else {
114- $ users = [];
115- $ this ->userManager ->callForSeenUsers (function (IUser $ user ) use (&$ users ) {
116- $ users [] = $ user ->getUID ();
117- });
118- $ userValues = $ this ->config ->getUserValueForUsers ('files_trashbin ' , 'trashbin_size ' , $ users );
119109
120- if ($ input ->getOption ('output ' ) == self ::OUTPUT_FORMAT_PLAIN ) {
121- $ output ->writeln ("Default size: $ globalHumanSize " );
122- $ output ->writeln ("" );
123- if (count ($ userValues )) {
124- $ output ->writeln ("Per-user sizes: " );
125- $ this ->writeArrayInOutputFormat ($ input , $ output , array_map (function ($ size ) {
126- return \OC_Helper::humanFileSize ($ size );
127- }, $ userValues ));
128- } else {
129- $ output ->writeln ("No per-user sizes configured " );
130- }
131- } else {
132- $ globalValue = ($ globalSize < 0 ) ? 'default ' : $ globalSize ;
133- $ this ->writeArrayInOutputFormat ($ input , $ output , [
134- 'global_size ' => $ globalValue ,
135- 'user_sizes ' => $ userValues ,
136- ]);
110+ $ userValue = ($ userSize < 0 ) ? 'default ' : $ userSize ;
111+ $ globalValue = ($ globalSize < 0 ) ? 'default ' : $ globalSize ;
112+ $ this ->writeArrayInOutputFormat ($ input , $ output , [
113+ 'user_size ' => $ userValue ,
114+ 'global_size ' => $ globalValue ,
115+ 'effective_size ' => ($ userSize < 0 ) ? $ globalValue : $ userValue ,
116+ ]);
117+ return ;
118+ }
119+
120+ $ users = [];
121+ $ this ->userManager ->callForSeenUsers (function (IUser $ user ) use (&$ users ) {
122+ $ users [] = $ user ->getUID ();
123+ });
124+ $ userValues = $ this ->config ->getUserValueForUsers ('files_trashbin ' , 'trashbin_size ' , $ users );
125+
126+ if ($ input ->getOption ('output ' ) == self ::OUTPUT_FORMAT_PLAIN ) {
127+ $ output ->writeln ("Default size: $ globalHumanSize " );
128+ $ output ->writeln ("" );
129+
130+ if (!count ($ userValues )) {
131+ $ output ->writeln ("No per-user sizes configured " );
132+ return ;
137133 }
134+
135+ $ output ->writeln ("Per-user sizes: " );
136+ $ this ->writeArrayInOutputFormat ($ input , $ output , array_map (function ($ size ) {
137+ return \OC_Helper::humanFileSize ($ size );
138+ }, $ userValues ));
139+ return ;
138140 }
141+
142+ $ globalValue = ($ globalSize < 0 ) ? 'default ' : $ globalSize ;
143+ $ this ->writeArrayInOutputFormat ($ input , $ output , [
144+ 'global_size ' => $ globalValue ,
145+ 'user_sizes ' => $ userValues ,
146+ ]);
139147 }
140148}
0 commit comments