X Tutup
Skip to content

Commit 701c4a7

Browse files
authored
Merge pull request #38785 from owncloud/verify-checksum-exceptions
Prevent files:checksum:verify from crashing on exception
2 parents a8a03dd + 6aeb0ab commit 701c4a7

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

apps/files/lib/Command/VerifyChecksums.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use OCP\Files\Node;
3030
use OCP\Files\NotFoundException;
3131
use OCP\Files\Storage\IStorage;
32+
use OCP\Files\StorageNotAvailableException;
3233
use OCP\IUser;
3334
use OCP\IUserManager;
3435
use Symfony\Component\Console\Command\Command;
@@ -200,11 +201,19 @@ private function verifyChecksumsForFile($file, InputInterface $input, OutputInte
200201
private function verifyChecksumsForFolder($folder, InputInterface $input, OutputInterface $output) {
201202
$folderQueue = [$folder];
202203
while ($currentFolder = \array_pop($folderQueue)) {
204+
'@phan-var \OCP\Files\Folder $currentFolder';
205+
$currentFolderPath = $currentFolder->getPath();
203206
try {
204-
'@phan-var \OCP\Files\Folder $currentFolder';
205207
$nodes = $currentFolder->getDirectoryListing();
206208
} catch (NotFoundException $e) {
207209
$nodes = [];
210+
$output->writeln("Skipping $currentFolderPath => Directory could not be found");
211+
} catch (StorageNotAvailableException $e) {
212+
$nodes = [];
213+
$output->writeln("Skipping $currentFolderPath => Storage is not available");
214+
} catch (\Exception $e) {
215+
$nodes = [];
216+
$output->writeln("Skipping $currentFolderPath => " . $e->getMessage());
208217
}
209218
foreach ($nodes as $node) {
210219
if ($node->getType() === FileInfo::TYPE_FOLDER) {

changelog/unreleased/38785

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Bugfix: Prevent files:checksum:verify from crashing on exception
2+
3+
The command now skips files with exceptions instead of crashing.
4+
A proper message will be displayed to the user who fires the command.
5+
6+
https://github.com/owncloud/core/pull/38785
7+
https://github.com/owncloud/core/issues/38782

0 commit comments

Comments
 (0)
X Tutup