Merge pull request #20626 from nextcloud/enh/scan-appdata-folder-arg

Add folder argument to files:scan-app-data
This commit is contained in:
Roeland Jago Douma 2020-04-24 13:07:17 +02:00 committed by GitHub
commit 8c07b6e07a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 2 deletions

View File

@ -38,6 +38,7 @@ use OCP\Files\StorageNotAvailableException;
use OCP\IConfig;
use OCP\IDBConnection;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@ -67,6 +68,8 @@ class ScanAppData extends Base {
$this
->setName('files:scan-app-data')
->setDescription('rescan the AppData folder');
$this->addArgument('folder', InputArgument::OPTIONAL, 'The appdata subfolder to scan', '');
}
public function checkScanWarning($fullPath, OutputInterface $output) {
@ -78,7 +81,7 @@ class ScanAppData extends Base {
}
}
protected function scanFiles(OutputInterface $output) {
protected function scanFiles(OutputInterface $output, string $folder) {
try {
$appData = $this->getAppDataFolder();
} catch (NotFoundException $e) {
@ -86,6 +89,15 @@ class ScanAppData extends Base {
return;
}
if ($folder !== '') {
try {
$appData = $appData->get($folder);
} catch (NotFoundException $e) {
$output->writeln('Could not find folder: ' . $folder);
return;
}
}
$connection = $this->reconnectToDatabase($output);
$scanner = new \OC\Files\Utils\Scanner(null, $connection, \OC::$server->query(IEventDispatcher::class), \OC::$server->getLogger());
@ -139,9 +151,11 @@ class ScanAppData extends Base {
$output->writeln("\nScanning AppData for files");
$folder = $input->getArgument('folder');
$this->initTools();
$this->scanFiles($output);
$this->scanFiles($output, $folder);
$this->presentStats($output);
}