diff options
author | Robin Appelman <icewind@owncloud.com> | 2013-06-19 01:26:08 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2013-06-19 01:26:08 +0200 |
commit | 85585ede023e4f8e59c0b01dc5e4552d8ff23ad6 (patch) | |
tree | d14f6c5ff4b0a83cfa3870ee30c0012c779bc206 /apps/files/ajax/scan.php | |
parent | 0b74e71de83801475a029951cdc85d2942307856 (diff) | |
download | nextcloud-server-85585ede023e4f8e59c0b01dc5e4552d8ff23ad6.tar.gz nextcloud-server-85585ede023e4f8e59c0b01dc5e4552d8ff23ad6.zip |
allow scanning files for multiple users
Diffstat (limited to 'apps/files/ajax/scan.php')
-rw-r--r-- | apps/files/ajax/scan.php | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/apps/files/ajax/scan.php b/apps/files/ajax/scan.php index 6659cd459c8..d58fd69b9f9 100644 --- a/apps/files/ajax/scan.php +++ b/apps/files/ajax/scan.php @@ -4,6 +4,16 @@ session_write_close(); $force = (isset($_GET['force']) and ($_GET['force'] === 'true')); $dir = isset($_GET['dir']) ? $_GET['dir'] : ''; +if (isset($_GET['users'])) { + OC_JSON::checkAdminUser(); + if ($_GET['users'] === 'all') { + $users = OC_User::getUsers(); + } else { + $users = explode(',', $_GET['users']); + } +} else { + $users = array(OC_User::getUser()); +} $eventSource = new OC_EventSource(); ScanListener::$eventSource = $eventSource; @@ -12,21 +22,27 @@ ScanListener::$view = \OC\Files\Filesystem::getView(); OC_Hook::connect('\OC\Files\Cache\Scanner', 'scan_folder', 'ScanListener', 'folder'); OC_Hook::connect('\OC\Files\Cache\Scanner', 'scan_file', 'ScanListener', 'file'); -$absolutePath = \OC\Files\Filesystem::getView()->getAbsolutePath($dir); +foreach ($users as $user) { + $eventSource->send('user', $user); + OC_Util::tearDownFS(); + OC_Util::setupFS($user); + + $absolutePath = \OC\Files\Filesystem::getView()->getAbsolutePath($dir); -$mountPoints = \OC\Files\Filesystem::getMountPoints($absolutePath); -$mountPoints[] = \OC\Files\Filesystem::getMountPoint($absolutePath); -$mountPoints = array_reverse($mountPoints); //start with the mount point of $dir + $mountPoints = \OC\Files\Filesystem::getMountPoints($absolutePath); + $mountPoints[] = \OC\Files\Filesystem::getMountPoint($absolutePath); + $mountPoints = array_reverse($mountPoints); //start with the mount point of $dir -foreach ($mountPoints as $mountPoint) { - $storage = \OC\Files\Filesystem::getStorage($mountPoint); - if ($storage) { - ScanListener::$mountPoints[$storage->getId()] = $mountPoint; - $scanner = $storage->getScanner(); - if ($force) { - $scanner->scan('', \OC\Files\Cache\Scanner::SCAN_RECURSIVE, \OC\Files\Cache\Scanner::REUSE_ETAG); - } else { - $scanner->backgroundScan(); + foreach ($mountPoints as $mountPoint) { + $storage = \OC\Files\Filesystem::getStorage($mountPoint); + if ($storage) { + ScanListener::$mountPoints[$storage->getId()] = $mountPoint; + $scanner = $storage->getScanner(); + if ($force) { + $scanner->scan('', \OC\Files\Cache\Scanner::SCAN_RECURSIVE, \OC\Files\Cache\Scanner::REUSE_ETAG); + } else { + $scanner->backgroundScan(); + } } } } |