@@ -113,136 +113,136 @@ |
||
113 | 113 | $config = Server::get(IConfig::class); |
114 | 114 | |
115 | 115 | if ($config->getSystemValueBool('installed', false)) { |
116 | - $application->add(Server::get(Disable::class)); |
|
117 | - $application->add(Server::get(Enable::class)); |
|
118 | - $application->add(Server::get(Install::class)); |
|
119 | - $application->add(Server::get(GetPath::class)); |
|
120 | - $application->add(Server::get(ListApps::class)); |
|
121 | - $application->add(Server::get(Remove::class)); |
|
122 | - $application->add(Server::get(Update::class)); |
|
123 | - |
|
124 | - $application->add(Server::get(Cleanup::class)); |
|
125 | - $application->add(Server::get(Enforce::class)); |
|
126 | - $application->add(Server::get(Command\TwoFactorAuth\Enable::class)); |
|
127 | - $application->add(Server::get(Command\TwoFactorAuth\Disable::class)); |
|
128 | - $application->add(Server::get(State::class)); |
|
129 | - |
|
130 | - $application->add(Server::get(Mode::class)); |
|
131 | - $application->add(Server::get(Job::class)); |
|
132 | - $application->add(Server::get(ListCommand::class)); |
|
133 | - $application->add(Server::get(Delete::class)); |
|
134 | - $application->add(Server::get(JobWorker::class)); |
|
135 | - |
|
136 | - $application->add(Server::get(Test::class)); |
|
137 | - |
|
138 | - $application->add(Server::get(DeleteConfig::class)); |
|
139 | - $application->add(Server::get(GetConfig::class)); |
|
140 | - $application->add(Server::get(SetConfig::class)); |
|
141 | - $application->add(Server::get(Import::class)); |
|
142 | - $application->add(Server::get(ListConfigs::class)); |
|
143 | - $application->add(Server::get(Command\Config\System\DeleteConfig::class)); |
|
144 | - $application->add(Server::get(Command\Config\System\GetConfig::class)); |
|
145 | - $application->add(Server::get(Command\Config\System\SetConfig::class)); |
|
146 | - |
|
147 | - $application->add(Server::get(File::class)); |
|
148 | - $application->add(Server::get(Space::class)); |
|
149 | - $application->add(Server::get(Storage::class)); |
|
150 | - $application->add(Server::get(Storages::class)); |
|
151 | - |
|
152 | - $application->add(Server::get(ConvertType::class)); |
|
153 | - $application->add(Server::get(ConvertMysqlToMB4::class)); |
|
154 | - $application->add(Server::get(ConvertFilecacheBigInt::class)); |
|
155 | - $application->add(Server::get(AddMissingColumns::class)); |
|
156 | - $application->add(Server::get(AddMissingIndices::class)); |
|
157 | - $application->add(Server::get(AddMissingPrimaryKeys::class)); |
|
158 | - $application->add(Server::get(ExpectedSchema::class)); |
|
159 | - $application->add(Server::get(ExportSchema::class)); |
|
160 | - |
|
161 | - $application->add(Server::get(GenerateMetadataCommand::class)); |
|
162 | - $application->add(Server::get(PreviewCommand::class)); |
|
163 | - if ($config->getSystemValueBool('debug', false)) { |
|
164 | - $application->add(Server::get(StatusCommand::class)); |
|
165 | - $application->add(Server::get(MigrateCommand::class)); |
|
166 | - $application->add(Server::get(GenerateCommand::class)); |
|
167 | - $application->add(Server::get(ExecuteCommand::class)); |
|
168 | - } |
|
169 | - |
|
170 | - $application->add(Server::get(Command\Encryption\Disable::class)); |
|
171 | - $application->add(Server::get(Command\Encryption\Enable::class)); |
|
172 | - $application->add(Server::get(ListModules::class)); |
|
173 | - $application->add(Server::get(SetDefaultModule::class)); |
|
174 | - $application->add(Server::get(Command\Encryption\Status::class)); |
|
175 | - $application->add(Server::get(EncryptAll::class)); |
|
176 | - $application->add(Server::get(DecryptAll::class)); |
|
177 | - |
|
178 | - $application->add(Server::get(Manage::class)); |
|
179 | - $application->add(Server::get(Command\Log\File::class)); |
|
180 | - |
|
181 | - $application->add(Server::get(ChangeKeyStorageRoot::class)); |
|
182 | - $application->add(Server::get(ShowKeyStorageRoot::class)); |
|
183 | - $application->add(Server::get(MigrateKeyStorage::class)); |
|
184 | - |
|
185 | - $application->add(Server::get(DataFingerprint::class)); |
|
186 | - $application->add(Server::get(UpdateDB::class)); |
|
187 | - $application->add(Server::get(UpdateJS::class)); |
|
188 | - $application->add(Server::get(Command\Maintenance\Mode::class)); |
|
189 | - $application->add(Server::get(UpdateHtaccess::class)); |
|
190 | - $application->add(Server::get(UpdateTheme::class)); |
|
191 | - |
|
192 | - $application->add(Server::get(Upgrade::class)); |
|
193 | - $application->add(Server::get(Repair::class)); |
|
194 | - $application->add(Server::get(RepairShareOwnership::class)); |
|
195 | - |
|
196 | - $application->add(Server::get(Command\Preview\Cleanup::class)); |
|
197 | - $application->add(Server::get(Generate::class)); |
|
198 | - $application->add(Server::get(Command\Preview\Repair::class)); |
|
199 | - $application->add(Server::get(ResetRenderedTexts::class)); |
|
200 | - |
|
201 | - $application->add(Server::get(Add::class)); |
|
202 | - $application->add(Server::get(Command\User\Delete::class)); |
|
203 | - $application->add(Server::get(Command\User\Disable::class)); |
|
204 | - $application->add(Server::get(Command\User\Enable::class)); |
|
205 | - $application->add(Server::get(LastSeen::class)); |
|
206 | - $application->add(Server::get(Report::class)); |
|
207 | - $application->add(Server::get(ResetPassword::class)); |
|
208 | - $application->add(Server::get(Setting::class)); |
|
209 | - $application->add(Server::get(Command\User\ListCommand::class)); |
|
210 | - $application->add(Server::get(ClearGeneratedAvatarCacheCommand::class)); |
|
211 | - $application->add(Server::get(Info::class)); |
|
212 | - $application->add(Server::get(SyncAccountDataCommand::class)); |
|
213 | - $application->add(Server::get(Command\User\AuthTokens\Add::class)); |
|
214 | - $application->add(Server::get(Command\User\AuthTokens\ListCommand::class)); |
|
215 | - $application->add(Server::get(Command\User\AuthTokens\Delete::class)); |
|
216 | - $application->add(Server::get(Verify::class)); |
|
217 | - $application->add(Server::get(Welcome::class)); |
|
218 | - |
|
219 | - $application->add(Server::get(Command\Group\Add::class)); |
|
220 | - $application->add(Server::get(Command\Group\Delete::class)); |
|
221 | - $application->add(Server::get(Command\Group\ListCommand::class)); |
|
222 | - $application->add(Server::get(AddUser::class)); |
|
223 | - $application->add(Server::get(RemoveUser::class)); |
|
224 | - $application->add(Server::get(Command\Group\Info::class)); |
|
225 | - |
|
226 | - $application->add(Server::get(Command\SystemTag\ListCommand::class)); |
|
227 | - $application->add(Server::get(Command\SystemTag\Delete::class)); |
|
228 | - $application->add(Server::get(Command\SystemTag\Add::class)); |
|
229 | - $application->add(Server::get(Edit::class)); |
|
230 | - |
|
231 | - $application->add(Server::get(ListCertificates::class)); |
|
232 | - $application->add(Server::get(ExportCertificates::class)); |
|
233 | - $application->add(Server::get(ImportCertificate::class)); |
|
234 | - $application->add(Server::get(RemoveCertificate::class)); |
|
235 | - $application->add(Server::get(BruteforceAttempts::class)); |
|
236 | - $application->add(Server::get(BruteforceResetAttempts::class)); |
|
237 | - $application->add(Server::get(SetupChecks::class)); |
|
238 | - $application->add(Server::get(Get::class)); |
|
239 | - |
|
240 | - $application->add(Server::get(GetCommand::class)); |
|
241 | - $application->add(Server::get(EnabledCommand::class)); |
|
242 | - $application->add(Server::get(Command\TaskProcessing\ListCommand::class)); |
|
243 | - $application->add(Server::get(Statistics::class)); |
|
244 | - |
|
245 | - $application->add(Server::get(RedisCommand::class)); |
|
116 | + $application->add(Server::get(Disable::class)); |
|
117 | + $application->add(Server::get(Enable::class)); |
|
118 | + $application->add(Server::get(Install::class)); |
|
119 | + $application->add(Server::get(GetPath::class)); |
|
120 | + $application->add(Server::get(ListApps::class)); |
|
121 | + $application->add(Server::get(Remove::class)); |
|
122 | + $application->add(Server::get(Update::class)); |
|
123 | + |
|
124 | + $application->add(Server::get(Cleanup::class)); |
|
125 | + $application->add(Server::get(Enforce::class)); |
|
126 | + $application->add(Server::get(Command\TwoFactorAuth\Enable::class)); |
|
127 | + $application->add(Server::get(Command\TwoFactorAuth\Disable::class)); |
|
128 | + $application->add(Server::get(State::class)); |
|
129 | + |
|
130 | + $application->add(Server::get(Mode::class)); |
|
131 | + $application->add(Server::get(Job::class)); |
|
132 | + $application->add(Server::get(ListCommand::class)); |
|
133 | + $application->add(Server::get(Delete::class)); |
|
134 | + $application->add(Server::get(JobWorker::class)); |
|
135 | + |
|
136 | + $application->add(Server::get(Test::class)); |
|
137 | + |
|
138 | + $application->add(Server::get(DeleteConfig::class)); |
|
139 | + $application->add(Server::get(GetConfig::class)); |
|
140 | + $application->add(Server::get(SetConfig::class)); |
|
141 | + $application->add(Server::get(Import::class)); |
|
142 | + $application->add(Server::get(ListConfigs::class)); |
|
143 | + $application->add(Server::get(Command\Config\System\DeleteConfig::class)); |
|
144 | + $application->add(Server::get(Command\Config\System\GetConfig::class)); |
|
145 | + $application->add(Server::get(Command\Config\System\SetConfig::class)); |
|
146 | + |
|
147 | + $application->add(Server::get(File::class)); |
|
148 | + $application->add(Server::get(Space::class)); |
|
149 | + $application->add(Server::get(Storage::class)); |
|
150 | + $application->add(Server::get(Storages::class)); |
|
151 | + |
|
152 | + $application->add(Server::get(ConvertType::class)); |
|
153 | + $application->add(Server::get(ConvertMysqlToMB4::class)); |
|
154 | + $application->add(Server::get(ConvertFilecacheBigInt::class)); |
|
155 | + $application->add(Server::get(AddMissingColumns::class)); |
|
156 | + $application->add(Server::get(AddMissingIndices::class)); |
|
157 | + $application->add(Server::get(AddMissingPrimaryKeys::class)); |
|
158 | + $application->add(Server::get(ExpectedSchema::class)); |
|
159 | + $application->add(Server::get(ExportSchema::class)); |
|
160 | + |
|
161 | + $application->add(Server::get(GenerateMetadataCommand::class)); |
|
162 | + $application->add(Server::get(PreviewCommand::class)); |
|
163 | + if ($config->getSystemValueBool('debug', false)) { |
|
164 | + $application->add(Server::get(StatusCommand::class)); |
|
165 | + $application->add(Server::get(MigrateCommand::class)); |
|
166 | + $application->add(Server::get(GenerateCommand::class)); |
|
167 | + $application->add(Server::get(ExecuteCommand::class)); |
|
168 | + } |
|
169 | + |
|
170 | + $application->add(Server::get(Command\Encryption\Disable::class)); |
|
171 | + $application->add(Server::get(Command\Encryption\Enable::class)); |
|
172 | + $application->add(Server::get(ListModules::class)); |
|
173 | + $application->add(Server::get(SetDefaultModule::class)); |
|
174 | + $application->add(Server::get(Command\Encryption\Status::class)); |
|
175 | + $application->add(Server::get(EncryptAll::class)); |
|
176 | + $application->add(Server::get(DecryptAll::class)); |
|
177 | + |
|
178 | + $application->add(Server::get(Manage::class)); |
|
179 | + $application->add(Server::get(Command\Log\File::class)); |
|
180 | + |
|
181 | + $application->add(Server::get(ChangeKeyStorageRoot::class)); |
|
182 | + $application->add(Server::get(ShowKeyStorageRoot::class)); |
|
183 | + $application->add(Server::get(MigrateKeyStorage::class)); |
|
184 | + |
|
185 | + $application->add(Server::get(DataFingerprint::class)); |
|
186 | + $application->add(Server::get(UpdateDB::class)); |
|
187 | + $application->add(Server::get(UpdateJS::class)); |
|
188 | + $application->add(Server::get(Command\Maintenance\Mode::class)); |
|
189 | + $application->add(Server::get(UpdateHtaccess::class)); |
|
190 | + $application->add(Server::get(UpdateTheme::class)); |
|
191 | + |
|
192 | + $application->add(Server::get(Upgrade::class)); |
|
193 | + $application->add(Server::get(Repair::class)); |
|
194 | + $application->add(Server::get(RepairShareOwnership::class)); |
|
195 | + |
|
196 | + $application->add(Server::get(Command\Preview\Cleanup::class)); |
|
197 | + $application->add(Server::get(Generate::class)); |
|
198 | + $application->add(Server::get(Command\Preview\Repair::class)); |
|
199 | + $application->add(Server::get(ResetRenderedTexts::class)); |
|
200 | + |
|
201 | + $application->add(Server::get(Add::class)); |
|
202 | + $application->add(Server::get(Command\User\Delete::class)); |
|
203 | + $application->add(Server::get(Command\User\Disable::class)); |
|
204 | + $application->add(Server::get(Command\User\Enable::class)); |
|
205 | + $application->add(Server::get(LastSeen::class)); |
|
206 | + $application->add(Server::get(Report::class)); |
|
207 | + $application->add(Server::get(ResetPassword::class)); |
|
208 | + $application->add(Server::get(Setting::class)); |
|
209 | + $application->add(Server::get(Command\User\ListCommand::class)); |
|
210 | + $application->add(Server::get(ClearGeneratedAvatarCacheCommand::class)); |
|
211 | + $application->add(Server::get(Info::class)); |
|
212 | + $application->add(Server::get(SyncAccountDataCommand::class)); |
|
213 | + $application->add(Server::get(Command\User\AuthTokens\Add::class)); |
|
214 | + $application->add(Server::get(Command\User\AuthTokens\ListCommand::class)); |
|
215 | + $application->add(Server::get(Command\User\AuthTokens\Delete::class)); |
|
216 | + $application->add(Server::get(Verify::class)); |
|
217 | + $application->add(Server::get(Welcome::class)); |
|
218 | + |
|
219 | + $application->add(Server::get(Command\Group\Add::class)); |
|
220 | + $application->add(Server::get(Command\Group\Delete::class)); |
|
221 | + $application->add(Server::get(Command\Group\ListCommand::class)); |
|
222 | + $application->add(Server::get(AddUser::class)); |
|
223 | + $application->add(Server::get(RemoveUser::class)); |
|
224 | + $application->add(Server::get(Command\Group\Info::class)); |
|
225 | + |
|
226 | + $application->add(Server::get(Command\SystemTag\ListCommand::class)); |
|
227 | + $application->add(Server::get(Command\SystemTag\Delete::class)); |
|
228 | + $application->add(Server::get(Command\SystemTag\Add::class)); |
|
229 | + $application->add(Server::get(Edit::class)); |
|
230 | + |
|
231 | + $application->add(Server::get(ListCertificates::class)); |
|
232 | + $application->add(Server::get(ExportCertificates::class)); |
|
233 | + $application->add(Server::get(ImportCertificate::class)); |
|
234 | + $application->add(Server::get(RemoveCertificate::class)); |
|
235 | + $application->add(Server::get(BruteforceAttempts::class)); |
|
236 | + $application->add(Server::get(BruteforceResetAttempts::class)); |
|
237 | + $application->add(Server::get(SetupChecks::class)); |
|
238 | + $application->add(Server::get(Get::class)); |
|
239 | + |
|
240 | + $application->add(Server::get(GetCommand::class)); |
|
241 | + $application->add(Server::get(EnabledCommand::class)); |
|
242 | + $application->add(Server::get(Command\TaskProcessing\ListCommand::class)); |
|
243 | + $application->add(Server::get(Statistics::class)); |
|
244 | + |
|
245 | + $application->add(Server::get(RedisCommand::class)); |
|
246 | 246 | } else { |
247 | - $application->add(Server::get(Command\Maintenance\Install::class)); |
|
247 | + $application->add(Server::get(Command\Maintenance\Install::class)); |
|
248 | 248 | } |
@@ -15,35 +15,35 @@ |
||
15 | 15 | use Symfony\Component\Console\Output\OutputInterface; |
16 | 16 | |
17 | 17 | class Storage extends Base { |
18 | - public function __construct( |
|
19 | - private readonly IDBConnection $connection, |
|
20 | - private readonly FileUtils $fileUtils, |
|
21 | - ) { |
|
22 | - parent::__construct(); |
|
23 | - } |
|
18 | + public function __construct( |
|
19 | + private readonly IDBConnection $connection, |
|
20 | + private readonly FileUtils $fileUtils, |
|
21 | + ) { |
|
22 | + parent::__construct(); |
|
23 | + } |
|
24 | 24 | |
25 | - protected function configure(): void { |
|
26 | - parent::configure(); |
|
27 | - $this |
|
28 | - ->setName('info:storage') |
|
29 | - ->setDescription('Get information a single storage') |
|
30 | - ->addArgument('storage', InputArgument::REQUIRED, 'Storage to get information for'); |
|
31 | - } |
|
25 | + protected function configure(): void { |
|
26 | + parent::configure(); |
|
27 | + $this |
|
28 | + ->setName('info:storage') |
|
29 | + ->setDescription('Get information a single storage') |
|
30 | + ->addArgument('storage', InputArgument::REQUIRED, 'Storage to get information for'); |
|
31 | + } |
|
32 | 32 | |
33 | - public function execute(InputInterface $input, OutputInterface $output): int { |
|
34 | - $storage = $input->getArgument('storage'); |
|
35 | - $storageId = $this->fileUtils->getNumericStorageId($storage); |
|
36 | - if (!$storageId) { |
|
37 | - $output->writeln('<error>No storage with id ' . $storage . ' found</error>'); |
|
38 | - return 1; |
|
39 | - } |
|
33 | + public function execute(InputInterface $input, OutputInterface $output): int { |
|
34 | + $storage = $input->getArgument('storage'); |
|
35 | + $storageId = $this->fileUtils->getNumericStorageId($storage); |
|
36 | + if (!$storageId) { |
|
37 | + $output->writeln('<error>No storage with id ' . $storage . ' found</error>'); |
|
38 | + return 1; |
|
39 | + } |
|
40 | 40 | |
41 | - $info = $this->fileUtils->getStorage($storageId); |
|
42 | - if (!$info) { |
|
43 | - $output->writeln('<error>No storage with id ' . $storage . ' found</error>'); |
|
44 | - return 1; |
|
45 | - } |
|
46 | - $this->writeArrayInOutputFormat($input, $output, $this->fileUtils->formatStorage($info)); |
|
47 | - return 0; |
|
48 | - } |
|
41 | + $info = $this->fileUtils->getStorage($storageId); |
|
42 | + if (!$info) { |
|
43 | + $output->writeln('<error>No storage with id ' . $storage . ' found</error>'); |
|
44 | + return 1; |
|
45 | + } |
|
46 | + $this->writeArrayInOutputFormat($input, $output, $this->fileUtils->formatStorage($info)); |
|
47 | + return 0; |
|
48 | + } |
|
49 | 49 | } |
@@ -15,29 +15,29 @@ |
||
15 | 15 | use Symfony\Component\Console\Output\OutputInterface; |
16 | 16 | |
17 | 17 | class Storages extends Base { |
18 | - public function __construct( |
|
19 | - private readonly IDBConnection $connection, |
|
20 | - private readonly FileUtils $fileUtils, |
|
21 | - ) { |
|
22 | - parent::__construct(); |
|
23 | - } |
|
18 | + public function __construct( |
|
19 | + private readonly IDBConnection $connection, |
|
20 | + private readonly FileUtils $fileUtils, |
|
21 | + ) { |
|
22 | + parent::__construct(); |
|
23 | + } |
|
24 | 24 | |
25 | - protected function configure(): void { |
|
26 | - parent::configure(); |
|
27 | - $this |
|
28 | - ->setName('info:storages') |
|
29 | - ->setDescription('List storages ordered by the number of files') |
|
30 | - ->addOption('count', 'c', InputOption::VALUE_REQUIRED, 'Number of storages to display', 25) |
|
31 | - ->addOption('all', 'a', InputOption::VALUE_NONE, 'Display all storages'); |
|
32 | - } |
|
25 | + protected function configure(): void { |
|
26 | + parent::configure(); |
|
27 | + $this |
|
28 | + ->setName('info:storages') |
|
29 | + ->setDescription('List storages ordered by the number of files') |
|
30 | + ->addOption('count', 'c', InputOption::VALUE_REQUIRED, 'Number of storages to display', 25) |
|
31 | + ->addOption('all', 'a', InputOption::VALUE_NONE, 'Display all storages'); |
|
32 | + } |
|
33 | 33 | |
34 | - public function execute(InputInterface $input, OutputInterface $output): int { |
|
35 | - $count = (int)$input->getOption('count'); |
|
36 | - $all = $input->getOption('all'); |
|
34 | + public function execute(InputInterface $input, OutputInterface $output): int { |
|
35 | + $count = (int)$input->getOption('count'); |
|
36 | + $all = $input->getOption('all'); |
|
37 | 37 | |
38 | - $limit = $all ? null : $count; |
|
39 | - $storages = $this->fileUtils->listStorages($limit); |
|
40 | - $this->writeStreamingTableInOutputFormat($input, $output, $this->fileUtils->formatStorages($storages), 100); |
|
41 | - return 0; |
|
42 | - } |
|
38 | + $limit = $all ? null : $count; |
|
39 | + $storages = $this->fileUtils->listStorages($limit); |
|
40 | + $this->writeStreamingTableInOutputFormat($input, $output, $this->fileUtils->formatStorages($storages), 100); |
|
41 | + return 0; |
|
42 | + } |
|
43 | 43 | } |
@@ -33,293 +33,293 @@ |
||
33 | 33 | * @psalm-type StorageInfo array{numeric_id: int, id: string, available: bool, last_checked: ?\DateTime, files: int, mount_id: ?int} |
34 | 34 | */ |
35 | 35 | class FileUtils { |
36 | - public function __construct( |
|
37 | - private IRootFolder $rootFolder, |
|
38 | - private IUserMountCache $userMountCache, |
|
39 | - private IDBConnection $connection, |
|
40 | - ) { |
|
41 | - } |
|
36 | + public function __construct( |
|
37 | + private IRootFolder $rootFolder, |
|
38 | + private IUserMountCache $userMountCache, |
|
39 | + private IDBConnection $connection, |
|
40 | + ) { |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param FileInfo $file |
|
45 | - * @return array<string, Node[]> |
|
46 | - * @throws NotPermittedException |
|
47 | - * @throws NoUserException |
|
48 | - */ |
|
49 | - public function getFilesByUser(FileInfo $file): array { |
|
50 | - $id = $file->getId(); |
|
51 | - if (!$id) { |
|
52 | - return []; |
|
53 | - } |
|
43 | + /** |
|
44 | + * @param FileInfo $file |
|
45 | + * @return array<string, Node[]> |
|
46 | + * @throws NotPermittedException |
|
47 | + * @throws NoUserException |
|
48 | + */ |
|
49 | + public function getFilesByUser(FileInfo $file): array { |
|
50 | + $id = $file->getId(); |
|
51 | + if (!$id) { |
|
52 | + return []; |
|
53 | + } |
|
54 | 54 | |
55 | - $mounts = $this->userMountCache->getMountsForFileId($id); |
|
56 | - $result = []; |
|
57 | - foreach ($mounts as $cachedMount) { |
|
58 | - $mount = $this->rootFolder->getMount($cachedMount->getMountPoint()); |
|
59 | - $cache = $mount->getStorage()->getCache(); |
|
60 | - $cacheEntry = $cache->get($id); |
|
61 | - $node = $this->rootFolder->getNodeFromCacheEntryAndMount($cacheEntry, $mount); |
|
62 | - $result[$cachedMount->getUser()->getUID()][] = $node; |
|
63 | - } |
|
55 | + $mounts = $this->userMountCache->getMountsForFileId($id); |
|
56 | + $result = []; |
|
57 | + foreach ($mounts as $cachedMount) { |
|
58 | + $mount = $this->rootFolder->getMount($cachedMount->getMountPoint()); |
|
59 | + $cache = $mount->getStorage()->getCache(); |
|
60 | + $cacheEntry = $cache->get($id); |
|
61 | + $node = $this->rootFolder->getNodeFromCacheEntryAndMount($cacheEntry, $mount); |
|
62 | + $result[$cachedMount->getUser()->getUID()][] = $node; |
|
63 | + } |
|
64 | 64 | |
65 | - return $result; |
|
66 | - } |
|
65 | + return $result; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * Get file by either id of path |
|
70 | - * |
|
71 | - * @param string $fileInput |
|
72 | - * @return Node|null |
|
73 | - */ |
|
74 | - public function getNode(string $fileInput): ?Node { |
|
75 | - if (is_numeric($fileInput)) { |
|
76 | - $mounts = $this->userMountCache->getMountsForFileId((int)$fileInput); |
|
77 | - if (!$mounts) { |
|
78 | - return null; |
|
79 | - } |
|
80 | - $mount = reset($mounts); |
|
81 | - $userFolder = $this->rootFolder->getUserFolder($mount->getUser()->getUID()); |
|
82 | - return $userFolder->getFirstNodeById((int)$fileInput); |
|
83 | - } else { |
|
84 | - try { |
|
85 | - return $this->rootFolder->get($fileInput); |
|
86 | - } catch (NotFoundException $e) { |
|
87 | - return null; |
|
88 | - } |
|
89 | - } |
|
90 | - } |
|
68 | + /** |
|
69 | + * Get file by either id of path |
|
70 | + * |
|
71 | + * @param string $fileInput |
|
72 | + * @return Node|null |
|
73 | + */ |
|
74 | + public function getNode(string $fileInput): ?Node { |
|
75 | + if (is_numeric($fileInput)) { |
|
76 | + $mounts = $this->userMountCache->getMountsForFileId((int)$fileInput); |
|
77 | + if (!$mounts) { |
|
78 | + return null; |
|
79 | + } |
|
80 | + $mount = reset($mounts); |
|
81 | + $userFolder = $this->rootFolder->getUserFolder($mount->getUser()->getUID()); |
|
82 | + return $userFolder->getFirstNodeById((int)$fileInput); |
|
83 | + } else { |
|
84 | + try { |
|
85 | + return $this->rootFolder->get($fileInput); |
|
86 | + } catch (NotFoundException $e) { |
|
87 | + return null; |
|
88 | + } |
|
89 | + } |
|
90 | + } |
|
91 | 91 | |
92 | - public function formatPermissions(string $type, int $permissions): string { |
|
93 | - if ($permissions == Constants::PERMISSION_ALL || ($type === 'file' && $permissions == (Constants::PERMISSION_ALL - Constants::PERMISSION_CREATE))) { |
|
94 | - return 'full permissions'; |
|
95 | - } |
|
92 | + public function formatPermissions(string $type, int $permissions): string { |
|
93 | + if ($permissions == Constants::PERMISSION_ALL || ($type === 'file' && $permissions == (Constants::PERMISSION_ALL - Constants::PERMISSION_CREATE))) { |
|
94 | + return 'full permissions'; |
|
95 | + } |
|
96 | 96 | |
97 | - $perms = []; |
|
98 | - $allPerms = [Constants::PERMISSION_READ => 'read', Constants::PERMISSION_UPDATE => 'update', Constants::PERMISSION_CREATE => 'create', Constants::PERMISSION_DELETE => 'delete', Constants::PERMISSION_SHARE => 'share']; |
|
99 | - foreach ($allPerms as $perm => $name) { |
|
100 | - if (($permissions & $perm) === $perm) { |
|
101 | - $perms[] = $name; |
|
102 | - } |
|
103 | - } |
|
97 | + $perms = []; |
|
98 | + $allPerms = [Constants::PERMISSION_READ => 'read', Constants::PERMISSION_UPDATE => 'update', Constants::PERMISSION_CREATE => 'create', Constants::PERMISSION_DELETE => 'delete', Constants::PERMISSION_SHARE => 'share']; |
|
99 | + foreach ($allPerms as $perm => $name) { |
|
100 | + if (($permissions & $perm) === $perm) { |
|
101 | + $perms[] = $name; |
|
102 | + } |
|
103 | + } |
|
104 | 104 | |
105 | - return implode(', ', $perms); |
|
106 | - } |
|
105 | + return implode(', ', $perms); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * @psalm-suppress UndefinedClass |
|
110 | - * @psalm-suppress UndefinedInterfaceMethod |
|
111 | - */ |
|
112 | - public function formatMountType(IMountPoint $mountPoint): string { |
|
113 | - $storage = $mountPoint->getStorage(); |
|
114 | - if ($storage && $storage->instanceOfStorage(IHomeStorage::class)) { |
|
115 | - return 'home storage'; |
|
116 | - } elseif ($mountPoint instanceof SharedMount) { |
|
117 | - $share = $mountPoint->getShare(); |
|
118 | - $shares = $mountPoint->getGroupedShares(); |
|
119 | - $sharedBy = array_map(function (IShare $share) { |
|
120 | - $shareType = $this->formatShareType($share); |
|
121 | - if ($shareType) { |
|
122 | - return $share->getSharedBy() . ' (via ' . $shareType . ' ' . $share->getSharedWith() . ')'; |
|
123 | - } else { |
|
124 | - return $share->getSharedBy(); |
|
125 | - } |
|
126 | - }, $shares); |
|
127 | - $description = 'shared by ' . implode(', ', $sharedBy); |
|
128 | - if ($share->getSharedBy() !== $share->getShareOwner()) { |
|
129 | - $description .= ' owned by ' . $share->getShareOwner(); |
|
130 | - } |
|
131 | - return $description; |
|
132 | - } elseif ($mountPoint instanceof GroupMountPoint) { |
|
133 | - return 'groupfolder ' . $mountPoint->getFolderId(); |
|
134 | - } elseif ($mountPoint instanceof ExternalMountPoint) { |
|
135 | - return 'external storage ' . $mountPoint->getStorageConfig()->getId(); |
|
136 | - } elseif ($mountPoint instanceof CircleMount) { |
|
137 | - return 'circle'; |
|
138 | - } |
|
139 | - return get_class($mountPoint); |
|
140 | - } |
|
108 | + /** |
|
109 | + * @psalm-suppress UndefinedClass |
|
110 | + * @psalm-suppress UndefinedInterfaceMethod |
|
111 | + */ |
|
112 | + public function formatMountType(IMountPoint $mountPoint): string { |
|
113 | + $storage = $mountPoint->getStorage(); |
|
114 | + if ($storage && $storage->instanceOfStorage(IHomeStorage::class)) { |
|
115 | + return 'home storage'; |
|
116 | + } elseif ($mountPoint instanceof SharedMount) { |
|
117 | + $share = $mountPoint->getShare(); |
|
118 | + $shares = $mountPoint->getGroupedShares(); |
|
119 | + $sharedBy = array_map(function (IShare $share) { |
|
120 | + $shareType = $this->formatShareType($share); |
|
121 | + if ($shareType) { |
|
122 | + return $share->getSharedBy() . ' (via ' . $shareType . ' ' . $share->getSharedWith() . ')'; |
|
123 | + } else { |
|
124 | + return $share->getSharedBy(); |
|
125 | + } |
|
126 | + }, $shares); |
|
127 | + $description = 'shared by ' . implode(', ', $sharedBy); |
|
128 | + if ($share->getSharedBy() !== $share->getShareOwner()) { |
|
129 | + $description .= ' owned by ' . $share->getShareOwner(); |
|
130 | + } |
|
131 | + return $description; |
|
132 | + } elseif ($mountPoint instanceof GroupMountPoint) { |
|
133 | + return 'groupfolder ' . $mountPoint->getFolderId(); |
|
134 | + } elseif ($mountPoint instanceof ExternalMountPoint) { |
|
135 | + return 'external storage ' . $mountPoint->getStorageConfig()->getId(); |
|
136 | + } elseif ($mountPoint instanceof CircleMount) { |
|
137 | + return 'circle'; |
|
138 | + } |
|
139 | + return get_class($mountPoint); |
|
140 | + } |
|
141 | 141 | |
142 | - public function formatShareType(IShare $share): ?string { |
|
143 | - switch ($share->getShareType()) { |
|
144 | - case IShare::TYPE_GROUP: |
|
145 | - return 'group'; |
|
146 | - case IShare::TYPE_CIRCLE: |
|
147 | - return 'circle'; |
|
148 | - case IShare::TYPE_DECK: |
|
149 | - return 'deck'; |
|
150 | - case IShare::TYPE_ROOM: |
|
151 | - return 'room'; |
|
152 | - case IShare::TYPE_USER: |
|
153 | - return null; |
|
154 | - default: |
|
155 | - return 'Unknown (' . $share->getShareType() . ')'; |
|
156 | - } |
|
157 | - } |
|
142 | + public function formatShareType(IShare $share): ?string { |
|
143 | + switch ($share->getShareType()) { |
|
144 | + case IShare::TYPE_GROUP: |
|
145 | + return 'group'; |
|
146 | + case IShare::TYPE_CIRCLE: |
|
147 | + return 'circle'; |
|
148 | + case IShare::TYPE_DECK: |
|
149 | + return 'deck'; |
|
150 | + case IShare::TYPE_ROOM: |
|
151 | + return 'room'; |
|
152 | + case IShare::TYPE_USER: |
|
153 | + return null; |
|
154 | + default: |
|
155 | + return 'Unknown (' . $share->getShareType() . ')'; |
|
156 | + } |
|
157 | + } |
|
158 | 158 | |
159 | - /** |
|
160 | - * Print out the largest count($sizeLimits) files in the directory tree |
|
161 | - * |
|
162 | - * @param OutputInterface $output |
|
163 | - * @param Folder $node |
|
164 | - * @param string $prefix |
|
165 | - * @param array $sizeLimits largest items that are still in the queue to be printed, ordered ascending |
|
166 | - * @return int how many items we've printed |
|
167 | - */ |
|
168 | - public function outputLargeFilesTree( |
|
169 | - OutputInterface $output, |
|
170 | - Folder $node, |
|
171 | - string $prefix, |
|
172 | - array &$sizeLimits, |
|
173 | - bool $all, |
|
174 | - ): int { |
|
175 | - /** |
|
176 | - * Algorithm to print the N largest items in a folder without requiring to query or sort the entire three |
|
177 | - * |
|
178 | - * This is done by keeping a list ($sizeLimits) of size N that contain the largest items outside of this |
|
179 | - * folders that are could be printed if there aren't enough items in this folder that are larger. |
|
180 | - * |
|
181 | - * We loop over the items in this folder by size descending until the size of the item falls before the smallest |
|
182 | - * size in $sizeLimits (at that point there are enough items outside this folder to complete the N items). |
|
183 | - * |
|
184 | - * When encountering a folder, we create an updated $sizeLimits with the largest items in the current folder still |
|
185 | - * remaining which we pass into the recursion. (We don't update the current $sizeLimits because that should only |
|
186 | - * hold items *outside* of the current folder.) |
|
187 | - * |
|
188 | - * For every item printed we remove the first item of $sizeLimits are there is no longer room in the output to print |
|
189 | - * items that small. |
|
190 | - */ |
|
159 | + /** |
|
160 | + * Print out the largest count($sizeLimits) files in the directory tree |
|
161 | + * |
|
162 | + * @param OutputInterface $output |
|
163 | + * @param Folder $node |
|
164 | + * @param string $prefix |
|
165 | + * @param array $sizeLimits largest items that are still in the queue to be printed, ordered ascending |
|
166 | + * @return int how many items we've printed |
|
167 | + */ |
|
168 | + public function outputLargeFilesTree( |
|
169 | + OutputInterface $output, |
|
170 | + Folder $node, |
|
171 | + string $prefix, |
|
172 | + array &$sizeLimits, |
|
173 | + bool $all, |
|
174 | + ): int { |
|
175 | + /** |
|
176 | + * Algorithm to print the N largest items in a folder without requiring to query or sort the entire three |
|
177 | + * |
|
178 | + * This is done by keeping a list ($sizeLimits) of size N that contain the largest items outside of this |
|
179 | + * folders that are could be printed if there aren't enough items in this folder that are larger. |
|
180 | + * |
|
181 | + * We loop over the items in this folder by size descending until the size of the item falls before the smallest |
|
182 | + * size in $sizeLimits (at that point there are enough items outside this folder to complete the N items). |
|
183 | + * |
|
184 | + * When encountering a folder, we create an updated $sizeLimits with the largest items in the current folder still |
|
185 | + * remaining which we pass into the recursion. (We don't update the current $sizeLimits because that should only |
|
186 | + * hold items *outside* of the current folder.) |
|
187 | + * |
|
188 | + * For every item printed we remove the first item of $sizeLimits are there is no longer room in the output to print |
|
189 | + * items that small. |
|
190 | + */ |
|
191 | 191 | |
192 | - $count = 0; |
|
193 | - $children = $node->getDirectoryListing(); |
|
194 | - usort($children, function (Node $a, Node $b) { |
|
195 | - return $b->getSize() <=> $a->getSize(); |
|
196 | - }); |
|
197 | - foreach ($children as $i => $child) { |
|
198 | - if (!$all) { |
|
199 | - if (count($sizeLimits) === 0 || $child->getSize() < $sizeLimits[0]) { |
|
200 | - return $count; |
|
201 | - } |
|
202 | - array_shift($sizeLimits); |
|
203 | - } |
|
204 | - $count += 1; |
|
192 | + $count = 0; |
|
193 | + $children = $node->getDirectoryListing(); |
|
194 | + usort($children, function (Node $a, Node $b) { |
|
195 | + return $b->getSize() <=> $a->getSize(); |
|
196 | + }); |
|
197 | + foreach ($children as $i => $child) { |
|
198 | + if (!$all) { |
|
199 | + if (count($sizeLimits) === 0 || $child->getSize() < $sizeLimits[0]) { |
|
200 | + return $count; |
|
201 | + } |
|
202 | + array_shift($sizeLimits); |
|
203 | + } |
|
204 | + $count += 1; |
|
205 | 205 | |
206 | - /** @var Node $child */ |
|
207 | - $output->writeln("$prefix- " . $child->getName() . ': <info>' . Util::humanFileSize($child->getSize()) . '</info>'); |
|
208 | - if ($child instanceof Folder) { |
|
209 | - $recurseSizeLimits = $sizeLimits; |
|
210 | - if (!$all) { |
|
211 | - for ($j = 0; $j < count($recurseSizeLimits); $j++) { |
|
212 | - if (isset($children[$i + $j + 1])) { |
|
213 | - $nextChildSize = $children[$i + $j + 1]->getSize(); |
|
214 | - if ($nextChildSize > $recurseSizeLimits[0]) { |
|
215 | - array_shift($recurseSizeLimits); |
|
216 | - $recurseSizeLimits[] = $nextChildSize; |
|
217 | - } |
|
218 | - } |
|
219 | - } |
|
220 | - sort($recurseSizeLimits); |
|
221 | - } |
|
222 | - $recurseCount = $this->outputLargeFilesTree($output, $child, $prefix . ' ', $recurseSizeLimits, $all); |
|
223 | - $sizeLimits = array_slice($sizeLimits, $recurseCount); |
|
224 | - $count += $recurseCount; |
|
225 | - } |
|
226 | - } |
|
227 | - return $count; |
|
228 | - } |
|
206 | + /** @var Node $child */ |
|
207 | + $output->writeln("$prefix- " . $child->getName() . ': <info>' . Util::humanFileSize($child->getSize()) . '</info>'); |
|
208 | + if ($child instanceof Folder) { |
|
209 | + $recurseSizeLimits = $sizeLimits; |
|
210 | + if (!$all) { |
|
211 | + for ($j = 0; $j < count($recurseSizeLimits); $j++) { |
|
212 | + if (isset($children[$i + $j + 1])) { |
|
213 | + $nextChildSize = $children[$i + $j + 1]->getSize(); |
|
214 | + if ($nextChildSize > $recurseSizeLimits[0]) { |
|
215 | + array_shift($recurseSizeLimits); |
|
216 | + $recurseSizeLimits[] = $nextChildSize; |
|
217 | + } |
|
218 | + } |
|
219 | + } |
|
220 | + sort($recurseSizeLimits); |
|
221 | + } |
|
222 | + $recurseCount = $this->outputLargeFilesTree($output, $child, $prefix . ' ', $recurseSizeLimits, $all); |
|
223 | + $sizeLimits = array_slice($sizeLimits, $recurseCount); |
|
224 | + $count += $recurseCount; |
|
225 | + } |
|
226 | + } |
|
227 | + return $count; |
|
228 | + } |
|
229 | 229 | |
230 | - public function getNumericStorageId(string $id): ?int { |
|
231 | - if (is_numeric($id)) { |
|
232 | - return (int)$id; |
|
233 | - } |
|
234 | - $query = $this->connection->getQueryBuilder(); |
|
235 | - $query->select('numeric_id') |
|
236 | - ->from('storages') |
|
237 | - ->where($query->expr()->eq('id', $query->createNamedParameter($id))); |
|
238 | - $result = $query->executeQuery()->fetchOne(); |
|
239 | - return $result ? (int)$result : null; |
|
240 | - } |
|
230 | + public function getNumericStorageId(string $id): ?int { |
|
231 | + if (is_numeric($id)) { |
|
232 | + return (int)$id; |
|
233 | + } |
|
234 | + $query = $this->connection->getQueryBuilder(); |
|
235 | + $query->select('numeric_id') |
|
236 | + ->from('storages') |
|
237 | + ->where($query->expr()->eq('id', $query->createNamedParameter($id))); |
|
238 | + $result = $query->executeQuery()->fetchOne(); |
|
239 | + return $result ? (int)$result : null; |
|
240 | + } |
|
241 | 241 | |
242 | - /** |
|
243 | - * @param int|null $limit |
|
244 | - * @return ?StorageInfo |
|
245 | - * @throws \OCP\DB\Exception |
|
246 | - */ |
|
247 | - public function getStorage(int $id): ?array { |
|
248 | - $query = $this->connection->getQueryBuilder(); |
|
249 | - $query->select('numeric_id', 's.id', 'available', 'last_checked', 'mount_id') |
|
250 | - ->selectAlias($query->func()->count('fileid'), 'files') |
|
251 | - ->from('storages', 's') |
|
252 | - ->innerJoin('s', 'filecache', 'f', $query->expr()->eq('f.storage', 's.numeric_id')) |
|
253 | - ->leftJoin('s', 'mounts', 'm', $query->expr()->eq('s.numeric_id', 'm.storage_id')) |
|
254 | - ->where($query->expr()->eq('s.numeric_id', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT))) |
|
255 | - ->groupBy('s.numeric_id', 's.id', 's.available', 's.last_checked', 'mount_id'); |
|
256 | - $row = $query->executeQuery()->fetch(); |
|
257 | - if ($row) { |
|
258 | - return [ |
|
259 | - 'numeric_id' => $row['numeric_id'], |
|
260 | - 'id' => $row['id'], |
|
261 | - 'files' => $row['files'], |
|
262 | - 'available' => (bool)$row['available'], |
|
263 | - 'last_checked' => $row['last_checked'] ? new \DateTime('@' . $row['last_checked']) : null, |
|
264 | - 'mount_id' => $row['mount_id'], |
|
265 | - ]; |
|
266 | - } else { |
|
267 | - return null; |
|
268 | - } |
|
269 | - } |
|
242 | + /** |
|
243 | + * @param int|null $limit |
|
244 | + * @return ?StorageInfo |
|
245 | + * @throws \OCP\DB\Exception |
|
246 | + */ |
|
247 | + public function getStorage(int $id): ?array { |
|
248 | + $query = $this->connection->getQueryBuilder(); |
|
249 | + $query->select('numeric_id', 's.id', 'available', 'last_checked', 'mount_id') |
|
250 | + ->selectAlias($query->func()->count('fileid'), 'files') |
|
251 | + ->from('storages', 's') |
|
252 | + ->innerJoin('s', 'filecache', 'f', $query->expr()->eq('f.storage', 's.numeric_id')) |
|
253 | + ->leftJoin('s', 'mounts', 'm', $query->expr()->eq('s.numeric_id', 'm.storage_id')) |
|
254 | + ->where($query->expr()->eq('s.numeric_id', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT))) |
|
255 | + ->groupBy('s.numeric_id', 's.id', 's.available', 's.last_checked', 'mount_id'); |
|
256 | + $row = $query->executeQuery()->fetch(); |
|
257 | + if ($row) { |
|
258 | + return [ |
|
259 | + 'numeric_id' => $row['numeric_id'], |
|
260 | + 'id' => $row['id'], |
|
261 | + 'files' => $row['files'], |
|
262 | + 'available' => (bool)$row['available'], |
|
263 | + 'last_checked' => $row['last_checked'] ? new \DateTime('@' . $row['last_checked']) : null, |
|
264 | + 'mount_id' => $row['mount_id'], |
|
265 | + ]; |
|
266 | + } else { |
|
267 | + return null; |
|
268 | + } |
|
269 | + } |
|
270 | 270 | |
271 | - /** |
|
272 | - * @param int|null $limit |
|
273 | - * @return \Iterator<StorageInfo> |
|
274 | - * @throws \OCP\DB\Exception |
|
275 | - */ |
|
276 | - public function listStorages(?int $limit): \Iterator { |
|
277 | - $query = $this->connection->getQueryBuilder(); |
|
278 | - $query->select('numeric_id', 's.id', 'available', 'last_checked', 'mount_id') |
|
279 | - ->selectAlias($query->func()->count('fileid'), 'files') |
|
280 | - ->from('storages', 's') |
|
281 | - ->innerJoin('s', 'filecache', 'f', $query->expr()->eq('f.storage', 's.numeric_id')) |
|
282 | - ->leftJoin('s', 'mounts', 'm', $query->expr()->eq('s.numeric_id', 'm.storage_id')) |
|
283 | - ->groupBy('s.numeric_id', 's.id', 's.available', 's.last_checked', 'mount_id') |
|
284 | - ->orderBy('files', 'DESC'); |
|
285 | - if ($limit !== null) { |
|
286 | - $query->setMaxResults($limit); |
|
287 | - } |
|
288 | - $result = $query->executeQuery(); |
|
289 | - while ($row = $result->fetch()) { |
|
290 | - yield [ |
|
291 | - 'numeric_id' => $row['numeric_id'], |
|
292 | - 'id' => $row['id'], |
|
293 | - 'files' => $row['files'], |
|
294 | - 'available' => (bool)$row['available'], |
|
295 | - 'last_checked' => $row['last_checked'] ? new \DateTime('@' . $row['last_checked']) : null, |
|
296 | - 'mount_id' => $row['mount_id'], |
|
297 | - ]; |
|
298 | - } |
|
299 | - } |
|
271 | + /** |
|
272 | + * @param int|null $limit |
|
273 | + * @return \Iterator<StorageInfo> |
|
274 | + * @throws \OCP\DB\Exception |
|
275 | + */ |
|
276 | + public function listStorages(?int $limit): \Iterator { |
|
277 | + $query = $this->connection->getQueryBuilder(); |
|
278 | + $query->select('numeric_id', 's.id', 'available', 'last_checked', 'mount_id') |
|
279 | + ->selectAlias($query->func()->count('fileid'), 'files') |
|
280 | + ->from('storages', 's') |
|
281 | + ->innerJoin('s', 'filecache', 'f', $query->expr()->eq('f.storage', 's.numeric_id')) |
|
282 | + ->leftJoin('s', 'mounts', 'm', $query->expr()->eq('s.numeric_id', 'm.storage_id')) |
|
283 | + ->groupBy('s.numeric_id', 's.id', 's.available', 's.last_checked', 'mount_id') |
|
284 | + ->orderBy('files', 'DESC'); |
|
285 | + if ($limit !== null) { |
|
286 | + $query->setMaxResults($limit); |
|
287 | + } |
|
288 | + $result = $query->executeQuery(); |
|
289 | + while ($row = $result->fetch()) { |
|
290 | + yield [ |
|
291 | + 'numeric_id' => $row['numeric_id'], |
|
292 | + 'id' => $row['id'], |
|
293 | + 'files' => $row['files'], |
|
294 | + 'available' => (bool)$row['available'], |
|
295 | + 'last_checked' => $row['last_checked'] ? new \DateTime('@' . $row['last_checked']) : null, |
|
296 | + 'mount_id' => $row['mount_id'], |
|
297 | + ]; |
|
298 | + } |
|
299 | + } |
|
300 | 300 | |
301 | - /** |
|
302 | - * @param StorageInfo $storage |
|
303 | - * @return array |
|
304 | - */ |
|
305 | - public function formatStorage(array $storage): array { |
|
306 | - return [ |
|
307 | - 'numeric_id' => $storage['numeric_id'], |
|
308 | - 'id' => $storage['id'], |
|
309 | - 'files' => $storage['files'], |
|
310 | - 'available' => $storage['available'] ? 'true' : 'false', |
|
311 | - 'last_checked' => $storage['last_checked']?->format(\DATE_ATOM), |
|
312 | - 'external_mount_id' => $storage['mount_id'], |
|
313 | - ]; |
|
314 | - } |
|
301 | + /** |
|
302 | + * @param StorageInfo $storage |
|
303 | + * @return array |
|
304 | + */ |
|
305 | + public function formatStorage(array $storage): array { |
|
306 | + return [ |
|
307 | + 'numeric_id' => $storage['numeric_id'], |
|
308 | + 'id' => $storage['id'], |
|
309 | + 'files' => $storage['files'], |
|
310 | + 'available' => $storage['available'] ? 'true' : 'false', |
|
311 | + 'last_checked' => $storage['last_checked']?->format(\DATE_ATOM), |
|
312 | + 'external_mount_id' => $storage['mount_id'], |
|
313 | + ]; |
|
314 | + } |
|
315 | 315 | |
316 | - /** |
|
317 | - * @param \Iterator<StorageInfo> $storages |
|
318 | - * @return \Iterator |
|
319 | - */ |
|
320 | - public function formatStorages(\Iterator $storages): \Iterator { |
|
321 | - foreach ($storages as $storage) { |
|
322 | - yield $this->formatStorage($storage); |
|
323 | - } |
|
324 | - } |
|
316 | + /** |
|
317 | + * @param \Iterator<StorageInfo> $storages |
|
318 | + * @return \Iterator |
|
319 | + */ |
|
320 | + public function formatStorages(\Iterator $storages): \Iterator { |
|
321 | + foreach ($storages as $storage) { |
|
322 | + yield $this->formatStorage($storage); |
|
323 | + } |
|
324 | + } |
|
325 | 325 | } |