Browse Source

remove triggerupdate, ref #11872

tags/v8.0.0alpha1
Jörn Friedrich Dreyer 9 years ago
parent
commit
7ef6df04da
3 changed files with 13 additions and 28 deletions
  1. 11
    3
      apps/files/command/scan.php
  2. 0
    23
      apps/files/triggerupdate.php
  3. 2
    2
      lib/private/files/utils/scanner.php

+ 11
- 3
apps/files/command/scan.php View File

@@ -37,6 +37,13 @@ class Scan extends Command {
InputArgument::OPTIONAL | InputArgument::IS_ARRAY,
'will rescan all files of the given user(s)'
)
->addOption(
'path',
null,
InputArgument::OPTIONAL,
'limit rescan to this path, eg. --path="files/Music"',
''
)
->addOption(
'all',
null,
@@ -45,7 +52,7 @@ class Scan extends Command {
);
}

protected function scanFiles($user, OutputInterface $output) {
protected function scanFiles($user, $path, OutputInterface $output) {
$scanner = new \OC\Files\Utils\Scanner($user, \OC::$server->getDatabaseConnection());
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) {
$output->writeln("Scanning <info>$path</info>");
@@ -54,7 +61,7 @@ class Scan extends Command {
$output->writeln("Scanning <info>$path</info>");
});
try {
$scanner->scan('');
$scanner->scan($path);
} 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");
@@ -67,6 +74,7 @@ class Scan extends Command {
} else {
$users = $input->getArgument('user_id');
}
$path = trim($input->getOption('path'), '/');

if (count($users) === 0) {
$output->writeln("<error>Please specify the user id to scan or \"--all\" to scan for all users</error>");
@@ -78,7 +86,7 @@ class Scan extends Command {
$user = $user->getUID();
}
if ($this->userManager->userExists($user)) {
$this->scanFiles($user, $output);
$this->scanFiles($user, $path, $output);
} else {
$output->writeln("<error>Unknown user $user</error>");
}

+ 0
- 23
apps/files/triggerupdate.php View File

@@ -1,23 +0,0 @@
<?php

require_once __DIR__ . '/../../lib/base.php';

if (OC::$CLI) {
if (count($argv) === 2) {
$file = $argv[1];
list(, $user) = explode('/', $file);
OCP\JSON::checkUserExists($user);
OC_Util::setupFS($user);
$view = new \OC\Files\View('');
/**
* @var \OC\Files\Storage\Storage $storage
*/
list($storage, $internalPath) = $view->resolvePath($file);
$watcher = $storage->getWatcher($internalPath);
$watcher->checkUpdate($internalPath);
} else {
echo "Usage: php triggerupdate.php /path/to/file\n";
}
} else {
echo "This script can be run from the command line only\n";
}

+ 2
- 2
lib/private/files/utils/scanner.php View File

@@ -114,7 +114,7 @@ class Scanner extends PublicEmitter {
* @param string $dir
* @throws \OC\ForbiddenException
*/
public function scan($dir) {
public function scan($dir = '') {
$mounts = $this->getMounts($dir);
foreach ($mounts as $mount) {
if (is_null($mount->getStorage())) {
@@ -131,7 +131,7 @@ class Scanner extends PublicEmitter {
$scanner->setUseTransactions(false);
$this->attachListener($mount);
$this->db->beginTransaction();
$scanner->scan('', \OC\Files\Cache\Scanner::SCAN_RECURSIVE, \OC\Files\Cache\Scanner::REUSE_ETAG | \OC\Files\Cache\Scanner::REUSE_SIZE);
$scanner->scan($dir, \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());

Loading…
Cancel
Save