@@ -27,42 +27,42 @@ |
||
27 | 27 | |
28 | 28 | class Admin implements ISettings { |
29 | 29 | |
30 | - /** @var SettingsManager */ |
|
31 | - private $settingsManager; |
|
30 | + /** @var SettingsManager */ |
|
31 | + private $settingsManager; |
|
32 | 32 | |
33 | - public function __construct(SettingsManager $settingsManager) { |
|
34 | - $this->settingsManager = $settingsManager; |
|
35 | - } |
|
33 | + public function __construct(SettingsManager $settingsManager) { |
|
34 | + $this->settingsManager = $settingsManager; |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * @return TemplateResponse |
|
39 | - */ |
|
40 | - public function getForm() { |
|
37 | + /** |
|
38 | + * @return TemplateResponse |
|
39 | + */ |
|
40 | + public function getForm() { |
|
41 | 41 | |
42 | - $parameters = [ |
|
43 | - 'sendPasswordMail' => $this->settingsManager->sendPasswordByMail(), |
|
44 | - 'enforcePasswordProtection' => $this->settingsManager->enforcePasswordProtection() |
|
45 | - ]; |
|
42 | + $parameters = [ |
|
43 | + 'sendPasswordMail' => $this->settingsManager->sendPasswordByMail(), |
|
44 | + 'enforcePasswordProtection' => $this->settingsManager->enforcePasswordProtection() |
|
45 | + ]; |
|
46 | 46 | |
47 | - return new TemplateResponse('sharebymail', 'settings-admin', $parameters, ''); |
|
48 | - } |
|
47 | + return new TemplateResponse('sharebymail', 'settings-admin', $parameters, ''); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @return string the section ID, e.g. 'sharing' |
|
52 | - */ |
|
53 | - public function getSection() { |
|
54 | - return 'sharing'; |
|
55 | - } |
|
50 | + /** |
|
51 | + * @return string the section ID, e.g. 'sharing' |
|
52 | + */ |
|
53 | + public function getSection() { |
|
54 | + return 'sharing'; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return int whether the form should be rather on the top or bottom of |
|
59 | - * the admin section. The forms are arranged in ascending order of the |
|
60 | - * priority values. It is required to return a value between 0 and 100. |
|
61 | - * |
|
62 | - * E.g.: 70 |
|
63 | - */ |
|
64 | - public function getPriority() { |
|
65 | - return 40; |
|
66 | - } |
|
57 | + /** |
|
58 | + * @return int whether the form should be rather on the top or bottom of |
|
59 | + * the admin section. The forms are arranged in ascending order of the |
|
60 | + * priority values. It is required to return a value between 0 and 100. |
|
61 | + * |
|
62 | + * E.g.: 70 |
|
63 | + */ |
|
64 | + public function getPriority() { |
|
65 | + return 40; |
|
66 | + } |
|
67 | 67 | |
68 | 68 | } |
@@ -27,27 +27,27 @@ |
||
27 | 27 | |
28 | 28 | class Settings { |
29 | 29 | |
30 | - /** @var SettingsManager */ |
|
31 | - private $settingsManager; |
|
32 | - |
|
33 | - public function __construct(SettingsManager $settingsManager) { |
|
34 | - $this->settingsManager = $settingsManager; |
|
35 | - } |
|
36 | - |
|
37 | - /** |
|
38 | - * announce that the share-by-mail share provider is enabled |
|
39 | - * |
|
40 | - * @param array $settings |
|
41 | - */ |
|
42 | - public function announceShareProvider(array $settings) { |
|
43 | - $array = json_decode($settings['array']['oc_appconfig'], true); |
|
44 | - $array['shareByMailEnabled'] = true; |
|
45 | - $settings['array']['oc_appconfig'] = json_encode($array); |
|
46 | - } |
|
47 | - |
|
48 | - public function announceShareByMailSettings(array $settings) { |
|
49 | - $array = json_decode($settings['array']['oc_appconfig'], true); |
|
50 | - $array['shareByMail']['enforcePasswordProtection'] = $this->settingsManager->enforcePasswordProtection(); |
|
51 | - $settings['array']['oc_appconfig'] = json_encode($array); |
|
52 | - } |
|
30 | + /** @var SettingsManager */ |
|
31 | + private $settingsManager; |
|
32 | + |
|
33 | + public function __construct(SettingsManager $settingsManager) { |
|
34 | + $this->settingsManager = $settingsManager; |
|
35 | + } |
|
36 | + |
|
37 | + /** |
|
38 | + * announce that the share-by-mail share provider is enabled |
|
39 | + * |
|
40 | + * @param array $settings |
|
41 | + */ |
|
42 | + public function announceShareProvider(array $settings) { |
|
43 | + $array = json_decode($settings['array']['oc_appconfig'], true); |
|
44 | + $array['shareByMailEnabled'] = true; |
|
45 | + $settings['array']['oc_appconfig'] = json_encode($array); |
|
46 | + } |
|
47 | + |
|
48 | + public function announceShareByMailSettings(array $settings) { |
|
49 | + $array = json_decode($settings['array']['oc_appconfig'], true); |
|
50 | + $array['shareByMail']['enforcePasswordProtection'] = $this->settingsManager->enforcePasswordProtection(); |
|
51 | + $settings['array']['oc_appconfig'] = json_encode($array); |
|
52 | + } |
|
53 | 53 | } |
@@ -28,13 +28,13 @@ |
||
28 | 28 | * @brief wraps around static Nextcloud core methods |
29 | 29 | */ |
30 | 30 | class LogWrapper { |
31 | - protected $app = 'user_ldap'; |
|
31 | + protected $app = 'user_ldap'; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @brief states whether the filesystem was loaded |
|
35 | - * @return bool |
|
36 | - */ |
|
37 | - public function log($msg, $level) { |
|
38 | - \OCP\Util::writeLog($this->app, $msg, $level); |
|
39 | - } |
|
33 | + /** |
|
34 | + * @brief states whether the filesystem was loaded |
|
35 | + * @return bool |
|
36 | + */ |
|
37 | + public function log($msg, $level) { |
|
38 | + \OCP\Util::writeLog($this->app, $msg, $level); |
|
39 | + } |
|
40 | 40 | } |
@@ -29,19 +29,19 @@ |
||
29 | 29 | */ |
30 | 30 | class FilesystemHelper { |
31 | 31 | |
32 | - /** |
|
33 | - * @brief states whether the filesystem was loaded |
|
34 | - * @return bool |
|
35 | - */ |
|
36 | - public function isLoaded() { |
|
37 | - return \OC\Files\Filesystem::$loaded; |
|
38 | - } |
|
32 | + /** |
|
33 | + * @brief states whether the filesystem was loaded |
|
34 | + * @return bool |
|
35 | + */ |
|
36 | + public function isLoaded() { |
|
37 | + return \OC\Files\Filesystem::$loaded; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @brief initializes the filesystem for the given user |
|
42 | - * @param string $uid the Nextcloud username of the user |
|
43 | - */ |
|
44 | - public function setup($uid) { |
|
45 | - \OC_Util::setupFS($uid); |
|
46 | - } |
|
40 | + /** |
|
41 | + * @brief initializes the filesystem for the given user |
|
42 | + * @param string $uid the Nextcloud username of the user |
|
43 | + */ |
|
44 | + public function setup($uid) { |
|
45 | + \OC_Util::setupFS($uid); |
|
46 | + } |
|
47 | 47 | } |
@@ -34,91 +34,91 @@ |
||
34 | 34 | |
35 | 35 | class SettingsController extends Controller { |
36 | 36 | |
37 | - /** @var IL10N */ |
|
38 | - private $l; |
|
39 | - |
|
40 | - /** @var TrustedServers */ |
|
41 | - private $trustedServers; |
|
42 | - |
|
43 | - /** |
|
44 | - * @param string $AppName |
|
45 | - * @param IRequest $request |
|
46 | - * @param IL10N $l10n |
|
47 | - * @param TrustedServers $trustedServers |
|
48 | - */ |
|
49 | - public function __construct($AppName, |
|
50 | - IRequest $request, |
|
51 | - IL10N $l10n, |
|
52 | - TrustedServers $trustedServers |
|
53 | - ) { |
|
54 | - parent::__construct($AppName, $request); |
|
55 | - $this->l = $l10n; |
|
56 | - $this->trustedServers = $trustedServers; |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * add server to the list of trusted Nextclouds |
|
62 | - * |
|
63 | - * @param string $url |
|
64 | - * @return DataResponse |
|
65 | - * @throws HintException |
|
66 | - */ |
|
67 | - public function addServer($url) { |
|
68 | - $this->checkServer($url); |
|
69 | - $id = $this->trustedServers->addServer($url); |
|
70 | - |
|
71 | - return new DataResponse( |
|
72 | - [ |
|
73 | - 'url' => $url, |
|
74 | - 'id' => $id, |
|
75 | - 'message' => (string) $this->l->t('Added to the list of trusted servers') |
|
76 | - ] |
|
77 | - ); |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * add server to the list of trusted Nextclouds |
|
82 | - * |
|
83 | - * @param int $id |
|
84 | - * @return DataResponse |
|
85 | - */ |
|
86 | - public function removeServer($id) { |
|
87 | - $this->trustedServers->removeServer($id); |
|
88 | - return new DataResponse(); |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * enable/disable to automatically add servers to the list of trusted servers |
|
93 | - * once a federated share was created and accepted successfully |
|
94 | - * |
|
95 | - * @param bool $autoAddServers |
|
96 | - */ |
|
97 | - public function autoAddServers($autoAddServers) { |
|
98 | - $this->trustedServers->setAutoAddServers($autoAddServers); |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * check if the server should be added to the list of trusted servers or not |
|
103 | - * |
|
104 | - * @param string $url |
|
105 | - * @return bool |
|
106 | - * @throws HintException |
|
107 | - */ |
|
108 | - protected function checkServer($url) { |
|
109 | - if ($this->trustedServers->isTrustedServer($url) === true) { |
|
110 | - $message = 'Server is already in the list of trusted servers.'; |
|
111 | - $hint = $this->l->t('Server is already in the list of trusted servers.'); |
|
112 | - throw new HintException($message, $hint); |
|
113 | - } |
|
114 | - |
|
115 | - if ($this->trustedServers->isOwnCloudServer($url) === false) { |
|
116 | - $message = 'No server to federate with found'; |
|
117 | - $hint = $this->l->t('No server to federate with found'); |
|
118 | - throw new HintException($message, $hint); |
|
119 | - } |
|
120 | - |
|
121 | - return true; |
|
122 | - } |
|
37 | + /** @var IL10N */ |
|
38 | + private $l; |
|
39 | + |
|
40 | + /** @var TrustedServers */ |
|
41 | + private $trustedServers; |
|
42 | + |
|
43 | + /** |
|
44 | + * @param string $AppName |
|
45 | + * @param IRequest $request |
|
46 | + * @param IL10N $l10n |
|
47 | + * @param TrustedServers $trustedServers |
|
48 | + */ |
|
49 | + public function __construct($AppName, |
|
50 | + IRequest $request, |
|
51 | + IL10N $l10n, |
|
52 | + TrustedServers $trustedServers |
|
53 | + ) { |
|
54 | + parent::__construct($AppName, $request); |
|
55 | + $this->l = $l10n; |
|
56 | + $this->trustedServers = $trustedServers; |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * add server to the list of trusted Nextclouds |
|
62 | + * |
|
63 | + * @param string $url |
|
64 | + * @return DataResponse |
|
65 | + * @throws HintException |
|
66 | + */ |
|
67 | + public function addServer($url) { |
|
68 | + $this->checkServer($url); |
|
69 | + $id = $this->trustedServers->addServer($url); |
|
70 | + |
|
71 | + return new DataResponse( |
|
72 | + [ |
|
73 | + 'url' => $url, |
|
74 | + 'id' => $id, |
|
75 | + 'message' => (string) $this->l->t('Added to the list of trusted servers') |
|
76 | + ] |
|
77 | + ); |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * add server to the list of trusted Nextclouds |
|
82 | + * |
|
83 | + * @param int $id |
|
84 | + * @return DataResponse |
|
85 | + */ |
|
86 | + public function removeServer($id) { |
|
87 | + $this->trustedServers->removeServer($id); |
|
88 | + return new DataResponse(); |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * enable/disable to automatically add servers to the list of trusted servers |
|
93 | + * once a federated share was created and accepted successfully |
|
94 | + * |
|
95 | + * @param bool $autoAddServers |
|
96 | + */ |
|
97 | + public function autoAddServers($autoAddServers) { |
|
98 | + $this->trustedServers->setAutoAddServers($autoAddServers); |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * check if the server should be added to the list of trusted servers or not |
|
103 | + * |
|
104 | + * @param string $url |
|
105 | + * @return bool |
|
106 | + * @throws HintException |
|
107 | + */ |
|
108 | + protected function checkServer($url) { |
|
109 | + if ($this->trustedServers->isTrustedServer($url) === true) { |
|
110 | + $message = 'Server is already in the list of trusted servers.'; |
|
111 | + $hint = $this->l->t('Server is already in the list of trusted servers.'); |
|
112 | + throw new HintException($message, $hint); |
|
113 | + } |
|
114 | + |
|
115 | + if ($this->trustedServers->isOwnCloudServer($url) === false) { |
|
116 | + $message = 'No server to federate with found'; |
|
117 | + $hint = $this->l->t('No server to federate with found'); |
|
118 | + throw new HintException($message, $hint); |
|
119 | + } |
|
120 | + |
|
121 | + return true; |
|
122 | + } |
|
123 | 123 | |
124 | 124 | } |
@@ -42,97 +42,97 @@ |
||
42 | 42 | * Migrate mount config from mount.json to the database |
43 | 43 | */ |
44 | 44 | class StorageMigrator { |
45 | - /** |
|
46 | - * @var BackendService |
|
47 | - */ |
|
48 | - private $backendService; |
|
45 | + /** |
|
46 | + * @var BackendService |
|
47 | + */ |
|
48 | + private $backendService; |
|
49 | 49 | |
50 | - /** |
|
51 | - * @var DBConfigService |
|
52 | - */ |
|
53 | - private $dbConfig; |
|
50 | + /** |
|
51 | + * @var DBConfigService |
|
52 | + */ |
|
53 | + private $dbConfig; |
|
54 | 54 | |
55 | - /** |
|
56 | - * @var IConfig |
|
57 | - */ |
|
58 | - private $config; |
|
55 | + /** |
|
56 | + * @var IConfig |
|
57 | + */ |
|
58 | + private $config; |
|
59 | 59 | |
60 | - /** |
|
61 | - * @var IDBConnection |
|
62 | - */ |
|
63 | - private $connection; |
|
60 | + /** |
|
61 | + * @var IDBConnection |
|
62 | + */ |
|
63 | + private $connection; |
|
64 | 64 | |
65 | - /** |
|
66 | - * @var ILogger |
|
67 | - */ |
|
68 | - private $logger; |
|
65 | + /** |
|
66 | + * @var ILogger |
|
67 | + */ |
|
68 | + private $logger; |
|
69 | 69 | |
70 | - /** @var IUserMountCache */ |
|
71 | - private $userMountCache; |
|
70 | + /** @var IUserMountCache */ |
|
71 | + private $userMountCache; |
|
72 | 72 | |
73 | - /** |
|
74 | - * StorageMigrator constructor. |
|
75 | - * |
|
76 | - * @param BackendService $backendService |
|
77 | - * @param DBConfigService $dbConfig |
|
78 | - * @param IConfig $config |
|
79 | - * @param IDBConnection $connection |
|
80 | - * @param ILogger $logger |
|
81 | - * @param IUserMountCache $userMountCache |
|
82 | - */ |
|
83 | - public function __construct( |
|
84 | - BackendService $backendService, |
|
85 | - DBConfigService $dbConfig, |
|
86 | - IConfig $config, |
|
87 | - IDBConnection $connection, |
|
88 | - ILogger $logger, |
|
89 | - IUserMountCache $userMountCache |
|
90 | - ) { |
|
91 | - $this->backendService = $backendService; |
|
92 | - $this->dbConfig = $dbConfig; |
|
93 | - $this->config = $config; |
|
94 | - $this->connection = $connection; |
|
95 | - $this->logger = $logger; |
|
96 | - $this->userMountCache = $userMountCache; |
|
97 | - } |
|
73 | + /** |
|
74 | + * StorageMigrator constructor. |
|
75 | + * |
|
76 | + * @param BackendService $backendService |
|
77 | + * @param DBConfigService $dbConfig |
|
78 | + * @param IConfig $config |
|
79 | + * @param IDBConnection $connection |
|
80 | + * @param ILogger $logger |
|
81 | + * @param IUserMountCache $userMountCache |
|
82 | + */ |
|
83 | + public function __construct( |
|
84 | + BackendService $backendService, |
|
85 | + DBConfigService $dbConfig, |
|
86 | + IConfig $config, |
|
87 | + IDBConnection $connection, |
|
88 | + ILogger $logger, |
|
89 | + IUserMountCache $userMountCache |
|
90 | + ) { |
|
91 | + $this->backendService = $backendService; |
|
92 | + $this->dbConfig = $dbConfig; |
|
93 | + $this->config = $config; |
|
94 | + $this->connection = $connection; |
|
95 | + $this->logger = $logger; |
|
96 | + $this->userMountCache = $userMountCache; |
|
97 | + } |
|
98 | 98 | |
99 | - private function migrate(LegacyStoragesService $legacyService, StoragesService $storageService) { |
|
100 | - $existingStorage = $legacyService->getAllStorages(); |
|
99 | + private function migrate(LegacyStoragesService $legacyService, StoragesService $storageService) { |
|
100 | + $existingStorage = $legacyService->getAllStorages(); |
|
101 | 101 | |
102 | - $this->connection->beginTransaction(); |
|
103 | - try { |
|
104 | - foreach ($existingStorage as $storage) { |
|
105 | - $mountOptions = $storage->getMountOptions(); |
|
106 | - if (!empty($mountOptions) && !isset($mountOptions['enable_sharing'])) { |
|
107 | - // existing mounts must have sharing enabled by default to avoid surprises |
|
108 | - $mountOptions['enable_sharing'] = true; |
|
109 | - $storage->setMountOptions($mountOptions); |
|
110 | - } |
|
111 | - $storageService->addStorage($storage); |
|
112 | - } |
|
113 | - $this->connection->commit(); |
|
114 | - } catch (\Exception $e) { |
|
115 | - $this->logger->logException($e); |
|
116 | - $this->connection->rollBack(); |
|
117 | - } |
|
118 | - } |
|
102 | + $this->connection->beginTransaction(); |
|
103 | + try { |
|
104 | + foreach ($existingStorage as $storage) { |
|
105 | + $mountOptions = $storage->getMountOptions(); |
|
106 | + if (!empty($mountOptions) && !isset($mountOptions['enable_sharing'])) { |
|
107 | + // existing mounts must have sharing enabled by default to avoid surprises |
|
108 | + $mountOptions['enable_sharing'] = true; |
|
109 | + $storage->setMountOptions($mountOptions); |
|
110 | + } |
|
111 | + $storageService->addStorage($storage); |
|
112 | + } |
|
113 | + $this->connection->commit(); |
|
114 | + } catch (\Exception $e) { |
|
115 | + $this->logger->logException($e); |
|
116 | + $this->connection->rollBack(); |
|
117 | + } |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * Migrate personal storages configured by the current user |
|
122 | - * |
|
123 | - * @param IUser $user |
|
124 | - */ |
|
125 | - public function migrateUser(IUser $user) { |
|
126 | - $dummySession = new DummyUserSession(); |
|
127 | - $dummySession->setUser($user); |
|
128 | - $userId = $user->getUID(); |
|
129 | - $userVersion = $this->config->getUserValue($userId, 'files_external', 'config_version', '0.0.0'); |
|
130 | - if (version_compare($userVersion, '0.5.0', '<')) { |
|
131 | - $this->config->setUserValue($userId, 'files_external', 'config_version', '0.5.0'); |
|
132 | - $legacyService = new UserLegacyStoragesService($this->backendService, $dummySession); |
|
133 | - $storageService = new UserStoragesService($this->backendService, $this->dbConfig, $dummySession, $this->userMountCache); |
|
120 | + /** |
|
121 | + * Migrate personal storages configured by the current user |
|
122 | + * |
|
123 | + * @param IUser $user |
|
124 | + */ |
|
125 | + public function migrateUser(IUser $user) { |
|
126 | + $dummySession = new DummyUserSession(); |
|
127 | + $dummySession->setUser($user); |
|
128 | + $userId = $user->getUID(); |
|
129 | + $userVersion = $this->config->getUserValue($userId, 'files_external', 'config_version', '0.0.0'); |
|
130 | + if (version_compare($userVersion, '0.5.0', '<')) { |
|
131 | + $this->config->setUserValue($userId, 'files_external', 'config_version', '0.5.0'); |
|
132 | + $legacyService = new UserLegacyStoragesService($this->backendService, $dummySession); |
|
133 | + $storageService = new UserStoragesService($this->backendService, $this->dbConfig, $dummySession, $this->userMountCache); |
|
134 | 134 | |
135 | - $this->migrate($legacyService, $storageService); |
|
136 | - } |
|
137 | - } |
|
135 | + $this->migrate($legacyService, $storageService); |
|
136 | + } |
|
137 | + } |
|
138 | 138 | } |
@@ -31,52 +31,52 @@ |
||
31 | 31 | * Scanner for SharedStorage |
32 | 32 | */ |
33 | 33 | class Scanner extends \OC\Files\Cache\Scanner { |
34 | - /** |
|
35 | - * @var \OCA\Files_Sharing\SharedStorage $storage |
|
36 | - */ |
|
37 | - protected $storage; |
|
34 | + /** |
|
35 | + * @var \OCA\Files_Sharing\SharedStorage $storage |
|
36 | + */ |
|
37 | + protected $storage; |
|
38 | 38 | |
39 | - private $sourceScanner; |
|
39 | + private $sourceScanner; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Returns metadata from the shared storage, but |
|
43 | - * with permissions from the source storage. |
|
44 | - * |
|
45 | - * @param string $path path of the file for which to retrieve metadata |
|
46 | - * |
|
47 | - * @return array an array of metadata of the file |
|
48 | - */ |
|
49 | - public function getData($path) { |
|
50 | - $data = parent::getData($path); |
|
51 | - if ($data === null) { |
|
52 | - return null; |
|
53 | - } |
|
54 | - $internalPath = $this->storage->getUnjailedPath($path); |
|
55 | - $data['permissions'] = $this->storage->getSourceStorage()->getPermissions($internalPath); |
|
56 | - return $data; |
|
57 | - } |
|
41 | + /** |
|
42 | + * Returns metadata from the shared storage, but |
|
43 | + * with permissions from the source storage. |
|
44 | + * |
|
45 | + * @param string $path path of the file for which to retrieve metadata |
|
46 | + * |
|
47 | + * @return array an array of metadata of the file |
|
48 | + */ |
|
49 | + public function getData($path) { |
|
50 | + $data = parent::getData($path); |
|
51 | + if ($data === null) { |
|
52 | + return null; |
|
53 | + } |
|
54 | + $internalPath = $this->storage->getUnjailedPath($path); |
|
55 | + $data['permissions'] = $this->storage->getSourceStorage()->getPermissions($internalPath); |
|
56 | + return $data; |
|
57 | + } |
|
58 | 58 | |
59 | - private function getSourceScanner() { |
|
60 | - if ($this->sourceScanner) { |
|
61 | - return $this->sourceScanner; |
|
62 | - } |
|
63 | - if ($this->storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) { |
|
64 | - /** @var \OC\Files\Storage\Storage $storage */ |
|
65 | - list($storage) = $this->storage->resolvePath(''); |
|
66 | - $this->sourceScanner = $storage->getScanner(); |
|
67 | - return $this->sourceScanner; |
|
68 | - } else { |
|
69 | - return null; |
|
70 | - } |
|
71 | - } |
|
59 | + private function getSourceScanner() { |
|
60 | + if ($this->sourceScanner) { |
|
61 | + return $this->sourceScanner; |
|
62 | + } |
|
63 | + if ($this->storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) { |
|
64 | + /** @var \OC\Files\Storage\Storage $storage */ |
|
65 | + list($storage) = $this->storage->resolvePath(''); |
|
66 | + $this->sourceScanner = $storage->getScanner(); |
|
67 | + return $this->sourceScanner; |
|
68 | + } else { |
|
69 | + return null; |
|
70 | + } |
|
71 | + } |
|
72 | 72 | |
73 | - public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true) { |
|
74 | - $sourceScanner = $this->getSourceScanner(); |
|
75 | - if ($sourceScanner instanceof NoopScanner) { |
|
76 | - return []; |
|
77 | - } else { |
|
78 | - return parent::scanFile($file, $reuseExisting, $parentId, $cacheData, $lock); |
|
79 | - } |
|
80 | - } |
|
73 | + public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true) { |
|
74 | + $sourceScanner = $this->getSourceScanner(); |
|
75 | + if ($sourceScanner instanceof NoopScanner) { |
|
76 | + return []; |
|
77 | + } else { |
|
78 | + return parent::scanFile($file, $reuseExisting, $parentId, $cacheData, $lock); |
|
79 | + } |
|
80 | + } |
|
81 | 81 | } |
82 | 82 |
@@ -25,28 +25,28 @@ |
||
25 | 25 | use OCP\AppFramework\Http\JSONResponse; |
26 | 26 | |
27 | 27 | class RateLimitTestController extends Controller { |
28 | - /** |
|
29 | - * @PublicPage |
|
30 | - * @NoCSRFRequired |
|
31 | - * |
|
32 | - * @UserRateThrottle(limit=5, period=100) |
|
33 | - * @AnonRateThrottle(limit=1, period=100) |
|
34 | - * |
|
35 | - * @return JSONResponse |
|
36 | - */ |
|
37 | - public function userAndAnonProtected() { |
|
38 | - return new JSONResponse(); |
|
39 | - } |
|
28 | + /** |
|
29 | + * @PublicPage |
|
30 | + * @NoCSRFRequired |
|
31 | + * |
|
32 | + * @UserRateThrottle(limit=5, period=100) |
|
33 | + * @AnonRateThrottle(limit=1, period=100) |
|
34 | + * |
|
35 | + * @return JSONResponse |
|
36 | + */ |
|
37 | + public function userAndAnonProtected() { |
|
38 | + return new JSONResponse(); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @PublicPage |
|
43 | - * @NoCSRFRequired |
|
44 | - * |
|
45 | - * @AnonRateThrottle(limit=1, period=10) |
|
46 | - * |
|
47 | - * @return JSONResponse |
|
48 | - */ |
|
49 | - public function onlyAnonProtected() { |
|
50 | - return new JSONResponse(); |
|
51 | - } |
|
41 | + /** |
|
42 | + * @PublicPage |
|
43 | + * @NoCSRFRequired |
|
44 | + * |
|
45 | + * @AnonRateThrottle(limit=1, period=10) |
|
46 | + * |
|
47 | + * @return JSONResponse |
|
48 | + */ |
|
49 | + public function onlyAnonProtected() { |
|
50 | + return new JSONResponse(); |
|
51 | + } |
|
52 | 52 | } |
@@ -25,7 +25,7 @@ |
||
25 | 25 | use OCP\AppFramework\Http; |
26 | 26 | |
27 | 27 | class RateLimitExceededException extends SecurityException { |
28 | - public function __construct() { |
|
29 | - parent::__construct('Rate limit exceeded', Http::STATUS_TOO_MANY_REQUESTS); |
|
30 | - } |
|
28 | + public function __construct() { |
|
29 | + parent::__construct('Rate limit exceeded', Http::STATUS_TOO_MANY_REQUESTS); |
|
30 | + } |
|
31 | 31 | } |