@@ -32,29 +32,29 @@ |
||
32 | 32 | use OCP\Migration\IRepairStep; |
33 | 33 | |
34 | 34 | class ClearCollectionsAccessCache implements IRepairStep { |
35 | - /** @var IConfig */ |
|
36 | - private $config; |
|
37 | - |
|
38 | - /** @var Manager */ |
|
39 | - private $manager; |
|
40 | - |
|
41 | - public function __construct(IConfig $config, IManager $manager) { |
|
42 | - $this->config = $config; |
|
43 | - $this->manager = $manager; |
|
44 | - } |
|
45 | - |
|
46 | - public function getName(): string { |
|
47 | - return 'Clear access cache of projects'; |
|
48 | - } |
|
49 | - |
|
50 | - private function shouldRun(): bool { |
|
51 | - $versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0'); |
|
52 | - return version_compare($versionFromBeforeUpdate, '17.0.0.3', '<='); |
|
53 | - } |
|
54 | - |
|
55 | - public function run(IOutput $output): void { |
|
56 | - if ($this->shouldRun()) { |
|
57 | - $this->manager->invalidateAccessCacheForAllCollections(); |
|
58 | - } |
|
59 | - } |
|
35 | + /** @var IConfig */ |
|
36 | + private $config; |
|
37 | + |
|
38 | + /** @var Manager */ |
|
39 | + private $manager; |
|
40 | + |
|
41 | + public function __construct(IConfig $config, IManager $manager) { |
|
42 | + $this->config = $config; |
|
43 | + $this->manager = $manager; |
|
44 | + } |
|
45 | + |
|
46 | + public function getName(): string { |
|
47 | + return 'Clear access cache of projects'; |
|
48 | + } |
|
49 | + |
|
50 | + private function shouldRun(): bool { |
|
51 | + $versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0'); |
|
52 | + return version_compare($versionFromBeforeUpdate, '17.0.0.3', '<='); |
|
53 | + } |
|
54 | + |
|
55 | + public function run(IOutput $output): void { |
|
56 | + if ($this->shouldRun()) { |
|
57 | + $this->manager->invalidateAccessCacheForAllCollections(); |
|
58 | + } |
|
59 | + } |
|
60 | 60 | } |
@@ -31,114 +31,114 @@ |
||
31 | 31 | use OCP\L10N\ILanguageIterator; |
32 | 32 | |
33 | 33 | class LanguageIterator implements ILanguageIterator { |
34 | - private $i = 0; |
|
35 | - /** @var IConfig */ |
|
36 | - private $config; |
|
37 | - /** @var IUser */ |
|
38 | - private $user; |
|
34 | + private $i = 0; |
|
35 | + /** @var IConfig */ |
|
36 | + private $config; |
|
37 | + /** @var IUser */ |
|
38 | + private $user; |
|
39 | 39 | |
40 | - public function __construct(IUser $user, IConfig $config) { |
|
41 | - $this->config = $config; |
|
42 | - $this->user = $user; |
|
43 | - } |
|
40 | + public function __construct(IUser $user, IConfig $config) { |
|
41 | + $this->config = $config; |
|
42 | + $this->user = $user; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Rewind the Iterator to the first element |
|
47 | - */ |
|
48 | - public function rewind(): void { |
|
49 | - $this->i = 0; |
|
50 | - } |
|
45 | + /** |
|
46 | + * Rewind the Iterator to the first element |
|
47 | + */ |
|
48 | + public function rewind(): void { |
|
49 | + $this->i = 0; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Return the current element |
|
54 | - * |
|
55 | - * @since 14.0.0 |
|
56 | - */ |
|
57 | - public function current(): string { |
|
58 | - switch ($this->i) { |
|
59 | - /** @noinspection PhpMissingBreakStatementInspection */ |
|
60 | - case 0: |
|
61 | - $forcedLang = $this->config->getSystemValue('force_language', false); |
|
62 | - if (is_string($forcedLang)) { |
|
63 | - return $forcedLang; |
|
64 | - } |
|
65 | - $this->next(); |
|
66 | - /** @noinspection PhpMissingBreakStatementInspection */ |
|
67 | - // no break |
|
68 | - case 1: |
|
69 | - $forcedLang = $this->config->getSystemValue('force_language', false); |
|
70 | - if (is_string($forcedLang) |
|
71 | - && ($truncated = $this->getTruncatedLanguage($forcedLang)) !== $forcedLang |
|
72 | - ) { |
|
73 | - return $truncated; |
|
74 | - } |
|
75 | - $this->next(); |
|
76 | - /** @noinspection PhpMissingBreakStatementInspection */ |
|
77 | - // no break |
|
78 | - case 2: |
|
79 | - $userLang = $this->config->getUserValue($this->user->getUID(), 'core', 'lang', null); |
|
80 | - if (is_string($userLang)) { |
|
81 | - return $userLang; |
|
82 | - } |
|
83 | - $this->next(); |
|
84 | - /** @noinspection PhpMissingBreakStatementInspection */ |
|
85 | - // no break |
|
86 | - case 3: |
|
87 | - $userLang = $this->config->getUserValue($this->user->getUID(), 'core', 'lang', null); |
|
88 | - if (is_string($userLang) |
|
89 | - && ($truncated = $this->getTruncatedLanguage($userLang)) !== $userLang |
|
90 | - ) { |
|
91 | - return $truncated; |
|
92 | - } |
|
93 | - $this->next(); |
|
94 | - // no break |
|
95 | - case 4: |
|
96 | - return $this->config->getSystemValueString('default_language', 'en'); |
|
97 | - /** @noinspection PhpMissingBreakStatementInspection */ |
|
98 | - case 5: |
|
99 | - $defaultLang = $this->config->getSystemValueString('default_language', 'en'); |
|
100 | - if (($truncated = $this->getTruncatedLanguage($defaultLang)) !== $defaultLang) { |
|
101 | - return $truncated; |
|
102 | - } |
|
103 | - $this->next(); |
|
104 | - // no break |
|
105 | - default: |
|
106 | - return 'en'; |
|
107 | - } |
|
108 | - } |
|
52 | + /** |
|
53 | + * Return the current element |
|
54 | + * |
|
55 | + * @since 14.0.0 |
|
56 | + */ |
|
57 | + public function current(): string { |
|
58 | + switch ($this->i) { |
|
59 | + /** @noinspection PhpMissingBreakStatementInspection */ |
|
60 | + case 0: |
|
61 | + $forcedLang = $this->config->getSystemValue('force_language', false); |
|
62 | + if (is_string($forcedLang)) { |
|
63 | + return $forcedLang; |
|
64 | + } |
|
65 | + $this->next(); |
|
66 | + /** @noinspection PhpMissingBreakStatementInspection */ |
|
67 | + // no break |
|
68 | + case 1: |
|
69 | + $forcedLang = $this->config->getSystemValue('force_language', false); |
|
70 | + if (is_string($forcedLang) |
|
71 | + && ($truncated = $this->getTruncatedLanguage($forcedLang)) !== $forcedLang |
|
72 | + ) { |
|
73 | + return $truncated; |
|
74 | + } |
|
75 | + $this->next(); |
|
76 | + /** @noinspection PhpMissingBreakStatementInspection */ |
|
77 | + // no break |
|
78 | + case 2: |
|
79 | + $userLang = $this->config->getUserValue($this->user->getUID(), 'core', 'lang', null); |
|
80 | + if (is_string($userLang)) { |
|
81 | + return $userLang; |
|
82 | + } |
|
83 | + $this->next(); |
|
84 | + /** @noinspection PhpMissingBreakStatementInspection */ |
|
85 | + // no break |
|
86 | + case 3: |
|
87 | + $userLang = $this->config->getUserValue($this->user->getUID(), 'core', 'lang', null); |
|
88 | + if (is_string($userLang) |
|
89 | + && ($truncated = $this->getTruncatedLanguage($userLang)) !== $userLang |
|
90 | + ) { |
|
91 | + return $truncated; |
|
92 | + } |
|
93 | + $this->next(); |
|
94 | + // no break |
|
95 | + case 4: |
|
96 | + return $this->config->getSystemValueString('default_language', 'en'); |
|
97 | + /** @noinspection PhpMissingBreakStatementInspection */ |
|
98 | + case 5: |
|
99 | + $defaultLang = $this->config->getSystemValueString('default_language', 'en'); |
|
100 | + if (($truncated = $this->getTruncatedLanguage($defaultLang)) !== $defaultLang) { |
|
101 | + return $truncated; |
|
102 | + } |
|
103 | + $this->next(); |
|
104 | + // no break |
|
105 | + default: |
|
106 | + return 'en'; |
|
107 | + } |
|
108 | + } |
|
109 | 109 | |
110 | - /** |
|
111 | - * Move forward to next element |
|
112 | - * |
|
113 | - * @since 14.0.0 |
|
114 | - */ |
|
115 | - public function next(): void { |
|
116 | - ++$this->i; |
|
117 | - } |
|
110 | + /** |
|
111 | + * Move forward to next element |
|
112 | + * |
|
113 | + * @since 14.0.0 |
|
114 | + */ |
|
115 | + public function next(): void { |
|
116 | + ++$this->i; |
|
117 | + } |
|
118 | 118 | |
119 | - /** |
|
120 | - * Return the key of the current element |
|
121 | - * |
|
122 | - * @since 14.0.0 |
|
123 | - */ |
|
124 | - public function key(): int { |
|
125 | - return $this->i; |
|
126 | - } |
|
119 | + /** |
|
120 | + * Return the key of the current element |
|
121 | + * |
|
122 | + * @since 14.0.0 |
|
123 | + */ |
|
124 | + public function key(): int { |
|
125 | + return $this->i; |
|
126 | + } |
|
127 | 127 | |
128 | - /** |
|
129 | - * Checks if current position is valid |
|
130 | - * |
|
131 | - * @since 14.0.0 |
|
132 | - */ |
|
133 | - public function valid(): bool { |
|
134 | - return $this->i <= 6; |
|
135 | - } |
|
128 | + /** |
|
129 | + * Checks if current position is valid |
|
130 | + * |
|
131 | + * @since 14.0.0 |
|
132 | + */ |
|
133 | + public function valid(): bool { |
|
134 | + return $this->i <= 6; |
|
135 | + } |
|
136 | 136 | |
137 | - protected function getTruncatedLanguage(string $lang):string { |
|
138 | - $pos = strpos($lang, '_'); |
|
139 | - if ($pos !== false) { |
|
140 | - $lang = substr($lang, 0, $pos); |
|
141 | - } |
|
142 | - return $lang; |
|
143 | - } |
|
137 | + protected function getTruncatedLanguage(string $lang):string { |
|
138 | + $pos = strpos($lang, '_'); |
|
139 | + if ($pos !== false) { |
|
140 | + $lang = substr($lang, 0, $pos); |
|
141 | + } |
|
142 | + return $lang; |
|
143 | + } |
|
144 | 144 | } |
@@ -28,42 +28,42 @@ |
||
28 | 28 | namespace OC\IntegrityCheck\Iterator; |
29 | 29 | |
30 | 30 | class ExcludeFoldersByPathFilterIterator extends \RecursiveFilterIterator { |
31 | - private $excludedFolders; |
|
31 | + private $excludedFolders; |
|
32 | 32 | |
33 | - public function __construct(\RecursiveIterator $iterator, $root = '') { |
|
34 | - parent::__construct($iterator); |
|
33 | + public function __construct(\RecursiveIterator $iterator, $root = '') { |
|
34 | + parent::__construct($iterator); |
|
35 | 35 | |
36 | - $appFolders = \OC::$APPSROOTS; |
|
37 | - foreach ($appFolders as $key => $appFolder) { |
|
38 | - $appFolders[$key] = rtrim($appFolder['path'], '/'); |
|
39 | - } |
|
36 | + $appFolders = \OC::$APPSROOTS; |
|
37 | + foreach ($appFolders as $key => $appFolder) { |
|
38 | + $appFolders[$key] = rtrim($appFolder['path'], '/'); |
|
39 | + } |
|
40 | 40 | |
41 | - $excludedFolders = [ |
|
42 | - rtrim($root . '/data', '/'), |
|
43 | - rtrim($root . '/themes', '/'), |
|
44 | - rtrim($root . '/config', '/'), |
|
45 | - rtrim($root . '/apps', '/'), |
|
46 | - rtrim($root . '/assets', '/'), |
|
47 | - rtrim($root . '/lost+found', '/'), |
|
48 | - // Ignore folders generated by updater since the updater is replaced |
|
49 | - // after the integrity check is run. |
|
50 | - // See https://github.com/owncloud/updater/issues/318#issuecomment-212497846 |
|
51 | - rtrim($root . '/updater', '/'), |
|
52 | - rtrim($root . '/_oc_upgrade', '/'), |
|
53 | - ]; |
|
54 | - $customDataDir = \OC::$server->getConfig()->getSystemValueString('datadirectory', ''); |
|
55 | - if ($customDataDir !== '') { |
|
56 | - $excludedFolders[] = rtrim($customDataDir, '/'); |
|
57 | - } |
|
41 | + $excludedFolders = [ |
|
42 | + rtrim($root . '/data', '/'), |
|
43 | + rtrim($root . '/themes', '/'), |
|
44 | + rtrim($root . '/config', '/'), |
|
45 | + rtrim($root . '/apps', '/'), |
|
46 | + rtrim($root . '/assets', '/'), |
|
47 | + rtrim($root . '/lost+found', '/'), |
|
48 | + // Ignore folders generated by updater since the updater is replaced |
|
49 | + // after the integrity check is run. |
|
50 | + // See https://github.com/owncloud/updater/issues/318#issuecomment-212497846 |
|
51 | + rtrim($root . '/updater', '/'), |
|
52 | + rtrim($root . '/_oc_upgrade', '/'), |
|
53 | + ]; |
|
54 | + $customDataDir = \OC::$server->getConfig()->getSystemValueString('datadirectory', ''); |
|
55 | + if ($customDataDir !== '') { |
|
56 | + $excludedFolders[] = rtrim($customDataDir, '/'); |
|
57 | + } |
|
58 | 58 | |
59 | - $this->excludedFolders = array_merge($excludedFolders, $appFolders); |
|
60 | - } |
|
59 | + $this->excludedFolders = array_merge($excludedFolders, $appFolders); |
|
60 | + } |
|
61 | 61 | |
62 | - public function accept(): bool { |
|
63 | - return !\in_array( |
|
64 | - $this->current()->getPathName(), |
|
65 | - $this->excludedFolders, |
|
66 | - true |
|
67 | - ); |
|
68 | - } |
|
62 | + public function accept(): bool { |
|
63 | + return !\in_array( |
|
64 | + $this->current()->getPathName(), |
|
65 | + $this->excludedFolders, |
|
66 | + true |
|
67 | + ); |
|
68 | + } |
|
69 | 69 | } |
@@ -30,42 +30,42 @@ |
||
30 | 30 | * Mount provider for custom cache storages |
31 | 31 | */ |
32 | 32 | class CacheMountProvider implements IMountProvider { |
33 | - /** |
|
34 | - * @var IConfig |
|
35 | - */ |
|
36 | - private $config; |
|
33 | + /** |
|
34 | + * @var IConfig |
|
35 | + */ |
|
36 | + private $config; |
|
37 | 37 | |
38 | - /** |
|
39 | - * ObjectStoreHomeMountProvider constructor. |
|
40 | - * |
|
41 | - * @param IConfig $config |
|
42 | - */ |
|
43 | - public function __construct(IConfig $config) { |
|
44 | - $this->config = $config; |
|
45 | - } |
|
38 | + /** |
|
39 | + * ObjectStoreHomeMountProvider constructor. |
|
40 | + * |
|
41 | + * @param IConfig $config |
|
42 | + */ |
|
43 | + public function __construct(IConfig $config) { |
|
44 | + $this->config = $config; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Get the cache mount for a user |
|
49 | - * |
|
50 | - * @param IUser $user |
|
51 | - * @param IStorageFactory $loader |
|
52 | - * @return \OCP\Files\Mount\IMountPoint[] |
|
53 | - */ |
|
54 | - public function getMountsForUser(IUser $user, IStorageFactory $loader) { |
|
55 | - $cacheBaseDir = $this->config->getSystemValueString('cache_path', ''); |
|
56 | - if ($cacheBaseDir !== '') { |
|
57 | - $cacheDir = rtrim($cacheBaseDir, '/') . '/' . $user->getUID(); |
|
58 | - if (!file_exists($cacheDir)) { |
|
59 | - mkdir($cacheDir, 0770, true); |
|
60 | - mkdir($cacheDir . '/uploads', 0770, true); |
|
61 | - } |
|
47 | + /** |
|
48 | + * Get the cache mount for a user |
|
49 | + * |
|
50 | + * @param IUser $user |
|
51 | + * @param IStorageFactory $loader |
|
52 | + * @return \OCP\Files\Mount\IMountPoint[] |
|
53 | + */ |
|
54 | + public function getMountsForUser(IUser $user, IStorageFactory $loader) { |
|
55 | + $cacheBaseDir = $this->config->getSystemValueString('cache_path', ''); |
|
56 | + if ($cacheBaseDir !== '') { |
|
57 | + $cacheDir = rtrim($cacheBaseDir, '/') . '/' . $user->getUID(); |
|
58 | + if (!file_exists($cacheDir)) { |
|
59 | + mkdir($cacheDir, 0770, true); |
|
60 | + mkdir($cacheDir . '/uploads', 0770, true); |
|
61 | + } |
|
62 | 62 | |
63 | - return [ |
|
64 | - new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/cache', ['datadir' => $cacheDir], $loader, null, null, self::class), |
|
65 | - new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/uploads', ['datadir' => $cacheDir . '/uploads'], $loader, null, null, self::class) |
|
66 | - ]; |
|
67 | - } else { |
|
68 | - return []; |
|
69 | - } |
|
70 | - } |
|
63 | + return [ |
|
64 | + new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/cache', ['datadir' => $cacheDir], $loader, null, null, self::class), |
|
65 | + new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/uploads', ['datadir' => $cacheDir . '/uploads'], $loader, null, null, self::class) |
|
66 | + ]; |
|
67 | + } else { |
|
68 | + return []; |
|
69 | + } |
|
70 | + } |
|
71 | 71 | } |
@@ -30,21 +30,21 @@ |
||
30 | 30 | use OCP\IConfig; |
31 | 31 | |
32 | 32 | class FinishRememberedLoginCommand extends ALoginCommand { |
33 | - /** @var Session */ |
|
34 | - private $userSession; |
|
35 | - /** @var IConfig */ |
|
36 | - private $config; |
|
33 | + /** @var Session */ |
|
34 | + private $userSession; |
|
35 | + /** @var IConfig */ |
|
36 | + private $config; |
|
37 | 37 | |
38 | - public function __construct(Session $userSession, IConfig $config) { |
|
39 | - $this->userSession = $userSession; |
|
40 | - $this->config = $config; |
|
41 | - } |
|
38 | + public function __construct(Session $userSession, IConfig $config) { |
|
39 | + $this->userSession = $userSession; |
|
40 | + $this->config = $config; |
|
41 | + } |
|
42 | 42 | |
43 | - public function process(LoginData $loginData): LoginResult { |
|
44 | - if ($loginData->isRememberLogin() && !$this->config->getSystemValueBool('auto_logout', false)) { |
|
45 | - $this->userSession->createRememberMeToken($loginData->getUser()); |
|
46 | - } |
|
43 | + public function process(LoginData $loginData): LoginResult { |
|
44 | + if ($loginData->isRememberLogin() && !$this->config->getSystemValueBool('auto_logout', false)) { |
|
45 | + $this->userSession->createRememberMeToken($loginData->getUser()); |
|
46 | + } |
|
47 | 47 | |
48 | - return $this->processNextOrFinishSuccessfully($loginData); |
|
49 | - } |
|
48 | + return $this->processNextOrFinishSuccessfully($loginData); |
|
49 | + } |
|
50 | 50 | } |
@@ -30,18 +30,18 @@ |
||
30 | 30 | * @since 27.0.0 |
31 | 31 | */ |
32 | 32 | interface IParallelAwareJob { |
33 | - /** |
|
34 | - * Set this to false to prevent two Jobs from the same class from running in parallel |
|
35 | - * |
|
36 | - * @param bool $allow |
|
37 | - * @return void |
|
38 | - * @since 27.0.0 |
|
39 | - */ |
|
40 | - public function setAllowParallelRuns(bool $allow): void; |
|
33 | + /** |
|
34 | + * Set this to false to prevent two Jobs from the same class from running in parallel |
|
35 | + * |
|
36 | + * @param bool $allow |
|
37 | + * @return void |
|
38 | + * @since 27.0.0 |
|
39 | + */ |
|
40 | + public function setAllowParallelRuns(bool $allow): void; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @return bool |
|
44 | - * @since 27.0.0 |
|
45 | - */ |
|
46 | - public function getAllowParallelRuns(): bool; |
|
42 | + /** |
|
43 | + * @return bool |
|
44 | + * @since 27.0.0 |
|
45 | + */ |
|
46 | + public function getAllowParallelRuns(): bool; |
|
47 | 47 | } |
@@ -35,73 +35,73 @@ |
||
35 | 35 | * @since 6.0.0 |
36 | 36 | */ |
37 | 37 | interface File extends Node { |
38 | - /** |
|
39 | - * Get the content of the file as string |
|
40 | - * |
|
41 | - * @return string |
|
42 | - * @throws NotPermittedException |
|
43 | - * @throws GenericFileException |
|
44 | - * @throws LockedException |
|
45 | - * @since 6.0.0 |
|
46 | - */ |
|
47 | - public function getContent(); |
|
38 | + /** |
|
39 | + * Get the content of the file as string |
|
40 | + * |
|
41 | + * @return string |
|
42 | + * @throws NotPermittedException |
|
43 | + * @throws GenericFileException |
|
44 | + * @throws LockedException |
|
45 | + * @since 6.0.0 |
|
46 | + */ |
|
47 | + public function getContent(); |
|
48 | 48 | |
49 | - /** |
|
50 | - * Write to the file from string data |
|
51 | - * |
|
52 | - * @param string|resource $data |
|
53 | - * @throws NotPermittedException |
|
54 | - * @throws GenericFileException |
|
55 | - * @throws LockedException |
|
56 | - * @since 6.0.0 |
|
57 | - */ |
|
58 | - public function putContent($data); |
|
49 | + /** |
|
50 | + * Write to the file from string data |
|
51 | + * |
|
52 | + * @param string|resource $data |
|
53 | + * @throws NotPermittedException |
|
54 | + * @throws GenericFileException |
|
55 | + * @throws LockedException |
|
56 | + * @since 6.0.0 |
|
57 | + */ |
|
58 | + public function putContent($data); |
|
59 | 59 | |
60 | - /** |
|
61 | - * Get the mimetype of the file |
|
62 | - * |
|
63 | - * @return string |
|
64 | - * @since 6.0.0 |
|
65 | - */ |
|
66 | - public function getMimeType(); |
|
60 | + /** |
|
61 | + * Get the mimetype of the file |
|
62 | + * |
|
63 | + * @return string |
|
64 | + * @since 6.0.0 |
|
65 | + */ |
|
66 | + public function getMimeType(); |
|
67 | 67 | |
68 | - /** |
|
69 | - * Open the file as stream, resulting resource can be operated as stream like the result from php's own fopen |
|
70 | - * |
|
71 | - * @param string $mode |
|
72 | - * @return resource|false |
|
73 | - * @throws NotPermittedException |
|
74 | - * @throws LockedException |
|
75 | - * @since 6.0.0 |
|
76 | - */ |
|
77 | - public function fopen($mode); |
|
68 | + /** |
|
69 | + * Open the file as stream, resulting resource can be operated as stream like the result from php's own fopen |
|
70 | + * |
|
71 | + * @param string $mode |
|
72 | + * @return resource|false |
|
73 | + * @throws NotPermittedException |
|
74 | + * @throws LockedException |
|
75 | + * @since 6.0.0 |
|
76 | + */ |
|
77 | + public function fopen($mode); |
|
78 | 78 | |
79 | - /** |
|
80 | - * Compute the hash of the file |
|
81 | - * Type of hash is set with $type and can be anything supported by php's hash_file |
|
82 | - * |
|
83 | - * @param string $type |
|
84 | - * @param bool $raw |
|
85 | - * @return string |
|
86 | - * @since 6.0.0 |
|
87 | - */ |
|
88 | - public function hash($type, $raw = false); |
|
79 | + /** |
|
80 | + * Compute the hash of the file |
|
81 | + * Type of hash is set with $type and can be anything supported by php's hash_file |
|
82 | + * |
|
83 | + * @param string $type |
|
84 | + * @param bool $raw |
|
85 | + * @return string |
|
86 | + * @since 6.0.0 |
|
87 | + */ |
|
88 | + public function hash($type, $raw = false); |
|
89 | 89 | |
90 | - /** |
|
91 | - * Get the stored checksum for this file |
|
92 | - * |
|
93 | - * @return string |
|
94 | - * @since 9.0.0 |
|
95 | - * @throws InvalidPathException |
|
96 | - * @throws NotFoundException |
|
97 | - */ |
|
98 | - public function getChecksum(); |
|
90 | + /** |
|
91 | + * Get the stored checksum for this file |
|
92 | + * |
|
93 | + * @return string |
|
94 | + * @since 9.0.0 |
|
95 | + * @throws InvalidPathException |
|
96 | + * @throws NotFoundException |
|
97 | + */ |
|
98 | + public function getChecksum(); |
|
99 | 99 | |
100 | - /** |
|
101 | - * Get the extension of this file |
|
102 | - * |
|
103 | - * @return string |
|
104 | - * @since 15.0.0 |
|
105 | - */ |
|
106 | - public function getExtension(): string; |
|
100 | + /** |
|
101 | + * Get the extension of this file |
|
102 | + * |
|
103 | + * @return string |
|
104 | + * @since 15.0.0 |
|
105 | + */ |
|
106 | + public function getExtension(): string; |
|
107 | 107 | } |
@@ -33,129 +33,129 @@ |
||
33 | 33 | use OCP\Lock\LockedException; |
34 | 34 | |
35 | 35 | class File extends Node implements \OCP\Files\File { |
36 | - /** |
|
37 | - * Creates a Folder that represents a non-existing path |
|
38 | - * |
|
39 | - * @param string $path path |
|
40 | - * @return NonExistingFile non-existing node |
|
41 | - */ |
|
42 | - protected function createNonExistingNode($path) { |
|
43 | - return new NonExistingFile($this->root, $this->view, $path); |
|
44 | - } |
|
36 | + /** |
|
37 | + * Creates a Folder that represents a non-existing path |
|
38 | + * |
|
39 | + * @param string $path path |
|
40 | + * @return NonExistingFile non-existing node |
|
41 | + */ |
|
42 | + protected function createNonExistingNode($path) { |
|
43 | + return new NonExistingFile($this->root, $this->view, $path); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * @return string |
|
48 | - * @throws NotPermittedException |
|
49 | - * @throws GenericFileException |
|
50 | - * @throws LockedException |
|
51 | - */ |
|
52 | - public function getContent() { |
|
53 | - if ($this->checkPermissions(\OCP\Constants::PERMISSION_READ)) { |
|
54 | - $content = $this->view->file_get_contents($this->path); |
|
55 | - if ($content === false) { |
|
56 | - throw new GenericFileException(); |
|
57 | - } |
|
58 | - return $content; |
|
59 | - } else { |
|
60 | - throw new NotPermittedException(); |
|
61 | - } |
|
62 | - } |
|
46 | + /** |
|
47 | + * @return string |
|
48 | + * @throws NotPermittedException |
|
49 | + * @throws GenericFileException |
|
50 | + * @throws LockedException |
|
51 | + */ |
|
52 | + public function getContent() { |
|
53 | + if ($this->checkPermissions(\OCP\Constants::PERMISSION_READ)) { |
|
54 | + $content = $this->view->file_get_contents($this->path); |
|
55 | + if ($content === false) { |
|
56 | + throw new GenericFileException(); |
|
57 | + } |
|
58 | + return $content; |
|
59 | + } else { |
|
60 | + throw new NotPermittedException(); |
|
61 | + } |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @param string|resource $data |
|
66 | - * @throws NotPermittedException |
|
67 | - * @throws GenericFileException |
|
68 | - * @throws LockedException |
|
69 | - */ |
|
70 | - public function putContent($data) { |
|
71 | - if ($this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE)) { |
|
72 | - $this->sendHooks(['preWrite']); |
|
73 | - if ($this->view->file_put_contents($this->path, $data) === false) { |
|
74 | - throw new GenericFileException('file_put_contents failed'); |
|
75 | - } |
|
76 | - $this->fileInfo = null; |
|
77 | - $this->sendHooks(['postWrite']); |
|
78 | - } else { |
|
79 | - throw new NotPermittedException(); |
|
80 | - } |
|
81 | - } |
|
64 | + /** |
|
65 | + * @param string|resource $data |
|
66 | + * @throws NotPermittedException |
|
67 | + * @throws GenericFileException |
|
68 | + * @throws LockedException |
|
69 | + */ |
|
70 | + public function putContent($data) { |
|
71 | + if ($this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE)) { |
|
72 | + $this->sendHooks(['preWrite']); |
|
73 | + if ($this->view->file_put_contents($this->path, $data) === false) { |
|
74 | + throw new GenericFileException('file_put_contents failed'); |
|
75 | + } |
|
76 | + $this->fileInfo = null; |
|
77 | + $this->sendHooks(['postWrite']); |
|
78 | + } else { |
|
79 | + throw new NotPermittedException(); |
|
80 | + } |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * @param string $mode |
|
85 | - * @return resource|false |
|
86 | - * @throws NotPermittedException |
|
87 | - * @throws LockedException |
|
88 | - */ |
|
89 | - public function fopen($mode) { |
|
90 | - $preHooks = []; |
|
91 | - $postHooks = []; |
|
92 | - $requiredPermissions = \OCP\Constants::PERMISSION_READ; |
|
93 | - switch ($mode) { |
|
94 | - case 'r+': |
|
95 | - case 'rb+': |
|
96 | - case 'w+': |
|
97 | - case 'wb+': |
|
98 | - case 'x+': |
|
99 | - case 'xb+': |
|
100 | - case 'a+': |
|
101 | - case 'ab+': |
|
102 | - case 'w': |
|
103 | - case 'wb': |
|
104 | - case 'x': |
|
105 | - case 'xb': |
|
106 | - case 'a': |
|
107 | - case 'ab': |
|
108 | - $preHooks[] = 'preWrite'; |
|
109 | - $postHooks[] = 'postWrite'; |
|
110 | - $requiredPermissions |= \OCP\Constants::PERMISSION_UPDATE; |
|
111 | - break; |
|
112 | - } |
|
83 | + /** |
|
84 | + * @param string $mode |
|
85 | + * @return resource|false |
|
86 | + * @throws NotPermittedException |
|
87 | + * @throws LockedException |
|
88 | + */ |
|
89 | + public function fopen($mode) { |
|
90 | + $preHooks = []; |
|
91 | + $postHooks = []; |
|
92 | + $requiredPermissions = \OCP\Constants::PERMISSION_READ; |
|
93 | + switch ($mode) { |
|
94 | + case 'r+': |
|
95 | + case 'rb+': |
|
96 | + case 'w+': |
|
97 | + case 'wb+': |
|
98 | + case 'x+': |
|
99 | + case 'xb+': |
|
100 | + case 'a+': |
|
101 | + case 'ab+': |
|
102 | + case 'w': |
|
103 | + case 'wb': |
|
104 | + case 'x': |
|
105 | + case 'xb': |
|
106 | + case 'a': |
|
107 | + case 'ab': |
|
108 | + $preHooks[] = 'preWrite'; |
|
109 | + $postHooks[] = 'postWrite'; |
|
110 | + $requiredPermissions |= \OCP\Constants::PERMISSION_UPDATE; |
|
111 | + break; |
|
112 | + } |
|
113 | 113 | |
114 | - if ($this->checkPermissions($requiredPermissions)) { |
|
115 | - $this->sendHooks($preHooks); |
|
116 | - $result = $this->view->fopen($this->path, $mode); |
|
117 | - $this->sendHooks($postHooks); |
|
118 | - return $result; |
|
119 | - } else { |
|
120 | - throw new NotPermittedException(); |
|
121 | - } |
|
122 | - } |
|
114 | + if ($this->checkPermissions($requiredPermissions)) { |
|
115 | + $this->sendHooks($preHooks); |
|
116 | + $result = $this->view->fopen($this->path, $mode); |
|
117 | + $this->sendHooks($postHooks); |
|
118 | + return $result; |
|
119 | + } else { |
|
120 | + throw new NotPermittedException(); |
|
121 | + } |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * @throws NotPermittedException |
|
126 | - * @throws \OCP\Files\InvalidPathException |
|
127 | - * @throws \OCP\Files\NotFoundException |
|
128 | - */ |
|
129 | - public function delete() { |
|
130 | - if ($this->checkPermissions(\OCP\Constants::PERMISSION_DELETE)) { |
|
131 | - $this->sendHooks(['preDelete']); |
|
132 | - $fileInfo = $this->getFileInfo(); |
|
133 | - $this->view->unlink($this->path); |
|
134 | - $nonExisting = new NonExistingFile($this->root, $this->view, $this->path, $fileInfo); |
|
135 | - $this->sendHooks(['postDelete'], [$nonExisting]); |
|
136 | - $this->fileInfo = null; |
|
137 | - } else { |
|
138 | - throw new NotPermittedException(); |
|
139 | - } |
|
140 | - } |
|
124 | + /** |
|
125 | + * @throws NotPermittedException |
|
126 | + * @throws \OCP\Files\InvalidPathException |
|
127 | + * @throws \OCP\Files\NotFoundException |
|
128 | + */ |
|
129 | + public function delete() { |
|
130 | + if ($this->checkPermissions(\OCP\Constants::PERMISSION_DELETE)) { |
|
131 | + $this->sendHooks(['preDelete']); |
|
132 | + $fileInfo = $this->getFileInfo(); |
|
133 | + $this->view->unlink($this->path); |
|
134 | + $nonExisting = new NonExistingFile($this->root, $this->view, $this->path, $fileInfo); |
|
135 | + $this->sendHooks(['postDelete'], [$nonExisting]); |
|
136 | + $this->fileInfo = null; |
|
137 | + } else { |
|
138 | + throw new NotPermittedException(); |
|
139 | + } |
|
140 | + } |
|
141 | 141 | |
142 | - /** |
|
143 | - * @param string $type |
|
144 | - * @param bool $raw |
|
145 | - * @return string |
|
146 | - */ |
|
147 | - public function hash($type, $raw = false) { |
|
148 | - return $this->view->hash($type, $this->path, $raw); |
|
149 | - } |
|
142 | + /** |
|
143 | + * @param string $type |
|
144 | + * @param bool $raw |
|
145 | + * @return string |
|
146 | + */ |
|
147 | + public function hash($type, $raw = false) { |
|
148 | + return $this->view->hash($type, $this->path, $raw); |
|
149 | + } |
|
150 | 150 | |
151 | - /** |
|
152 | - * @inheritdoc |
|
153 | - */ |
|
154 | - public function getChecksum() { |
|
155 | - return $this->getFileInfo()->getChecksum(); |
|
156 | - } |
|
151 | + /** |
|
152 | + * @inheritdoc |
|
153 | + */ |
|
154 | + public function getChecksum() { |
|
155 | + return $this->getFileInfo()->getChecksum(); |
|
156 | + } |
|
157 | 157 | |
158 | - public function getExtension(): string { |
|
159 | - return $this->getFileInfo()->getExtension(); |
|
160 | - } |
|
158 | + public function getExtension(): string { |
|
159 | + return $this->getFileInfo()->getExtension(); |
|
160 | + } |
|
161 | 161 | } |
@@ -30,26 +30,26 @@ |
||
30 | 30 | use Sabre\DAV\Server; |
31 | 31 | |
32 | 32 | class TooManyRequests extends NotAuthenticated { |
33 | - public const NS_OWNCLOUD = 'http://owncloud.org/ns'; |
|
34 | - |
|
35 | - public function getHTTPCode() { |
|
36 | - return 429; |
|
37 | - } |
|
38 | - |
|
39 | - /** |
|
40 | - * This method allows the exception to include additional information |
|
41 | - * into the WebDAV error response |
|
42 | - * |
|
43 | - * @param Server $server |
|
44 | - * @param DOMElement $errorNode |
|
45 | - * @return void |
|
46 | - */ |
|
47 | - public function serialize(Server $server, DOMElement $errorNode) { |
|
48 | - |
|
49 | - // set ownCloud namespace |
|
50 | - $errorNode->setAttribute('xmlns:o', self::NS_OWNCLOUD); |
|
51 | - |
|
52 | - $error = $errorNode->ownerDocument->createElementNS('o:', 'o:hint', 'too many requests'); |
|
53 | - $errorNode->appendChild($error); |
|
54 | - } |
|
33 | + public const NS_OWNCLOUD = 'http://owncloud.org/ns'; |
|
34 | + |
|
35 | + public function getHTTPCode() { |
|
36 | + return 429; |
|
37 | + } |
|
38 | + |
|
39 | + /** |
|
40 | + * This method allows the exception to include additional information |
|
41 | + * into the WebDAV error response |
|
42 | + * |
|
43 | + * @param Server $server |
|
44 | + * @param DOMElement $errorNode |
|
45 | + * @return void |
|
46 | + */ |
|
47 | + public function serialize(Server $server, DOMElement $errorNode) { |
|
48 | + |
|
49 | + // set ownCloud namespace |
|
50 | + $errorNode->setAttribute('xmlns:o', self::NS_OWNCLOUD); |
|
51 | + |
|
52 | + $error = $errorNode->ownerDocument->createElementNS('o:', 'o:hint', 'too many requests'); |
|
53 | + $errorNode->appendChild($error); |
|
54 | + } |
|
55 | 55 | } |