aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files/command/scan.php18
-rw-r--r--lib/private/files/cache/scanner.php6
-rw-r--r--lib/private/files/utils/scanner.php3
3 files changed, 17 insertions, 10 deletions
diff --git a/apps/files/command/scan.php b/apps/files/command/scan.php
index 6e4b3ee4bc3..7cf401c7b59 100644
--- a/apps/files/command/scan.php
+++ b/apps/files/command/scan.php
@@ -41,8 +41,7 @@ class Scan extends Command {
'path',
'p',
InputArgument::OPTIONAL,
- 'limit rescan to this path, eg. --path="files/Music"',
- ''
+ 'limit rescan to this path, eg. --path="/alice/files/Music", the user_id is determined by the path and the user_id parameter and --all are ignored'
)
->addOption(
'quiet',
@@ -62,10 +61,10 @@ class Scan extends Command {
$scanner = new \OC\Files\Utils\Scanner($user, \OC::$server->getDatabaseConnection());
if (!$quiet) {
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) {
- $output->writeln("Scanning <info>$path</info>");
+ $output->writeln("Scanning file <info>$path</info>");
});
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) {
- $output->writeln("Scanning <info>$path</info>");
+ $output->writeln("Scanning folder <info>$path</info>");
});
}
try {
@@ -77,16 +76,21 @@ class Scan extends Command {
}
protected function execute(InputInterface $input, OutputInterface $output) {
- if ($input->getOption('all')) {
+ $path = $input->getOption('path');
+ if ($path !== false) {
+ $path = '/'.trim($path, '/');
+ list (, $user, ) = explode('/', $path, 3);
+ $users = array($user);
+ } else if ($input->getOption('all')) {
$users = $this->userManager->search('');
} else {
$users = $input->getArgument('user_id');
}
- $path = trim($input->getOption('path'), '/');
$quiet = $input->getOption('quiet');
+
if (count($users) === 0) {
- $output->writeln("<error>Please specify the user id to scan or \"--all\" to scan for all users</error>");
+ $output->writeln("<error>Please specify the user id to scan, \"--all\" to scan for all users or \"--path=...\"</error>");
return;
}
diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php
index 444207518b2..a5383cee10d 100644
--- a/lib/private/files/cache/scanner.php
+++ b/lib/private/files/cache/scanner.php
@@ -219,8 +219,10 @@ class Scanner extends BasicEmitter {
$reuse = ($recursive === self::SCAN_SHALLOW) ? self::REUSE_ETAG | self::REUSE_SIZE : 0;
}
$data = $this->scanFile($path, $reuse);
- $size = $this->scanChildren($path, $recursive, $reuse);
- $data['size'] = $size;
+ if ($data !== null) {
+ $size = $this->scanChildren($path, $recursive, $reuse);
+ $data['size'] = $size;
+ }
return $data;
}
diff --git a/lib/private/files/utils/scanner.php b/lib/private/files/utils/scanner.php
index a0b06328579..7625e52e015 100644
--- a/lib/private/files/utils/scanner.php
+++ b/lib/private/files/utils/scanner.php
@@ -127,11 +127,12 @@ class Scanner extends PublicEmitter {
) {
throw new ForbiddenException();
}
+ $relativePath = $mount->getInternalPath($dir);
$scanner = $storage->getScanner();
$scanner->setUseTransactions(false);
$this->attachListener($mount);
$this->db->beginTransaction();
- $scanner->scan($dir, \OC\Files\Cache\Scanner::SCAN_RECURSIVE, \OC\Files\Cache\Scanner::REUSE_ETAG | \OC\Files\Cache\Scanner::REUSE_SIZE);
+ $scanner->scan($relativePath, \OC\Files\Cache\Scanner::SCAN_RECURSIVE, \OC\Files\Cache\Scanner::REUSE_ETAG | \OC\Files\Cache\Scanner::REUSE_SIZE);
$this->db->commit();
}
$this->propagator->propagateChanges(time());