Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add folder argument to files:scan-app-data #20626

Merged
merged 1 commit into from
Apr 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions apps/files/lib/Command/ScanAppData.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
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;

Expand Down Expand Up @@ -67,6 +68,8 @@ protected function configure() {
$this
->setName('files:scan-app-data')
->setDescription('rescan the AppData folder');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
->setDescription('rescan the AppData folder');
->setDescription('rescan the AppData folder')
->addArgument('folder', InputArgument::OPTIONAL, 'The appdata subfolder to scan', '');


$this->addArgument('folder', InputArgument::OPTIONAL, 'The appdata subfolder to scan', '');
}

public function checkScanWarning($fullPath, OutputInterface $output) {
Expand All @@ -78,14 +81,23 @@ public function checkScanWarning($fullPath, OutputInterface $output) {
}
}

protected function scanFiles(OutputInterface $output) {
protected function scanFiles(OutputInterface $output, string $folder) {
try {
$appData = $this->getAppDataFolder();
} catch (NotFoundException $e) {
$output->writeln('NoAppData folder found');
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());

Expand Down Expand Up @@ -139,9 +151,11 @@ protected function execute(InputInterface $input, OutputInterface $output) {

$output->writeln("\nScanning AppData for files");

$folder = $input->getArgument('folder');

$this->initTools();

$this->scanFiles($output);
$this->scanFiles($output, $folder);

$this->presentStats($output);
}
Expand Down