@@ -32,23 +32,23 @@ |
||
32 | 32 | |
33 | 33 | class Version2200Date20210805101925 extends SimpleMigrationStep { |
34 | 34 | |
35 | - /** |
|
36 | - * @param IOutput $output |
|
37 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
38 | - * @param array $options |
|
39 | - * @return null|ISchemaWrapper |
|
40 | - */ |
|
41 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
42 | - /** @var ISchemaWrapper $schema */ |
|
43 | - $schema = $schemaClosure(); |
|
35 | + /** |
|
36 | + * @param IOutput $output |
|
37 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
38 | + * @param array $options |
|
39 | + * @return null|ISchemaWrapper |
|
40 | + */ |
|
41 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
42 | + /** @var ISchemaWrapper $schema */ |
|
43 | + $schema = $schemaClosure(); |
|
44 | 44 | |
45 | - if ($schema->hasTable('flow_operations')) { |
|
46 | - $table = $schema->getTable('flow_operations'); |
|
47 | - $table->changeColumn('name', [ |
|
48 | - 'notnull' => false, |
|
49 | - ]); |
|
50 | - } |
|
45 | + if ($schema->hasTable('flow_operations')) { |
|
46 | + $table = $schema->getTable('flow_operations'); |
|
47 | + $table->changeColumn('name', [ |
|
48 | + 'notnull' => false, |
|
49 | + ]); |
|
50 | + } |
|
51 | 51 | |
52 | - return $schema; |
|
53 | - } |
|
52 | + return $schema; |
|
53 | + } |
|
54 | 54 | } |
@@ -26,102 +26,102 @@ |
||
26 | 26 | use OCP\IUser; |
27 | 27 | |
28 | 28 | class TrashManager implements ITrashManager { |
29 | - /** @var ITrashBackend[] */ |
|
30 | - private $backends = []; |
|
29 | + /** @var ITrashBackend[] */ |
|
30 | + private $backends = []; |
|
31 | 31 | |
32 | - private $trashPaused = false; |
|
32 | + private $trashPaused = false; |
|
33 | 33 | |
34 | - public function registerBackend(string $storageType, ITrashBackend $backend) { |
|
35 | - $this->backends[$storageType] = $backend; |
|
36 | - } |
|
34 | + public function registerBackend(string $storageType, ITrashBackend $backend) { |
|
35 | + $this->backends[$storageType] = $backend; |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * @return ITrashBackend[] |
|
40 | - */ |
|
41 | - private function getBackends(): array { |
|
42 | - return $this->backends; |
|
43 | - } |
|
38 | + /** |
|
39 | + * @return ITrashBackend[] |
|
40 | + */ |
|
41 | + private function getBackends(): array { |
|
42 | + return $this->backends; |
|
43 | + } |
|
44 | 44 | |
45 | - public function listTrashRoot(IUser $user): array { |
|
46 | - $items = array_reduce($this->getBackends(), function (array $items, ITrashBackend $backend) use ($user) { |
|
47 | - return array_merge($items, $backend->listTrashRoot($user)); |
|
48 | - }, []); |
|
49 | - usort($items, function (ITrashItem $a, ITrashItem $b) { |
|
50 | - return $b->getDeletedTime() - $a->getDeletedTime(); |
|
51 | - }); |
|
52 | - return $items; |
|
53 | - } |
|
45 | + public function listTrashRoot(IUser $user): array { |
|
46 | + $items = array_reduce($this->getBackends(), function (array $items, ITrashBackend $backend) use ($user) { |
|
47 | + return array_merge($items, $backend->listTrashRoot($user)); |
|
48 | + }, []); |
|
49 | + usort($items, function (ITrashItem $a, ITrashItem $b) { |
|
50 | + return $b->getDeletedTime() - $a->getDeletedTime(); |
|
51 | + }); |
|
52 | + return $items; |
|
53 | + } |
|
54 | 54 | |
55 | - private function getBackendForItem(ITrashItem $item) { |
|
56 | - return $item->getTrashBackend(); |
|
57 | - } |
|
55 | + private function getBackendForItem(ITrashItem $item) { |
|
56 | + return $item->getTrashBackend(); |
|
57 | + } |
|
58 | 58 | |
59 | - public function listTrashFolder(ITrashItem $folder): array { |
|
60 | - return $this->getBackendForItem($folder)->listTrashFolder($folder); |
|
61 | - } |
|
59 | + public function listTrashFolder(ITrashItem $folder): array { |
|
60 | + return $this->getBackendForItem($folder)->listTrashFolder($folder); |
|
61 | + } |
|
62 | 62 | |
63 | - public function restoreItem(ITrashItem $item) { |
|
64 | - return $this->getBackendForItem($item)->restoreItem($item); |
|
65 | - } |
|
63 | + public function restoreItem(ITrashItem $item) { |
|
64 | + return $this->getBackendForItem($item)->restoreItem($item); |
|
65 | + } |
|
66 | 66 | |
67 | - public function removeItem(ITrashItem $item) { |
|
68 | - $this->getBackendForItem($item)->removeItem($item); |
|
69 | - } |
|
67 | + public function removeItem(ITrashItem $item) { |
|
68 | + $this->getBackendForItem($item)->removeItem($item); |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @param IStorage $storage |
|
73 | - * @return ITrashBackend |
|
74 | - * @throws BackendNotFoundException |
|
75 | - */ |
|
76 | - public function getBackendForStorage(IStorage $storage): ITrashBackend { |
|
77 | - $fullType = get_class($storage); |
|
78 | - $foundType = array_reduce(array_keys($this->backends), function ($type, $registeredType) use ($storage) { |
|
79 | - if ( |
|
80 | - $storage->instanceOfStorage($registeredType) && |
|
81 | - ($type === '' || is_subclass_of($registeredType, $type)) |
|
82 | - ) { |
|
83 | - return $registeredType; |
|
84 | - } else { |
|
85 | - return $type; |
|
86 | - } |
|
87 | - }, ''); |
|
88 | - if ($foundType === '') { |
|
89 | - throw new BackendNotFoundException("Trash backend for $fullType not found"); |
|
90 | - } else { |
|
91 | - return $this->backends[$foundType]; |
|
92 | - } |
|
93 | - } |
|
71 | + /** |
|
72 | + * @param IStorage $storage |
|
73 | + * @return ITrashBackend |
|
74 | + * @throws BackendNotFoundException |
|
75 | + */ |
|
76 | + public function getBackendForStorage(IStorage $storage): ITrashBackend { |
|
77 | + $fullType = get_class($storage); |
|
78 | + $foundType = array_reduce(array_keys($this->backends), function ($type, $registeredType) use ($storage) { |
|
79 | + if ( |
|
80 | + $storage->instanceOfStorage($registeredType) && |
|
81 | + ($type === '' || is_subclass_of($registeredType, $type)) |
|
82 | + ) { |
|
83 | + return $registeredType; |
|
84 | + } else { |
|
85 | + return $type; |
|
86 | + } |
|
87 | + }, ''); |
|
88 | + if ($foundType === '') { |
|
89 | + throw new BackendNotFoundException("Trash backend for $fullType not found"); |
|
90 | + } else { |
|
91 | + return $this->backends[$foundType]; |
|
92 | + } |
|
93 | + } |
|
94 | 94 | |
95 | - public function moveToTrash(IStorage $storage, string $internalPath): bool { |
|
96 | - if ($this->trashPaused) { |
|
97 | - return false; |
|
98 | - } |
|
99 | - try { |
|
100 | - $backend = $this->getBackendForStorage($storage); |
|
101 | - $this->trashPaused = true; |
|
102 | - $result = $backend->moveToTrash($storage, $internalPath); |
|
103 | - $this->trashPaused = false; |
|
104 | - return $result; |
|
105 | - } catch (BackendNotFoundException $e) { |
|
106 | - return false; |
|
107 | - } |
|
108 | - } |
|
95 | + public function moveToTrash(IStorage $storage, string $internalPath): bool { |
|
96 | + if ($this->trashPaused) { |
|
97 | + return false; |
|
98 | + } |
|
99 | + try { |
|
100 | + $backend = $this->getBackendForStorage($storage); |
|
101 | + $this->trashPaused = true; |
|
102 | + $result = $backend->moveToTrash($storage, $internalPath); |
|
103 | + $this->trashPaused = false; |
|
104 | + return $result; |
|
105 | + } catch (BackendNotFoundException $e) { |
|
106 | + return false; |
|
107 | + } |
|
108 | + } |
|
109 | 109 | |
110 | - public function getTrashNodeById(IUser $user, int $fileId) { |
|
111 | - foreach ($this->backends as $backend) { |
|
112 | - $item = $backend->getTrashNodeById($user, $fileId); |
|
113 | - if ($item !== null) { |
|
114 | - return $item; |
|
115 | - } |
|
116 | - } |
|
117 | - return null; |
|
118 | - } |
|
110 | + public function getTrashNodeById(IUser $user, int $fileId) { |
|
111 | + foreach ($this->backends as $backend) { |
|
112 | + $item = $backend->getTrashNodeById($user, $fileId); |
|
113 | + if ($item !== null) { |
|
114 | + return $item; |
|
115 | + } |
|
116 | + } |
|
117 | + return null; |
|
118 | + } |
|
119 | 119 | |
120 | - public function pauseTrash() { |
|
121 | - $this->trashPaused = true; |
|
122 | - } |
|
120 | + public function pauseTrash() { |
|
121 | + $this->trashPaused = true; |
|
122 | + } |
|
123 | 123 | |
124 | - public function resumeTrash() { |
|
125 | - $this->trashPaused = false; |
|
126 | - } |
|
124 | + public function resumeTrash() { |
|
125 | + $this->trashPaused = false; |
|
126 | + } |
|
127 | 127 | } |
@@ -23,20 +23,20 @@ |
||
23 | 23 | namespace OCA\DAV\Connector\Sabre; |
24 | 24 | |
25 | 25 | class MtimeSanitizer { |
26 | - public static function sanitizeMtime(string $mtimeFromRequest): int { |
|
27 | - // In PHP 5.X "is_numeric" returns true for strings in hexadecimal |
|
28 | - // notation. This is no longer the case in PHP 7.X, so this check |
|
29 | - // ensures that strings with hexadecimal notations fail too in PHP 5.X. |
|
30 | - $isHexadecimal = preg_match('/^\s*0[xX]/', $mtimeFromRequest); |
|
31 | - if ($isHexadecimal || !is_numeric($mtimeFromRequest)) { |
|
32 | - throw new \InvalidArgumentException('X-OC-MTime header must be an integer (unix timestamp).'); |
|
33 | - } |
|
26 | + public static function sanitizeMtime(string $mtimeFromRequest): int { |
|
27 | + // In PHP 5.X "is_numeric" returns true for strings in hexadecimal |
|
28 | + // notation. This is no longer the case in PHP 7.X, so this check |
|
29 | + // ensures that strings with hexadecimal notations fail too in PHP 5.X. |
|
30 | + $isHexadecimal = preg_match('/^\s*0[xX]/', $mtimeFromRequest); |
|
31 | + if ($isHexadecimal || !is_numeric($mtimeFromRequest)) { |
|
32 | + throw new \InvalidArgumentException('X-OC-MTime header must be an integer (unix timestamp).'); |
|
33 | + } |
|
34 | 34 | |
35 | - // Prevent writing invalid mtime (timezone-proof) |
|
36 | - if ((int)$mtimeFromRequest <= 24 * 60 * 60) { |
|
37 | - throw new \InvalidArgumentException('X-OC-MTime header must be a valid positive integer'); |
|
38 | - } |
|
35 | + // Prevent writing invalid mtime (timezone-proof) |
|
36 | + if ((int)$mtimeFromRequest <= 24 * 60 * 60) { |
|
37 | + throw new \InvalidArgumentException('X-OC-MTime header must be a valid positive integer'); |
|
38 | + } |
|
39 | 39 | |
40 | - return (int)$mtimeFromRequest; |
|
41 | - } |
|
40 | + return (int)$mtimeFromRequest; |
|
41 | + } |
|
42 | 42 | } |
@@ -32,25 +32,25 @@ |
||
32 | 32 | use OCP\Migration\SimpleMigrationStep; |
33 | 33 | |
34 | 34 | class Version1130Date20220110154719 extends SimpleMigrationStep { |
35 | - public function getName() { |
|
36 | - return 'Drop ldap_group_mapping_backup'; |
|
37 | - } |
|
38 | - |
|
39 | - /** |
|
40 | - * @param IOutput $output |
|
41 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
42 | - * @param array $options |
|
43 | - * @return null|ISchemaWrapper |
|
44 | - */ |
|
45 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
46 | - /** @var ISchemaWrapper $schema */ |
|
47 | - $schema = $schemaClosure(); |
|
48 | - |
|
49 | - if ($schema->hasTable('ldap_group_mapping_backup')) { |
|
50 | - $schema->dropTable('ldap_group_mapping_backup'); |
|
51 | - return $schema; |
|
52 | - } |
|
53 | - |
|
54 | - return null; |
|
55 | - } |
|
35 | + public function getName() { |
|
36 | + return 'Drop ldap_group_mapping_backup'; |
|
37 | + } |
|
38 | + |
|
39 | + /** |
|
40 | + * @param IOutput $output |
|
41 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
42 | + * @param array $options |
|
43 | + * @return null|ISchemaWrapper |
|
44 | + */ |
|
45 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
46 | + /** @var ISchemaWrapper $schema */ |
|
47 | + $schema = $schemaClosure(); |
|
48 | + |
|
49 | + if ($schema->hasTable('ldap_group_mapping_backup')) { |
|
50 | + $schema->dropTable('ldap_group_mapping_backup'); |
|
51 | + return $schema; |
|
52 | + } |
|
53 | + |
|
54 | + return null; |
|
55 | + } |
|
56 | 56 | } |
@@ -30,37 +30,37 @@ |
||
30 | 30 | use OCP\Migration\SimpleMigrationStep; |
31 | 31 | |
32 | 32 | class Version24000Date20211213081604 extends SimpleMigrationStep { |
33 | - /** |
|
34 | - * @param IOutput $output |
|
35 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
36 | - * @param array $options |
|
37 | - * @return null|ISchemaWrapper |
|
38 | - */ |
|
39 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
40 | - /** @var ISchemaWrapper $schema */ |
|
41 | - $schema = $schemaClosure(); |
|
33 | + /** |
|
34 | + * @param IOutput $output |
|
35 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
36 | + * @param array $options |
|
37 | + * @return null|ISchemaWrapper |
|
38 | + */ |
|
39 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
40 | + /** @var ISchemaWrapper $schema */ |
|
41 | + $schema = $schemaClosure(); |
|
42 | 42 | |
43 | - $hasTable = $schema->hasTable('ratelimit_entries'); |
|
43 | + $hasTable = $schema->hasTable('ratelimit_entries'); |
|
44 | 44 | |
45 | - if (!$hasTable) { |
|
46 | - $table = $schema->createTable('ratelimit_entries'); |
|
47 | - $table->addColumn('id', Types::BIGINT, [ |
|
48 | - 'autoincrement' => true, |
|
49 | - 'notnull' => true, |
|
50 | - ]); |
|
51 | - $table->addColumn('hash', Types::STRING, [ |
|
52 | - 'notnull' => true, |
|
53 | - 'length' => 128, |
|
54 | - ]); |
|
55 | - $table->addColumn('delete_after', Types::DATETIME, [ |
|
56 | - 'notnull' => true, |
|
57 | - ]); |
|
58 | - $table->setPrimaryKey(['id']); |
|
59 | - $table->addIndex(['hash'], 'ratelimit_hash'); |
|
60 | - $table->addIndex(['delete_after'], 'ratelimit_delete_after'); |
|
61 | - return $schema; |
|
62 | - } |
|
45 | + if (!$hasTable) { |
|
46 | + $table = $schema->createTable('ratelimit_entries'); |
|
47 | + $table->addColumn('id', Types::BIGINT, [ |
|
48 | + 'autoincrement' => true, |
|
49 | + 'notnull' => true, |
|
50 | + ]); |
|
51 | + $table->addColumn('hash', Types::STRING, [ |
|
52 | + 'notnull' => true, |
|
53 | + 'length' => 128, |
|
54 | + ]); |
|
55 | + $table->addColumn('delete_after', Types::DATETIME, [ |
|
56 | + 'notnull' => true, |
|
57 | + ]); |
|
58 | + $table->setPrimaryKey(['id']); |
|
59 | + $table->addIndex(['hash'], 'ratelimit_hash'); |
|
60 | + $table->addIndex(['delete_after'], 'ratelimit_delete_after'); |
|
61 | + return $schema; |
|
62 | + } |
|
63 | 63 | |
64 | - return null; |
|
65 | - } |
|
64 | + return null; |
|
65 | + } |
|
66 | 66 | } |
@@ -29,22 +29,22 @@ |
||
29 | 29 | use OCP\Migration\SimpleMigrationStep; |
30 | 30 | |
31 | 31 | class Version24000Date20211213081506 extends SimpleMigrationStep { |
32 | - /** |
|
33 | - * @param IOutput $output |
|
34 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
35 | - * @param array $options |
|
36 | - * @return null|ISchemaWrapper |
|
37 | - */ |
|
38 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
39 | - /** @var ISchemaWrapper $schema */ |
|
40 | - $schema = $schemaClosure(); |
|
32 | + /** |
|
33 | + * @param IOutput $output |
|
34 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
35 | + * @param array $options |
|
36 | + * @return null|ISchemaWrapper |
|
37 | + */ |
|
38 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
39 | + /** @var ISchemaWrapper $schema */ |
|
40 | + $schema = $schemaClosure(); |
|
41 | 41 | |
42 | - $hasTable = $schema->hasTable('ratelimit_entries'); |
|
43 | - if ($hasTable) { |
|
44 | - $schema->dropTable('ratelimit_entries'); |
|
45 | - return $schema; |
|
46 | - } |
|
42 | + $hasTable = $schema->hasTable('ratelimit_entries'); |
|
43 | + if ($hasTable) { |
|
44 | + $schema->dropTable('ratelimit_entries'); |
|
45 | + return $schema; |
|
46 | + } |
|
47 | 47 | |
48 | - return null; |
|
49 | - } |
|
48 | + return null; |
|
49 | + } |
|
50 | 50 | } |
@@ -28,22 +28,22 @@ |
||
28 | 28 | use OCP\Talk\IConversationOptions; |
29 | 29 | |
30 | 30 | class ConversationOptions implements IConversationOptions { |
31 | - private bool $isPublic; |
|
31 | + private bool $isPublic; |
|
32 | 32 | |
33 | - private function __construct(bool $isPublic) { |
|
34 | - $this->isPublic = $isPublic; |
|
35 | - } |
|
33 | + private function __construct(bool $isPublic) { |
|
34 | + $this->isPublic = $isPublic; |
|
35 | + } |
|
36 | 36 | |
37 | - public static function default(): self { |
|
38 | - return new self(false); |
|
39 | - } |
|
37 | + public static function default(): self { |
|
38 | + return new self(false); |
|
39 | + } |
|
40 | 40 | |
41 | - public function setPublic(bool $isPublic = true): IConversationOptions { |
|
42 | - $this->isPublic = $isPublic; |
|
43 | - return $this; |
|
44 | - } |
|
41 | + public function setPublic(bool $isPublic = true): IConversationOptions { |
|
42 | + $this->isPublic = $isPublic; |
|
43 | + return $this; |
|
44 | + } |
|
45 | 45 | |
46 | - public function isPublic(): bool { |
|
47 | - return $this->isPublic; |
|
48 | - } |
|
46 | + public function isPublic(): bool { |
|
47 | + return $this->isPublic; |
|
48 | + } |
|
49 | 49 | } |
@@ -32,24 +32,24 @@ |
||
32 | 32 | use OCP\Migration\SimpleMigrationStep; |
33 | 33 | |
34 | 34 | class Version24000Date20220131153041 extends SimpleMigrationStep { |
35 | - /** |
|
36 | - * @param IOutput $output |
|
37 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
38 | - * @param array $options |
|
39 | - * @return null|ISchemaWrapper |
|
40 | - */ |
|
41 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
42 | - /** @var ISchemaWrapper $schema */ |
|
43 | - $schema = $schemaClosure(); |
|
35 | + /** |
|
36 | + * @param IOutput $output |
|
37 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
38 | + * @param array $options |
|
39 | + * @return null|ISchemaWrapper |
|
40 | + */ |
|
41 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
42 | + /** @var ISchemaWrapper $schema */ |
|
43 | + $schema = $schemaClosure(); |
|
44 | 44 | |
45 | - $table = $schema->getTable('jobs'); |
|
46 | - if (!$table->hasColumn('time_sensitive')) { |
|
47 | - $table->addColumn('time_sensitive', Types::SMALLINT, [ |
|
48 | - 'default' => 1, |
|
49 | - ]); |
|
50 | - $table->addIndex(['time_sensitive'], 'jobs_time_sensitive'); |
|
51 | - return $schema; |
|
52 | - } |
|
53 | - return null; |
|
54 | - } |
|
45 | + $table = $schema->getTable('jobs'); |
|
46 | + if (!$table->hasColumn('time_sensitive')) { |
|
47 | + $table->addColumn('time_sensitive', Types::SMALLINT, [ |
|
48 | + 'default' => 1, |
|
49 | + ]); |
|
50 | + $table->addIndex(['time_sensitive'], 'jobs_time_sensitive'); |
|
51 | + return $schema; |
|
52 | + } |
|
53 | + return null; |
|
54 | + } |
|
55 | 55 | } |
@@ -29,12 +29,12 @@ |
||
29 | 29 | */ |
30 | 30 | class BadGateway extends \Sabre\DAV\Exception { |
31 | 31 | |
32 | - /** |
|
33 | - * Returns the HTTP status code for this exception |
|
34 | - * |
|
35 | - * @return int |
|
36 | - */ |
|
37 | - public function getHTTPCode() { |
|
38 | - return 502; |
|
39 | - } |
|
32 | + /** |
|
33 | + * Returns the HTTP status code for this exception |
|
34 | + * |
|
35 | + * @return int |
|
36 | + */ |
|
37 | + public function getHTTPCode() { |
|
38 | + return 502; |
|
39 | + } |
|
40 | 40 | } |