@@ -40,11 +40,11 @@ |
||
40 | 40 | $l = \OC::$server->getL10N('files_external'); |
41 | 41 | |
42 | 42 | \OCA\Files\App::getNavigationManager()->add([ |
43 | - "id" => 'extstoragemounts', |
|
44 | - "appname" => 'files_external', |
|
45 | - "script" => 'list.php', |
|
46 | - "order" => 30, |
|
47 | - "name" => $l->t('External storage') |
|
43 | + "id" => 'extstoragemounts', |
|
44 | + "appname" => 'files_external', |
|
45 | + "script" => 'list.php', |
|
46 | + "order" => 30, |
|
47 | + "name" => $l->t('External storage') |
|
48 | 48 | ]); |
49 | 49 | |
50 | 50 | $mountProvider = $appContainer->query('OCA\Files_External\Config\ConfigAdapter'); |
@@ -29,7 +29,7 @@ |
||
29 | 29 | |
30 | 30 | OC::$CLASSPATH['OC_Mount_Config'] = 'files_external/lib/config.php'; |
31 | 31 | |
32 | -require_once __DIR__ . '/../3rdparty/autoload.php'; |
|
32 | +require_once __DIR__.'/../3rdparty/autoload.php'; |
|
33 | 33 | |
34 | 34 | // register Application object singleton |
35 | 35 | \OC_Mount_Config::$app = new \OCA\Files_External\AppInfo\Application(); |
@@ -18,14 +18,14 @@ |
||
18 | 18 | <tr> |
19 | 19 | <th id='headerName' class="hidden column-name"> |
20 | 20 | <div id="headerName-container"> |
21 | - <a class="name sort columntitle" data-sort="name"><span><?php p($l->t( 'Name' )); ?></span><span class="sort-indicator"></span></a> |
|
21 | + <a class="name sort columntitle" data-sort="name"><span><?php p($l->t('Name')); ?></span><span class="sort-indicator"></span></a> |
|
22 | 22 | </div> |
23 | 23 | </th> |
24 | 24 | <th id="headerSize" class="hidden column-size"> |
25 | 25 | <a class="size sort columntitle" data-sort="size"><span><?php p($l->t('Size')); ?></span><span class="sort-indicator"></span></a> |
26 | 26 | </th> |
27 | 27 | <th id="headerDate" class="hidden column-mtime"> |
28 | - <a id="modified" class="columntitle" data-sort="mtime"><span><?php p($l->t( 'Modified' )); ?></span><span class="sort-indicator"></span></a> |
|
28 | + <a id="modified" class="columntitle" data-sort="mtime"><span><?php p($l->t('Modified')); ?></span><span class="sort-indicator"></span></a> |
|
29 | 29 | </th> |
30 | 30 | </tr> |
31 | 31 | </thead> |
@@ -28,29 +28,29 @@ |
||
28 | 28 | |
29 | 29 | class Admin implements ISettings { |
30 | 30 | |
31 | - /** |
|
32 | - * @return TemplateResponse |
|
33 | - */ |
|
34 | - public function getForm() { |
|
35 | - return new TemplateResponse('systemtags', 'admin', [], ''); |
|
36 | - } |
|
31 | + /** |
|
32 | + * @return TemplateResponse |
|
33 | + */ |
|
34 | + public function getForm() { |
|
35 | + return new TemplateResponse('systemtags', 'admin', [], ''); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * @return string the section ID, e.g. 'sharing' |
|
40 | - */ |
|
41 | - public function getSection() { |
|
42 | - return 'workflow'; |
|
43 | - } |
|
38 | + /** |
|
39 | + * @return string the section ID, e.g. 'sharing' |
|
40 | + */ |
|
41 | + public function getSection() { |
|
42 | + return 'workflow'; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @return int whether the form should be rather on the top or bottom of |
|
47 | - * the admin section. The forms are arranged in ascending order of the |
|
48 | - * priority values. It is required to return a value between 0 and 100. |
|
49 | - * |
|
50 | - * E.g.: 70 |
|
51 | - */ |
|
52 | - public function getPriority() { |
|
53 | - return 70; |
|
54 | - } |
|
45 | + /** |
|
46 | + * @return int whether the form should be rather on the top or bottom of |
|
47 | + * the admin section. The forms are arranged in ascending order of the |
|
48 | + * priority values. It is required to return a value between 0 and 100. |
|
49 | + * |
|
50 | + * E.g.: 70 |
|
51 | + */ |
|
52 | + public function getPriority() { |
|
53 | + return 70; |
|
54 | + } |
|
55 | 55 | |
56 | 56 | } |
@@ -15,14 +15,14 @@ |
||
15 | 15 | <tr> |
16 | 16 | <th id='headerName' class="hidden column-name"> |
17 | 17 | <div id="headerName-container"> |
18 | - <a class="name sort columntitle" data-sort="name"><span><?php p($l->t( 'Name' )); ?></span><span class="sort-indicator"></span></a> |
|
18 | + <a class="name sort columntitle" data-sort="name"><span><?php p($l->t('Name')); ?></span><span class="sort-indicator"></span></a> |
|
19 | 19 | </div> |
20 | 20 | </th> |
21 | 21 | <th id="headerDate" class="hidden column-mtime"> |
22 | - <a id="modified" class="columntitle" data-sort="mtime"><span><?php p($l->t( 'Share time' )); ?></span><span class="sort-indicator"></span></a> |
|
22 | + <a id="modified" class="columntitle" data-sort="mtime"><span><?php p($l->t('Share time')); ?></span><span class="sort-indicator"></span></a> |
|
23 | 23 | </th> |
24 | 24 | <th class="hidden column-expiration"> |
25 | - <a class="columntitle"><span><?php p($l->t( 'Expiration date' )); ?></span></a> |
|
25 | + <a class="columntitle"><span><?php p($l->t('Expiration date')); ?></span></a> |
|
26 | 26 | </th> |
27 | 27 | </tr> |
28 | 28 | </thead> |
@@ -30,28 +30,28 @@ discard block |
||
30 | 30 | OCP\JSON::checkAppEnabled('files_sharing'); |
31 | 31 | |
32 | 32 | if (!isset($_GET['t'])) { |
33 | - \OC_Response::setStatus(400); //400 Bad Request |
|
34 | - exit; |
|
33 | + \OC_Response::setStatus(400); //400 Bad Request |
|
34 | + exit; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application(); |
38 | 38 | $federatedShareProvider = $federatedSharingApp->getFederatedShareProvider(); |
39 | 39 | |
40 | 40 | if ($federatedShareProvider->isOutgoingServer2serverShareEnabled() === false) { |
41 | - \OC_Response::setStatus(404); // 404 not found |
|
42 | - exit; |
|
41 | + \OC_Response::setStatus(404); // 404 not found |
|
42 | + exit; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | $token = $_GET['t']; |
46 | 46 | |
47 | 47 | $password = null; |
48 | 48 | if (isset($_POST['password'])) { |
49 | - $password = $_POST['password']; |
|
49 | + $password = $_POST['password']; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | $relativePath = null; |
53 | 53 | if (isset($_GET['dir'])) { |
54 | - $relativePath = $_GET['dir']; |
|
54 | + $relativePath = $_GET['dir']; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | $data = \OCA\Files_Sharing\Helper::setupFromToken($token, $relativePath, $password); |
@@ -63,20 +63,20 @@ discard block |
||
63 | 63 | |
64 | 64 | $isWritable = $share->getPermissions() & (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_CREATE); |
65 | 65 | if (!$isWritable) { |
66 | - // FIXME: should not add storage wrappers outside of preSetup, need to find a better way |
|
67 | - $previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false); |
|
68 | - \OC\Files\Filesystem::addStorageWrapper('readonly', function ($mountPoint, $storage) { |
|
69 | - return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_SHARE)); |
|
70 | - }); |
|
71 | - \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog); |
|
66 | + // FIXME: should not add storage wrappers outside of preSetup, need to find a better way |
|
67 | + $previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false); |
|
68 | + \OC\Files\Filesystem::addStorageWrapper('readonly', function ($mountPoint, $storage) { |
|
69 | + return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_SHARE)); |
|
70 | + }); |
|
71 | + \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | $rootInfo = \OC\Files\Filesystem::getFileInfo($path); |
75 | 75 | $rootView = new \OC\Files\View(''); |
76 | 76 | |
77 | 77 | if($rootInfo === false || !($share->getPermissions() & \OCP\Constants::PERMISSION_READ)) { |
78 | - OCP\JSON::error(array('data' => 'Share is not readable.')); |
|
79 | - exit(); |
|
78 | + OCP\JSON::error(array('data' => 'Share is not readable.')); |
|
79 | + exit(); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -85,18 +85,18 @@ discard block |
||
85 | 85 | * @return array |
86 | 86 | */ |
87 | 87 | function getChildInfo($dir, $view, $sharePermissions) { |
88 | - $children = $view->getDirectoryContent($dir->getPath()); |
|
89 | - $result = array(); |
|
90 | - foreach ($children as $child) { |
|
91 | - $formatted = \OCA\Files\Helper::formatFileInfo($child); |
|
92 | - if ($child->getType() === 'dir') { |
|
93 | - $formatted['children'] = getChildInfo($child, $view, $sharePermissions); |
|
94 | - } |
|
95 | - $formatted['mtime'] = $formatted['mtime'] / 1000; |
|
96 | - $formatted['permissions'] = $sharePermissions & (int)$formatted['permissions']; |
|
97 | - $result[] = $formatted; |
|
98 | - } |
|
99 | - return $result; |
|
88 | + $children = $view->getDirectoryContent($dir->getPath()); |
|
89 | + $result = array(); |
|
90 | + foreach ($children as $child) { |
|
91 | + $formatted = \OCA\Files\Helper::formatFileInfo($child); |
|
92 | + if ($child->getType() === 'dir') { |
|
93 | + $formatted['children'] = getChildInfo($child, $view, $sharePermissions); |
|
94 | + } |
|
95 | + $formatted['mtime'] = $formatted['mtime'] / 1000; |
|
96 | + $formatted['permissions'] = $sharePermissions & (int)$formatted['permissions']; |
|
97 | + $result[] = $formatted; |
|
98 | + } |
|
99 | + return $result; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | $result = \OCA\Files\Helper::formatFileInfo($rootInfo); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | |
106 | 106 | |
107 | 107 | if ($rootInfo->getType() === 'dir') { |
108 | - $result['children'] = getChildInfo($rootInfo, $rootView, $share->getPermissions()); |
|
108 | + $result['children'] = getChildInfo($rootInfo, $rootView, $share->getPermissions()); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | OCP\JSON::success(array('data' => $result)); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | if (!$isWritable) { |
66 | 66 | // FIXME: should not add storage wrappers outside of preSetup, need to find a better way |
67 | 67 | $previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false); |
68 | - \OC\Files\Filesystem::addStorageWrapper('readonly', function ($mountPoint, $storage) { |
|
68 | + \OC\Files\Filesystem::addStorageWrapper('readonly', function($mountPoint, $storage) { |
|
69 | 69 | return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_SHARE)); |
70 | 70 | }); |
71 | 71 | \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | $rootInfo = \OC\Files\Filesystem::getFileInfo($path); |
75 | 75 | $rootView = new \OC\Files\View(''); |
76 | 76 | |
77 | -if($rootInfo === false || !($share->getPermissions() & \OCP\Constants::PERMISSION_READ)) { |
|
77 | +if ($rootInfo === false || !($share->getPermissions() & \OCP\Constants::PERMISSION_READ)) { |
|
78 | 78 | OCP\JSON::error(array('data' => 'Share is not readable.')); |
79 | 79 | exit(); |
80 | 80 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $formatted['children'] = getChildInfo($child, $view, $sharePermissions); |
94 | 94 | } |
95 | 95 | $formatted['mtime'] = $formatted['mtime'] / 1000; |
96 | - $formatted['permissions'] = $sharePermissions & (int)$formatted['permissions']; |
|
96 | + $formatted['permissions'] = $sharePermissions & (int) $formatted['permissions']; |
|
97 | 97 | $result[] = $formatted; |
98 | 98 | } |
99 | 99 | return $result; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | |
102 | 102 | $result = \OCA\Files\Helper::formatFileInfo($rootInfo); |
103 | 103 | $result['mtime'] = $result['mtime'] / 1000; |
104 | -$result['permissions'] = (int)$result['permissions'] & $share->getPermissions(); |
|
104 | +$result['permissions'] = (int) $result['permissions'] & $share->getPermissions(); |
|
105 | 105 | |
106 | 106 | |
107 | 107 | if ($rootInfo->getType() === 'dir') { |
@@ -29,49 +29,49 @@ |
||
29 | 29 | */ |
30 | 30 | class ExpireSharesJob extends TimedJob { |
31 | 31 | |
32 | - /** |
|
33 | - * sets the correct interval for this timed job |
|
34 | - */ |
|
35 | - public function __construct() { |
|
36 | - // Run once a day |
|
37 | - $this->setInterval(24 * 60 * 60); |
|
38 | - } |
|
32 | + /** |
|
33 | + * sets the correct interval for this timed job |
|
34 | + */ |
|
35 | + public function __construct() { |
|
36 | + // Run once a day |
|
37 | + $this->setInterval(24 * 60 * 60); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Makes the background job do its work |
|
42 | - * |
|
43 | - * @param array $argument unused argument |
|
44 | - */ |
|
45 | - public function run($argument) { |
|
46 | - $connection = \OC::$server->getDatabaseConnection(); |
|
47 | - $logger = \OC::$server->getLogger(); |
|
40 | + /** |
|
41 | + * Makes the background job do its work |
|
42 | + * |
|
43 | + * @param array $argument unused argument |
|
44 | + */ |
|
45 | + public function run($argument) { |
|
46 | + $connection = \OC::$server->getDatabaseConnection(); |
|
47 | + $logger = \OC::$server->getLogger(); |
|
48 | 48 | |
49 | - //Current time |
|
50 | - $now = new \DateTime(); |
|
51 | - $now = $now->format('Y-m-d H:i:s'); |
|
49 | + //Current time |
|
50 | + $now = new \DateTime(); |
|
51 | + $now = $now->format('Y-m-d H:i:s'); |
|
52 | 52 | |
53 | - /* |
|
53 | + /* |
|
54 | 54 | * Expire file link shares only (for now) |
55 | 55 | */ |
56 | - $qb = $connection->getQueryBuilder(); |
|
57 | - $qb->select('id', 'file_source', 'uid_owner', 'item_type') |
|
58 | - ->from('share') |
|
59 | - ->where( |
|
60 | - $qb->expr()->andX( |
|
61 | - $qb->expr()->eq('share_type', $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK)), |
|
62 | - $qb->expr()->lte('expiration', $qb->expr()->literal($now)), |
|
63 | - $qb->expr()->orX( |
|
64 | - $qb->expr()->eq('item_type', $qb->expr()->literal('file')), |
|
65 | - $qb->expr()->eq('item_type', $qb->expr()->literal('folder')) |
|
66 | - ) |
|
67 | - ) |
|
68 | - ); |
|
56 | + $qb = $connection->getQueryBuilder(); |
|
57 | + $qb->select('id', 'file_source', 'uid_owner', 'item_type') |
|
58 | + ->from('share') |
|
59 | + ->where( |
|
60 | + $qb->expr()->andX( |
|
61 | + $qb->expr()->eq('share_type', $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK)), |
|
62 | + $qb->expr()->lte('expiration', $qb->expr()->literal($now)), |
|
63 | + $qb->expr()->orX( |
|
64 | + $qb->expr()->eq('item_type', $qb->expr()->literal('file')), |
|
65 | + $qb->expr()->eq('item_type', $qb->expr()->literal('folder')) |
|
66 | + ) |
|
67 | + ) |
|
68 | + ); |
|
69 | 69 | |
70 | - $shares = $qb->execute(); |
|
71 | - while($share = $shares->fetch()) { |
|
72 | - \OCP\Share::unshare($share['item_type'], $share['file_source'], \OCP\Share::SHARE_TYPE_LINK, null, $share['uid_owner']); |
|
73 | - } |
|
74 | - $shares->closeCursor(); |
|
75 | - } |
|
70 | + $shares = $qb->execute(); |
|
71 | + while($share = $shares->fetch()) { |
|
72 | + \OCP\Share::unshare($share['item_type'], $share['file_source'], \OCP\Share::SHARE_TYPE_LINK, null, $share['uid_owner']); |
|
73 | + } |
|
74 | + $shares->closeCursor(); |
|
75 | + } |
|
76 | 76 | |
77 | 77 | } |
@@ -68,7 +68,7 @@ |
||
68 | 68 | ); |
69 | 69 | |
70 | 70 | $shares = $qb->execute(); |
71 | - while($share = $shares->fetch()) { |
|
71 | + while ($share = $shares->fetch()) { |
|
72 | 72 | \OCP\Share::unshare($share['item_type'], $share['file_source'], \OCP\Share::SHARE_TYPE_LINK, null, $share['uid_owner']); |
73 | 73 | } |
74 | 74 | $shares->closeCursor(); |
@@ -23,6 +23,6 @@ |
||
23 | 23 | |
24 | 24 | namespace OCA\Files_Sharing; |
25 | 25 | |
26 | -interface ISharedStorage{ |
|
26 | +interface ISharedStorage { |
|
27 | 27 | |
28 | 28 | } |
@@ -27,7 +27,6 @@ |
||
27 | 27 | * Expected path with a different root |
28 | 28 | * Possible Error Codes: |
29 | 29 | * 10 - Path not relative to data/ and point to the users file directory |
30 | - |
|
31 | 30 | */ |
32 | 31 | class BrokenPath extends \Exception { |
33 | 32 | } |
@@ -32,97 +32,97 @@ |
||
32 | 32 | use OCP\Files\StorageNotAvailableException; |
33 | 33 | |
34 | 34 | class Scanner extends \OC\Files\Cache\Scanner { |
35 | - /** @var \OCA\Files_Sharing\External\Storage */ |
|
36 | - protected $storage; |
|
35 | + /** @var \OCA\Files_Sharing\External\Storage */ |
|
36 | + protected $storage; |
|
37 | 37 | |
38 | - /** {@inheritDoc} */ |
|
39 | - public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) { |
|
40 | - if(!$this->storage->remoteIsOwnCloud()) { |
|
41 | - return parent::scan($path, $recursive, $recursive, $lock); |
|
42 | - } |
|
38 | + /** {@inheritDoc} */ |
|
39 | + public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) { |
|
40 | + if(!$this->storage->remoteIsOwnCloud()) { |
|
41 | + return parent::scan($path, $recursive, $recursive, $lock); |
|
42 | + } |
|
43 | 43 | |
44 | - $this->scanAll(); |
|
45 | - } |
|
44 | + $this->scanAll(); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Scan a single file and store it in the cache. |
|
49 | - * If an exception happened while accessing the external storage, |
|
50 | - * the storage will be checked for availability and removed |
|
51 | - * if it is not available any more. |
|
52 | - * |
|
53 | - * @param string $file file to scan |
|
54 | - * @param int $reuseExisting |
|
55 | - * @param int $parentId |
|
56 | - * @param array | null $cacheData existing data in the cache for the file to be scanned |
|
57 | - * @param bool $lock set to false to disable getting an additional read lock during scanning |
|
58 | - * @return array an array of metadata of the scanned file |
|
59 | - */ |
|
60 | - public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true) { |
|
61 | - try { |
|
62 | - return parent::scanFile($file, $reuseExisting); |
|
63 | - } catch (ForbiddenException $e) { |
|
64 | - $this->storage->checkStorageAvailability(); |
|
65 | - } catch (NotFoundException $e) { |
|
66 | - // if the storage isn't found, the call to |
|
67 | - // checkStorageAvailable() will verify it and remove it |
|
68 | - // if appropriate |
|
69 | - $this->storage->checkStorageAvailability(); |
|
70 | - } catch (StorageInvalidException $e) { |
|
71 | - $this->storage->checkStorageAvailability(); |
|
72 | - } catch (StorageNotAvailableException $e) { |
|
73 | - $this->storage->checkStorageAvailability(); |
|
74 | - } |
|
75 | - } |
|
47 | + /** |
|
48 | + * Scan a single file and store it in the cache. |
|
49 | + * If an exception happened while accessing the external storage, |
|
50 | + * the storage will be checked for availability and removed |
|
51 | + * if it is not available any more. |
|
52 | + * |
|
53 | + * @param string $file file to scan |
|
54 | + * @param int $reuseExisting |
|
55 | + * @param int $parentId |
|
56 | + * @param array | null $cacheData existing data in the cache for the file to be scanned |
|
57 | + * @param bool $lock set to false to disable getting an additional read lock during scanning |
|
58 | + * @return array an array of metadata of the scanned file |
|
59 | + */ |
|
60 | + public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true) { |
|
61 | + try { |
|
62 | + return parent::scanFile($file, $reuseExisting); |
|
63 | + } catch (ForbiddenException $e) { |
|
64 | + $this->storage->checkStorageAvailability(); |
|
65 | + } catch (NotFoundException $e) { |
|
66 | + // if the storage isn't found, the call to |
|
67 | + // checkStorageAvailable() will verify it and remove it |
|
68 | + // if appropriate |
|
69 | + $this->storage->checkStorageAvailability(); |
|
70 | + } catch (StorageInvalidException $e) { |
|
71 | + $this->storage->checkStorageAvailability(); |
|
72 | + } catch (StorageNotAvailableException $e) { |
|
73 | + $this->storage->checkStorageAvailability(); |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * Checks the remote share for changes. |
|
79 | - * If changes are available, scan them and update |
|
80 | - * the cache. |
|
81 | - * @throws NotFoundException |
|
82 | - * @throws StorageInvalidException |
|
83 | - * @throws \Exception |
|
84 | - */ |
|
85 | - public function scanAll() { |
|
86 | - try { |
|
87 | - $data = $this->storage->getShareInfo(); |
|
88 | - } catch (\Exception $e) { |
|
89 | - $this->storage->checkStorageAvailability(); |
|
90 | - throw new \Exception( |
|
91 | - 'Error while scanning remote share: "' . |
|
92 | - $this->storage->getRemote() . '" ' . |
|
93 | - $e->getMessage() |
|
94 | - ); |
|
95 | - } |
|
96 | - if ($data['status'] === 'success') { |
|
97 | - $this->addResult($data['data'], ''); |
|
98 | - } else { |
|
99 | - throw new \Exception( |
|
100 | - 'Error while scanning remote share: "' . |
|
101 | - $this->storage->getRemote() . '"' |
|
102 | - ); |
|
103 | - } |
|
104 | - } |
|
77 | + /** |
|
78 | + * Checks the remote share for changes. |
|
79 | + * If changes are available, scan them and update |
|
80 | + * the cache. |
|
81 | + * @throws NotFoundException |
|
82 | + * @throws StorageInvalidException |
|
83 | + * @throws \Exception |
|
84 | + */ |
|
85 | + public function scanAll() { |
|
86 | + try { |
|
87 | + $data = $this->storage->getShareInfo(); |
|
88 | + } catch (\Exception $e) { |
|
89 | + $this->storage->checkStorageAvailability(); |
|
90 | + throw new \Exception( |
|
91 | + 'Error while scanning remote share: "' . |
|
92 | + $this->storage->getRemote() . '" ' . |
|
93 | + $e->getMessage() |
|
94 | + ); |
|
95 | + } |
|
96 | + if ($data['status'] === 'success') { |
|
97 | + $this->addResult($data['data'], ''); |
|
98 | + } else { |
|
99 | + throw new \Exception( |
|
100 | + 'Error while scanning remote share: "' . |
|
101 | + $this->storage->getRemote() . '"' |
|
102 | + ); |
|
103 | + } |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * @param array $data |
|
108 | - * @param string $path |
|
109 | - */ |
|
110 | - private function addResult($data, $path) { |
|
111 | - $id = $this->cache->put($path, $data); |
|
112 | - if (isset($data['children'])) { |
|
113 | - $children = []; |
|
114 | - foreach ($data['children'] as $child) { |
|
115 | - $children[$child['name']] = true; |
|
116 | - $this->addResult($child, ltrim($path . '/' . $child['name'], '/')); |
|
117 | - } |
|
106 | + /** |
|
107 | + * @param array $data |
|
108 | + * @param string $path |
|
109 | + */ |
|
110 | + private function addResult($data, $path) { |
|
111 | + $id = $this->cache->put($path, $data); |
|
112 | + if (isset($data['children'])) { |
|
113 | + $children = []; |
|
114 | + foreach ($data['children'] as $child) { |
|
115 | + $children[$child['name']] = true; |
|
116 | + $this->addResult($child, ltrim($path . '/' . $child['name'], '/')); |
|
117 | + } |
|
118 | 118 | |
119 | - $existingCache = $this->cache->getFolderContentsById($id); |
|
120 | - foreach ($existingCache as $existingChild) { |
|
121 | - // if an existing child is not in the new data, remove it |
|
122 | - if (!isset($children[$existingChild['name']])) { |
|
123 | - $this->cache->remove(ltrim($path . '/' . $existingChild['name'], '/')); |
|
124 | - } |
|
125 | - } |
|
126 | - } |
|
127 | - } |
|
119 | + $existingCache = $this->cache->getFolderContentsById($id); |
|
120 | + foreach ($existingCache as $existingChild) { |
|
121 | + // if an existing child is not in the new data, remove it |
|
122 | + if (!isset($children[$existingChild['name']])) { |
|
123 | + $this->cache->remove(ltrim($path . '/' . $existingChild['name'], '/')); |
|
124 | + } |
|
125 | + } |
|
126 | + } |
|
127 | + } |
|
128 | 128 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | /** {@inheritDoc} */ |
39 | 39 | public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) { |
40 | - if(!$this->storage->remoteIsOwnCloud()) { |
|
40 | + if (!$this->storage->remoteIsOwnCloud()) { |
|
41 | 41 | return parent::scan($path, $recursive, $recursive, $lock); |
42 | 42 | } |
43 | 43 | |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | } catch (\Exception $e) { |
89 | 89 | $this->storage->checkStorageAvailability(); |
90 | 90 | throw new \Exception( |
91 | - 'Error while scanning remote share: "' . |
|
92 | - $this->storage->getRemote() . '" ' . |
|
91 | + 'Error while scanning remote share: "'. |
|
92 | + $this->storage->getRemote().'" '. |
|
93 | 93 | $e->getMessage() |
94 | 94 | ); |
95 | 95 | } |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | $this->addResult($data['data'], ''); |
98 | 98 | } else { |
99 | 99 | throw new \Exception( |
100 | - 'Error while scanning remote share: "' . |
|
101 | - $this->storage->getRemote() . '"' |
|
100 | + 'Error while scanning remote share: "'. |
|
101 | + $this->storage->getRemote().'"' |
|
102 | 102 | ); |
103 | 103 | } |
104 | 104 | } |
@@ -113,14 +113,14 @@ discard block |
||
113 | 113 | $children = []; |
114 | 114 | foreach ($data['children'] as $child) { |
115 | 115 | $children[$child['name']] = true; |
116 | - $this->addResult($child, ltrim($path . '/' . $child['name'], '/')); |
|
116 | + $this->addResult($child, ltrim($path.'/'.$child['name'], '/')); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | $existingCache = $this->cache->getFolderContentsById($id); |
120 | 120 | foreach ($existingCache as $existingChild) { |
121 | 121 | // if an existing child is not in the new data, remove it |
122 | 122 | if (!isset($children[$existingChild['name']])) { |
123 | - $this->cache->remove(ltrim($path . '/' . $existingChild['name'], '/')); |
|
123 | + $this->cache->remove(ltrim($path.'/'.$existingChild['name'], '/')); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | } |