Adjust code for changed method signature

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
This commit is contained in:
Daniel Kesselberg 2018-10-07 18:17:29 +02:00
parent 14d802b8f3
commit 752f637207
No known key found for this signature in database
GPG Key ID: 36E3664E099D0614
2 changed files with 16 additions and 30 deletions

View File

@ -129,33 +129,25 @@ class Scan extends Base {
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) {
$output->writeln("\tFile <info>$path</info>");
$this->filesCounter += 1;
if ($this->hasBeenInterrupted()) {
throw new InterruptedException();
}
$this->hasBeenInterrupted();
});
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) {
$output->writeln("\tFolder <info>$path</info>");
$this->foldersCounter += 1;
if ($this->hasBeenInterrupted()) {
throw new InterruptedException();
}
$this->hasBeenInterrupted();
});
$scanner->listen('\OC\Files\Utils\Scanner', 'StorageNotAvailable', function (StorageNotAvailableException $e) use ($output) {
$output->writeln("Error while scanning, storage not available (" . $e->getMessage() . ")");
$output->writeln('Error while scanning, storage not available (' . $e->getMessage() . ')');
});
# count only
} else {
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function () use ($output) {
$this->filesCounter += 1;
if ($this->hasBeenInterrupted()) {
throw new InterruptedException();
}
$this->hasBeenInterrupted();
});
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function () use ($output) {
$this->foldersCounter += 1;
if ($this->hasBeenInterrupted()) {
throw new InterruptedException();
}
$this->hasBeenInterrupted();
});
}
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) {
@ -173,7 +165,7 @@ class Scan extends Base {
}
} catch (ForbiddenException $e) {
$output->writeln("<error>Home storage for user $user not writable</error>");
$output->writeln("Make sure you're running the scan command only as the user the web server runs as");
$output->writeln('Make sure you\'re running the scan command only as the user the web server runs as');
} catch (InterruptedException $e) {
# exit the function if ctrl-c has been pressed
$output->writeln('Interrupted by user');
@ -250,8 +242,10 @@ class Scan extends Base {
} else {
$output->writeln("<error>Unknown user $user_count $user</error>");
}
# check on each user if there was a user interrupt (ctrl-c) and exit foreach
if ($this->hasBeenInterrupted()) {
try {
$this->hasBeenInterrupted();
} catch(InterruptedException $e) {
break;
}
}

View File

@ -102,33 +102,25 @@ class ScanAppData extends Base {
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) {
$output->writeln("\tFile <info>$path</info>");
$this->filesCounter += 1;
if ($this->hasBeenInterrupted()) {
throw new InterruptedException();
}
$this->hasBeenInterrupted();
});
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) {
$output->writeln("\tFolder <info>$path</info>");
$this->foldersCounter += 1;
if ($this->hasBeenInterrupted()) {
throw new InterruptedException();
}
$this->hasBeenInterrupted();
});
$scanner->listen('\OC\Files\Utils\Scanner', 'StorageNotAvailable', function (StorageNotAvailableException $e) use ($output) {
$output->writeln("Error while scanning, storage not available (" . $e->getMessage() . ")");
$output->writeln('Error while scanning, storage not available (' . $e->getMessage() . ')');
});
# count only
} else {
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function () use ($output) {
$this->filesCounter += 1;
if ($this->hasBeenInterrupted()) {
throw new InterruptedException();
}
$this->hasBeenInterrupted();
});
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function () use ($output) {
$this->foldersCounter += 1;
if ($this->hasBeenInterrupted()) {
throw new InterruptedException();
}
$this->hasBeenInterrupted();
});
}
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function($path) use ($output) {
@ -142,7 +134,7 @@ class ScanAppData extends Base {
$scanner->scan($appData->getPath());
} catch (ForbiddenException $e) {
$output->writeln("<error>Storage not writable</error>");
$output->writeln("Make sure you're running the scan command only as the user the web server runs as");
$output->writeln('Make sure you\'re running the scan command only as the user the web server runs as');
} catch (InterruptedException $e) {
# exit the function if ctrl-c has been pressed
$output->writeln('Interrupted by user');