make path absolute

This commit is contained in:
Jörn Friedrich Dreyer 2014-12-10 11:04:17 +01:00
parent 3cdaa4094f
commit 0f17486c1d
3 changed files with 17 additions and 10 deletions

View File

@ -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;
}

View File

@ -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);
if ($data !== null) {
$size = $this->scanChildren($path, $recursive, $reuse);
$data['size'] = $size;
}
return $data;
}

View File

@ -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());