Completed
Push — master ( 247b25...4111bd )
by Thomas
26:36 queued 10s
created
apps/testing/lib/Controller/LockingController.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	 */
95 95
 	protected function getPath(string $user, string $path): string {
96 96
 		$node = $this->rootFolder->getUserFolder($user)->get($path);
97
-		return 'files/' . md5($node->getStorage()->getId() . '::' . trim($node->getInternalPath(), '/'));
97
+		return 'files/'.md5($node->getStorage()->getId().'::'.trim($node->getInternalPath(), '/'));
98 98
 	}
99 99
 
100 100
 	/**
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 
126 126
 		try {
127 127
 			$lockingProvider->acquireLock($path, $type);
128
-			$this->config->setAppValue('testing', 'locking_' . $path, (string)$type);
128
+			$this->config->setAppValue('testing', 'locking_'.$path, (string) $type);
129 129
 			return new DataResponse();
130 130
 		} catch (LockedException $e) {
131 131
 			throw new OCSException('', Http::STATUS_LOCKED, $e);
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 
149 149
 		try {
150 150
 			$lockingProvider->changeLock($path, $type);
151
-			$this->config->setAppValue('testing', 'locking_' . $path, (string)$type);
151
+			$this->config->setAppValue('testing', 'locking_'.$path, (string) $type);
152 152
 			return new DataResponse();
153 153
 		} catch (LockedException $e) {
154 154
 			throw new OCSException('', Http::STATUS_LOCKED, $e);
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 
172 172
 		try {
173 173
 			$lockingProvider->releaseLock($path, $type);
174
-			$this->config->deleteAppValue('testing', 'locking_' . $path);
174
+			$this->config->deleteAppValue('testing', 'locking_'.$path);
175 175
 			return new DataResponse();
176 176
 		} catch (LockedException $e) {
177 177
 			throw new OCSException('', Http::STATUS_LOCKED, $e);
@@ -206,12 +206,12 @@  discard block
 block discarded – undo
206 206
 			if (strpos($lock, 'locking_') === 0) {
207 207
 				$path = substr($lock, strlen('locking_'));
208 208
 
209
-				if ($type === ILockingProvider::LOCK_EXCLUSIVE && (int)$this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_EXCLUSIVE) {
210
-					$lockingProvider->releaseLock($path, (int)$this->config->getAppValue('testing', $lock));
211
-				} elseif ($type === ILockingProvider::LOCK_SHARED && (int)$this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_SHARED) {
212
-					$lockingProvider->releaseLock($path, (int)$this->config->getAppValue('testing', $lock));
209
+				if ($type === ILockingProvider::LOCK_EXCLUSIVE && (int) $this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_EXCLUSIVE) {
210
+					$lockingProvider->releaseLock($path, (int) $this->config->getAppValue('testing', $lock));
211
+				} elseif ($type === ILockingProvider::LOCK_SHARED && (int) $this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_SHARED) {
212
+					$lockingProvider->releaseLock($path, (int) $this->config->getAppValue('testing', $lock));
213 213
 				} else {
214
-					$lockingProvider->releaseLock($path, (int)$this->config->getAppValue('testing', $lock));
214
+					$lockingProvider->releaseLock($path, (int) $this->config->getAppValue('testing', $lock));
215 215
 				}
216 216
 			}
217 217
 		}
Please login to merge, or discard this patch.
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -23,164 +23,164 @@
 block discarded – undo
23 23
 
24 24
 class LockingController extends OCSController {
25 25
 
26
-	/**
27
-	 * @param string $appName
28
-	 * @param IRequest $request
29
-	 * @param ILockingProvider $lockingProvider
30
-	 * @param FakeDBLockingProvider $fakeDBLockingProvider
31
-	 * @param IDBConnection $connection
32
-	 * @param IConfig $config
33
-	 * @param IRootFolder $rootFolder
34
-	 */
35
-	public function __construct(
36
-		$appName,
37
-		IRequest $request,
38
-		protected ILockingProvider $lockingProvider,
39
-		protected FakeDBLockingProvider $fakeDBLockingProvider,
40
-		protected IDBConnection $connection,
41
-		protected IConfig $config,
42
-		protected IRootFolder $rootFolder,
43
-	) {
44
-		parent::__construct($appName, $request);
45
-	}
46
-
47
-	/**
48
-	 * @throws \RuntimeException
49
-	 */
50
-	protected function getLockingProvider(): ILockingProvider {
51
-		if ($this->lockingProvider instanceof DBLockingProvider) {
52
-			return $this->fakeDBLockingProvider;
53
-		}
54
-		throw new \RuntimeException('Lock provisioning is only possible using the DBLockingProvider');
55
-	}
56
-
57
-	/**
58
-	 * @throws NotFoundException
59
-	 */
60
-	protected function getPath(string $user, string $path): string {
61
-		$node = $this->rootFolder->getUserFolder($user)->get($path);
62
-		return 'files/' . md5($node->getStorage()->getId() . '::' . trim($node->getInternalPath(), '/'));
63
-	}
64
-
65
-	/**
66
-	 * @throws OCSException
67
-	 */
68
-	public function isLockingEnabled(): DataResponse {
69
-		try {
70
-			$this->getLockingProvider();
71
-			return new DataResponse();
72
-		} catch (\RuntimeException $e) {
73
-			throw new OCSException($e->getMessage(), Http::STATUS_NOT_IMPLEMENTED, $e);
74
-		}
75
-	}
76
-
77
-	/**
78
-	 * @throws OCSException
79
-	 */
80
-	public function acquireLock(int $type, string $user, string $path): DataResponse {
81
-		try {
82
-			$path = $this->getPath($user, $path);
83
-		} catch (NoUserException $e) {
84
-			throw new OCSException('User not found', Http::STATUS_NOT_FOUND, $e);
85
-		} catch (NotFoundException $e) {
86
-			throw new OCSException('Path not found', Http::STATUS_NOT_FOUND, $e);
87
-		}
88
-
89
-		$lockingProvider = $this->getLockingProvider();
90
-
91
-		try {
92
-			$lockingProvider->acquireLock($path, $type);
93
-			$this->config->setAppValue('testing', 'locking_' . $path, (string)$type);
94
-			return new DataResponse();
95
-		} catch (LockedException $e) {
96
-			throw new OCSException('', Http::STATUS_LOCKED, $e);
97
-		}
98
-	}
99
-
100
-	/**
101
-	 * @throws OCSException
102
-	 */
103
-	public function changeLock(int $type, string $user, string $path): DataResponse {
104
-		try {
105
-			$path = $this->getPath($user, $path);
106
-		} catch (NoUserException $e) {
107
-			throw new OCSException('User not found', Http::STATUS_NOT_FOUND, $e);
108
-		} catch (NotFoundException $e) {
109
-			throw new OCSException('Path not found', Http::STATUS_NOT_FOUND, $e);
110
-		}
111
-
112
-		$lockingProvider = $this->getLockingProvider();
113
-
114
-		try {
115
-			$lockingProvider->changeLock($path, $type);
116
-			$this->config->setAppValue('testing', 'locking_' . $path, (string)$type);
117
-			return new DataResponse();
118
-		} catch (LockedException $e) {
119
-			throw new OCSException('', Http::STATUS_LOCKED, $e);
120
-		}
121
-	}
122
-
123
-	/**
124
-	 * @throws OCSException
125
-	 */
126
-	public function releaseLock(int $type, string $user, string $path): DataResponse {
127
-		try {
128
-			$path = $this->getPath($user, $path);
129
-		} catch (NoUserException $e) {
130
-			throw new OCSException('User not found', Http::STATUS_NOT_FOUND, $e);
131
-		} catch (NotFoundException $e) {
132
-			throw new OCSException('Path not found', Http::STATUS_NOT_FOUND, $e);
133
-		}
134
-
135
-		$lockingProvider = $this->getLockingProvider();
136
-
137
-		try {
138
-			$lockingProvider->releaseLock($path, $type);
139
-			$this->config->deleteAppValue('testing', 'locking_' . $path);
140
-			return new DataResponse();
141
-		} catch (LockedException $e) {
142
-			throw new OCSException('', Http::STATUS_LOCKED, $e);
143
-		}
144
-	}
145
-
146
-	/**
147
-	 * @throws OCSException
148
-	 */
149
-	public function isLocked(int $type, string $user, string $path): DataResponse {
150
-		try {
151
-			$path = $this->getPath($user, $path);
152
-		} catch (NoUserException $e) {
153
-			throw new OCSException('User not found', Http::STATUS_NOT_FOUND, $e);
154
-		} catch (NotFoundException $e) {
155
-			throw new OCSException('Path not found', Http::STATUS_NOT_FOUND, $e);
156
-		}
157
-
158
-		$lockingProvider = $this->getLockingProvider();
159
-
160
-		if ($lockingProvider->isLocked($path, $type)) {
161
-			return new DataResponse();
162
-		}
163
-
164
-		throw new OCSException('', Http::STATUS_LOCKED);
165
-	}
166
-
167
-	public function releaseAll(?int $type = null): DataResponse {
168
-		$lockingProvider = $this->getLockingProvider();
169
-
170
-		foreach ($this->config->getAppKeys('testing') as $lock) {
171
-			if (strpos($lock, 'locking_') === 0) {
172
-				$path = substr($lock, strlen('locking_'));
173
-
174
-				if ($type === ILockingProvider::LOCK_EXCLUSIVE && (int)$this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_EXCLUSIVE) {
175
-					$lockingProvider->releaseLock($path, (int)$this->config->getAppValue('testing', $lock));
176
-				} elseif ($type === ILockingProvider::LOCK_SHARED && (int)$this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_SHARED) {
177
-					$lockingProvider->releaseLock($path, (int)$this->config->getAppValue('testing', $lock));
178
-				} else {
179
-					$lockingProvider->releaseLock($path, (int)$this->config->getAppValue('testing', $lock));
180
-				}
181
-			}
182
-		}
183
-
184
-		return new DataResponse();
185
-	}
26
+    /**
27
+     * @param string $appName
28
+     * @param IRequest $request
29
+     * @param ILockingProvider $lockingProvider
30
+     * @param FakeDBLockingProvider $fakeDBLockingProvider
31
+     * @param IDBConnection $connection
32
+     * @param IConfig $config
33
+     * @param IRootFolder $rootFolder
34
+     */
35
+    public function __construct(
36
+        $appName,
37
+        IRequest $request,
38
+        protected ILockingProvider $lockingProvider,
39
+        protected FakeDBLockingProvider $fakeDBLockingProvider,
40
+        protected IDBConnection $connection,
41
+        protected IConfig $config,
42
+        protected IRootFolder $rootFolder,
43
+    ) {
44
+        parent::__construct($appName, $request);
45
+    }
46
+
47
+    /**
48
+     * @throws \RuntimeException
49
+     */
50
+    protected function getLockingProvider(): ILockingProvider {
51
+        if ($this->lockingProvider instanceof DBLockingProvider) {
52
+            return $this->fakeDBLockingProvider;
53
+        }
54
+        throw new \RuntimeException('Lock provisioning is only possible using the DBLockingProvider');
55
+    }
56
+
57
+    /**
58
+     * @throws NotFoundException
59
+     */
60
+    protected function getPath(string $user, string $path): string {
61
+        $node = $this->rootFolder->getUserFolder($user)->get($path);
62
+        return 'files/' . md5($node->getStorage()->getId() . '::' . trim($node->getInternalPath(), '/'));
63
+    }
64
+
65
+    /**
66
+     * @throws OCSException
67
+     */
68
+    public function isLockingEnabled(): DataResponse {
69
+        try {
70
+            $this->getLockingProvider();
71
+            return new DataResponse();
72
+        } catch (\RuntimeException $e) {
73
+            throw new OCSException($e->getMessage(), Http::STATUS_NOT_IMPLEMENTED, $e);
74
+        }
75
+    }
76
+
77
+    /**
78
+     * @throws OCSException
79
+     */
80
+    public function acquireLock(int $type, string $user, string $path): DataResponse {
81
+        try {
82
+            $path = $this->getPath($user, $path);
83
+        } catch (NoUserException $e) {
84
+            throw new OCSException('User not found', Http::STATUS_NOT_FOUND, $e);
85
+        } catch (NotFoundException $e) {
86
+            throw new OCSException('Path not found', Http::STATUS_NOT_FOUND, $e);
87
+        }
88
+
89
+        $lockingProvider = $this->getLockingProvider();
90
+
91
+        try {
92
+            $lockingProvider->acquireLock($path, $type);
93
+            $this->config->setAppValue('testing', 'locking_' . $path, (string)$type);
94
+            return new DataResponse();
95
+        } catch (LockedException $e) {
96
+            throw new OCSException('', Http::STATUS_LOCKED, $e);
97
+        }
98
+    }
99
+
100
+    /**
101
+     * @throws OCSException
102
+     */
103
+    public function changeLock(int $type, string $user, string $path): DataResponse {
104
+        try {
105
+            $path = $this->getPath($user, $path);
106
+        } catch (NoUserException $e) {
107
+            throw new OCSException('User not found', Http::STATUS_NOT_FOUND, $e);
108
+        } catch (NotFoundException $e) {
109
+            throw new OCSException('Path not found', Http::STATUS_NOT_FOUND, $e);
110
+        }
111
+
112
+        $lockingProvider = $this->getLockingProvider();
113
+
114
+        try {
115
+            $lockingProvider->changeLock($path, $type);
116
+            $this->config->setAppValue('testing', 'locking_' . $path, (string)$type);
117
+            return new DataResponse();
118
+        } catch (LockedException $e) {
119
+            throw new OCSException('', Http::STATUS_LOCKED, $e);
120
+        }
121
+    }
122
+
123
+    /**
124
+     * @throws OCSException
125
+     */
126
+    public function releaseLock(int $type, string $user, string $path): DataResponse {
127
+        try {
128
+            $path = $this->getPath($user, $path);
129
+        } catch (NoUserException $e) {
130
+            throw new OCSException('User not found', Http::STATUS_NOT_FOUND, $e);
131
+        } catch (NotFoundException $e) {
132
+            throw new OCSException('Path not found', Http::STATUS_NOT_FOUND, $e);
133
+        }
134
+
135
+        $lockingProvider = $this->getLockingProvider();
136
+
137
+        try {
138
+            $lockingProvider->releaseLock($path, $type);
139
+            $this->config->deleteAppValue('testing', 'locking_' . $path);
140
+            return new DataResponse();
141
+        } catch (LockedException $e) {
142
+            throw new OCSException('', Http::STATUS_LOCKED, $e);
143
+        }
144
+    }
145
+
146
+    /**
147
+     * @throws OCSException
148
+     */
149
+    public function isLocked(int $type, string $user, string $path): DataResponse {
150
+        try {
151
+            $path = $this->getPath($user, $path);
152
+        } catch (NoUserException $e) {
153
+            throw new OCSException('User not found', Http::STATUS_NOT_FOUND, $e);
154
+        } catch (NotFoundException $e) {
155
+            throw new OCSException('Path not found', Http::STATUS_NOT_FOUND, $e);
156
+        }
157
+
158
+        $lockingProvider = $this->getLockingProvider();
159
+
160
+        if ($lockingProvider->isLocked($path, $type)) {
161
+            return new DataResponse();
162
+        }
163
+
164
+        throw new OCSException('', Http::STATUS_LOCKED);
165
+    }
166
+
167
+    public function releaseAll(?int $type = null): DataResponse {
168
+        $lockingProvider = $this->getLockingProvider();
169
+
170
+        foreach ($this->config->getAppKeys('testing') as $lock) {
171
+            if (strpos($lock, 'locking_') === 0) {
172
+                $path = substr($lock, strlen('locking_'));
173
+
174
+                if ($type === ILockingProvider::LOCK_EXCLUSIVE && (int)$this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_EXCLUSIVE) {
175
+                    $lockingProvider->releaseLock($path, (int)$this->config->getAppValue('testing', $lock));
176
+                } elseif ($type === ILockingProvider::LOCK_SHARED && (int)$this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_SHARED) {
177
+                    $lockingProvider->releaseLock($path, (int)$this->config->getAppValue('testing', $lock));
178
+                } else {
179
+                    $lockingProvider->releaseLock($path, (int)$this->config->getAppValue('testing', $lock));
180
+                }
181
+            }
182
+        }
183
+
184
+        return new DataResponse();
185
+    }
186 186
 }
Please login to merge, or discard this patch.
core/Migrations/Version24000Date20211213081604.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -30,37 +30,37 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
core/Migrations/Version24000Date20211213081506.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -29,22 +29,22 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
lib/private/Talk/ConversationOptions.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -28,22 +28,22 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
core/Migrations/Version24000Date20220131153041.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -32,24 +32,24 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/Migration/Version1130Date20211102154716.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -214,7 +214,7 @@
 block discarded – undo
214 214
 
215 215
 		while ($nextcloudId = array_shift($idList)) {
216 216
 			$update->setParameter('nextcloudId', $nextcloudId);
217
-			$update->setParameter('invalidatedUuid', 'invalidated_' . \bin2hex(\random_bytes(6)));
217
+			$update->setParameter('invalidatedUuid', 'invalidated_'.\bin2hex(\random_bytes(6)));
218 218
 			try {
219 219
 				$update->executeStatement();
220 220
 				$this->logger->warning(
Please login to merge, or discard this patch.
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -22,245 +22,245 @@
 block discarded – undo
22 22
 
23 23
 class Version1130Date20211102154716 extends SimpleMigrationStep {
24 24
 
25
-	/** @var string[] */
26
-	private $hashColumnAddedToTables = [];
25
+    /** @var string[] */
26
+    private $hashColumnAddedToTables = [];
27 27
 
28
-	public function __construct(
29
-		private IDBConnection $dbc,
30
-		private LoggerInterface $logger,
31
-	) {
32
-	}
28
+    public function __construct(
29
+        private IDBConnection $dbc,
30
+        private LoggerInterface $logger,
31
+    ) {
32
+    }
33 33
 
34
-	public function getName() {
35
-		return 'Adjust LDAP user and group ldap_dn column lengths and add ldap_dn_hash columns';
36
-	}
34
+    public function getName() {
35
+        return 'Adjust LDAP user and group ldap_dn column lengths and add ldap_dn_hash columns';
36
+    }
37 37
 
38
-	public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
39
-		foreach (['ldap_user_mapping', 'ldap_group_mapping'] as $tableName) {
40
-			$this->processDuplicateUUIDs($tableName);
41
-		}
38
+    public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
39
+        foreach (['ldap_user_mapping', 'ldap_group_mapping'] as $tableName) {
40
+            $this->processDuplicateUUIDs($tableName);
41
+        }
42 42
 
43
-		/** @var ISchemaWrapper $schema */
44
-		$schema = $schemaClosure();
45
-		if ($schema->hasTable('ldap_group_mapping_backup')) {
46
-			// Previous upgrades of a broken release might have left an incomplete
47
-			// ldap_group_mapping_backup table. No need to recreate, but it
48
-			// should be empty.
49
-			// TRUNCATE is not available from Query Builder, but faster than DELETE FROM.
50
-			$sql = $this->dbc->getDatabasePlatform()->getTruncateTableSQL('`*PREFIX*ldap_group_mapping_backup`', false);
51
-			$this->dbc->executeStatement($sql);
52
-		}
53
-	}
43
+        /** @var ISchemaWrapper $schema */
44
+        $schema = $schemaClosure();
45
+        if ($schema->hasTable('ldap_group_mapping_backup')) {
46
+            // Previous upgrades of a broken release might have left an incomplete
47
+            // ldap_group_mapping_backup table. No need to recreate, but it
48
+            // should be empty.
49
+            // TRUNCATE is not available from Query Builder, but faster than DELETE FROM.
50
+            $sql = $this->dbc->getDatabasePlatform()->getTruncateTableSQL('`*PREFIX*ldap_group_mapping_backup`', false);
51
+            $this->dbc->executeStatement($sql);
52
+        }
53
+    }
54 54
 
55
-	/**
56
-	 * @param IOutput $output
57
-	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
58
-	 * @param array $options
59
-	 * @return null|ISchemaWrapper
60
-	 */
61
-	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
62
-		/** @var ISchemaWrapper $schema */
63
-		$schema = $schemaClosure();
55
+    /**
56
+     * @param IOutput $output
57
+     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
58
+     * @param array $options
59
+     * @return null|ISchemaWrapper
60
+     */
61
+    public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
62
+        /** @var ISchemaWrapper $schema */
63
+        $schema = $schemaClosure();
64 64
 
65
-		$changeSchema = false;
66
-		foreach (['ldap_user_mapping', 'ldap_group_mapping'] as $tableName) {
67
-			$table = $schema->getTable($tableName);
68
-			if (!$table->hasColumn('ldap_dn_hash')) {
69
-				$table->addColumn('ldap_dn_hash', Types::STRING, [
70
-					'notnull' => false,
71
-					'length' => 64,
72
-				]);
73
-				$changeSchema = true;
74
-				$this->hashColumnAddedToTables[] = $tableName;
75
-			}
76
-			$column = $table->getColumn('ldap_dn');
77
-			if ($tableName === 'ldap_user_mapping') {
78
-				if ($column->getLength() < 4000) {
79
-					$column->setLength(4000);
80
-					$changeSchema = true;
81
-				}
65
+        $changeSchema = false;
66
+        foreach (['ldap_user_mapping', 'ldap_group_mapping'] as $tableName) {
67
+            $table = $schema->getTable($tableName);
68
+            if (!$table->hasColumn('ldap_dn_hash')) {
69
+                $table->addColumn('ldap_dn_hash', Types::STRING, [
70
+                    'notnull' => false,
71
+                    'length' => 64,
72
+                ]);
73
+                $changeSchema = true;
74
+                $this->hashColumnAddedToTables[] = $tableName;
75
+            }
76
+            $column = $table->getColumn('ldap_dn');
77
+            if ($tableName === 'ldap_user_mapping') {
78
+                if ($column->getLength() < 4000) {
79
+                    $column->setLength(4000);
80
+                    $changeSchema = true;
81
+                }
82 82
 
83
-				if ($table->hasIndex('ldap_dn_users')) {
84
-					$table->dropIndex('ldap_dn_users');
85
-					$changeSchema = true;
86
-				}
87
-				if (!$table->hasIndex('ldap_user_dn_hashes')) {
88
-					$table->addUniqueIndex(['ldap_dn_hash'], 'ldap_user_dn_hashes');
89
-					$changeSchema = true;
90
-				}
91
-				if (!$table->hasIndex('ldap_user_directory_uuid')) {
92
-					$table->addUniqueIndex(['directory_uuid'], 'ldap_user_directory_uuid');
93
-					$changeSchema = true;
94
-				}
95
-			} elseif (!$schema->hasTable('ldap_group_mapping_backup')) {
96
-				// We need to copy the table twice to be able to change primary key, prepare the backup table
97
-				$table2 = $schema->createTable('ldap_group_mapping_backup');
98
-				$table2->addColumn('ldap_dn', Types::STRING, [
99
-					'notnull' => true,
100
-					'length' => 4000,
101
-					'default' => '',
102
-				]);
103
-				$table2->addColumn('owncloud_name', Types::STRING, [
104
-					'notnull' => true,
105
-					'length' => 64,
106
-					'default' => '',
107
-				]);
108
-				$table2->addColumn('directory_uuid', Types::STRING, [
109
-					'notnull' => true,
110
-					'length' => 255,
111
-					'default' => '',
112
-				]);
113
-				$table2->addColumn('ldap_dn_hash', Types::STRING, [
114
-					'notnull' => false,
115
-					'length' => 64,
116
-				]);
117
-				$table2->setPrimaryKey(['owncloud_name'], 'lgm_backup_primary');
118
-				$changeSchema = true;
119
-			}
120
-		}
83
+                if ($table->hasIndex('ldap_dn_users')) {
84
+                    $table->dropIndex('ldap_dn_users');
85
+                    $changeSchema = true;
86
+                }
87
+                if (!$table->hasIndex('ldap_user_dn_hashes')) {
88
+                    $table->addUniqueIndex(['ldap_dn_hash'], 'ldap_user_dn_hashes');
89
+                    $changeSchema = true;
90
+                }
91
+                if (!$table->hasIndex('ldap_user_directory_uuid')) {
92
+                    $table->addUniqueIndex(['directory_uuid'], 'ldap_user_directory_uuid');
93
+                    $changeSchema = true;
94
+                }
95
+            } elseif (!$schema->hasTable('ldap_group_mapping_backup')) {
96
+                // We need to copy the table twice to be able to change primary key, prepare the backup table
97
+                $table2 = $schema->createTable('ldap_group_mapping_backup');
98
+                $table2->addColumn('ldap_dn', Types::STRING, [
99
+                    'notnull' => true,
100
+                    'length' => 4000,
101
+                    'default' => '',
102
+                ]);
103
+                $table2->addColumn('owncloud_name', Types::STRING, [
104
+                    'notnull' => true,
105
+                    'length' => 64,
106
+                    'default' => '',
107
+                ]);
108
+                $table2->addColumn('directory_uuid', Types::STRING, [
109
+                    'notnull' => true,
110
+                    'length' => 255,
111
+                    'default' => '',
112
+                ]);
113
+                $table2->addColumn('ldap_dn_hash', Types::STRING, [
114
+                    'notnull' => false,
115
+                    'length' => 64,
116
+                ]);
117
+                $table2->setPrimaryKey(['owncloud_name'], 'lgm_backup_primary');
118
+                $changeSchema = true;
119
+            }
120
+        }
121 121
 
122
-		return $changeSchema ? $schema : null;
123
-	}
122
+        return $changeSchema ? $schema : null;
123
+    }
124 124
 
125
-	/**
126
-	 * @param IOutput $output
127
-	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
128
-	 * @param array $options
129
-	 */
130
-	public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
131
-		$this->handleDNHashes('ldap_group_mapping');
132
-		$this->handleDNHashes('ldap_user_mapping');
133
-	}
125
+    /**
126
+     * @param IOutput $output
127
+     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
128
+     * @param array $options
129
+     */
130
+    public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
131
+        $this->handleDNHashes('ldap_group_mapping');
132
+        $this->handleDNHashes('ldap_user_mapping');
133
+    }
134 134
 
135
-	protected function handleDNHashes(string $table): void {
136
-		$select = $this->getSelectQuery($table);
137
-		$update = $this->getUpdateQuery($table);
135
+    protected function handleDNHashes(string $table): void {
136
+        $select = $this->getSelectQuery($table);
137
+        $update = $this->getUpdateQuery($table);
138 138
 
139
-		$result = $select->executeQuery();
140
-		while ($row = $result->fetch()) {
141
-			$dnHash = hash('sha256', $row['ldap_dn'], false);
142
-			$update->setParameter('name', $row['owncloud_name']);
143
-			$update->setParameter('dn_hash', $dnHash);
144
-			try {
145
-				$update->executeStatement();
146
-			} catch (Exception $e) {
147
-				$this->logger->error('Failed to add hash "{dnHash}" ("{name}" of {table})',
148
-					[
149
-						'app' => 'user_ldap',
150
-						'name' => $row['owncloud_name'],
151
-						'dnHash' => $dnHash,
152
-						'table' => $table,
153
-						'exception' => $e,
154
-					]
155
-				);
156
-			}
157
-		}
158
-		$result->closeCursor();
159
-	}
139
+        $result = $select->executeQuery();
140
+        while ($row = $result->fetch()) {
141
+            $dnHash = hash('sha256', $row['ldap_dn'], false);
142
+            $update->setParameter('name', $row['owncloud_name']);
143
+            $update->setParameter('dn_hash', $dnHash);
144
+            try {
145
+                $update->executeStatement();
146
+            } catch (Exception $e) {
147
+                $this->logger->error('Failed to add hash "{dnHash}" ("{name}" of {table})',
148
+                    [
149
+                        'app' => 'user_ldap',
150
+                        'name' => $row['owncloud_name'],
151
+                        'dnHash' => $dnHash,
152
+                        'table' => $table,
153
+                        'exception' => $e,
154
+                    ]
155
+                );
156
+            }
157
+        }
158
+        $result->closeCursor();
159
+    }
160 160
 
161
-	protected function getSelectQuery(string $table): IQueryBuilder {
162
-		$qb = $this->dbc->getQueryBuilder();
163
-		$qb->select('owncloud_name', 'ldap_dn')
164
-			->from($table);
161
+    protected function getSelectQuery(string $table): IQueryBuilder {
162
+        $qb = $this->dbc->getQueryBuilder();
163
+        $qb->select('owncloud_name', 'ldap_dn')
164
+            ->from($table);
165 165
 
166
-		// when added we may run into risk that it's read from a DB node
167
-		// where the column is not present. Then the where clause is also
168
-		// not necessary since all rows qualify.
169
-		if (!in_array($table, $this->hashColumnAddedToTables, true)) {
170
-			$qb->where($qb->expr()->isNull('ldap_dn_hash'));
171
-		}
166
+        // when added we may run into risk that it's read from a DB node
167
+        // where the column is not present. Then the where clause is also
168
+        // not necessary since all rows qualify.
169
+        if (!in_array($table, $this->hashColumnAddedToTables, true)) {
170
+            $qb->where($qb->expr()->isNull('ldap_dn_hash'));
171
+        }
172 172
 
173
-		return $qb;
174
-	}
173
+        return $qb;
174
+    }
175 175
 
176
-	protected function getUpdateQuery(string $table): IQueryBuilder {
177
-		$qb = $this->dbc->getQueryBuilder();
178
-		$qb->update($table)
179
-			->set('ldap_dn_hash', $qb->createParameter('dn_hash'))
180
-			->where($qb->expr()->eq('owncloud_name', $qb->createParameter('name')));
181
-		return $qb;
182
-	}
176
+    protected function getUpdateQuery(string $table): IQueryBuilder {
177
+        $qb = $this->dbc->getQueryBuilder();
178
+        $qb->update($table)
179
+            ->set('ldap_dn_hash', $qb->createParameter('dn_hash'))
180
+            ->where($qb->expr()->eq('owncloud_name', $qb->createParameter('name')));
181
+        return $qb;
182
+    }
183 183
 
184
-	/**
185
-	 * @throws Exception
186
-	 */
187
-	protected function processDuplicateUUIDs(string $table): void {
188
-		$uuids = $this->getDuplicatedUuids($table);
189
-		$idsWithUuidToInvalidate = [];
190
-		foreach ($uuids as $uuid) {
191
-			array_push($idsWithUuidToInvalidate, ...$this->getNextcloudIdsByUuid($table, $uuid));
192
-		}
193
-		$this->invalidateUuids($table, $idsWithUuidToInvalidate);
194
-	}
184
+    /**
185
+     * @throws Exception
186
+     */
187
+    protected function processDuplicateUUIDs(string $table): void {
188
+        $uuids = $this->getDuplicatedUuids($table);
189
+        $idsWithUuidToInvalidate = [];
190
+        foreach ($uuids as $uuid) {
191
+            array_push($idsWithUuidToInvalidate, ...$this->getNextcloudIdsByUuid($table, $uuid));
192
+        }
193
+        $this->invalidateUuids($table, $idsWithUuidToInvalidate);
194
+    }
195 195
 
196
-	/**
197
-	 * @throws Exception
198
-	 */
199
-	protected function invalidateUuids(string $table, array $idList): void {
200
-		$update = $this->dbc->getQueryBuilder();
201
-		$update->update($table)
202
-			->set('directory_uuid', $update->createParameter('invalidatedUuid'))
203
-			->where($update->expr()->eq('owncloud_name', $update->createParameter('nextcloudId')));
196
+    /**
197
+     * @throws Exception
198
+     */
199
+    protected function invalidateUuids(string $table, array $idList): void {
200
+        $update = $this->dbc->getQueryBuilder();
201
+        $update->update($table)
202
+            ->set('directory_uuid', $update->createParameter('invalidatedUuid'))
203
+            ->where($update->expr()->eq('owncloud_name', $update->createParameter('nextcloudId')));
204 204
 
205
-		while ($nextcloudId = array_shift($idList)) {
206
-			$update->setParameter('nextcloudId', $nextcloudId);
207
-			$update->setParameter('invalidatedUuid', 'invalidated_' . \bin2hex(\random_bytes(6)));
208
-			try {
209
-				$update->executeStatement();
210
-				$this->logger->warning(
211
-					'LDAP user or group with ID {nid} has a duplicated UUID value which therefore was invalidated. You may double-check your LDAP configuration and trigger an update of the UUID.',
212
-					[
213
-						'app' => 'user_ldap',
214
-						'nid' => $nextcloudId,
215
-					]
216
-				);
217
-			} catch (Exception $e) {
218
-				// Catch possible, but unlikely duplications if new invalidated errors.
219
-				// There is the theoretical chance of an infinity loop is, when
220
-				// the constraint violation has a different background. I cannot
221
-				// think of one at the moment.
222
-				if ($e->getReason() !== Exception::REASON_CONSTRAINT_VIOLATION) {
223
-					throw $e;
224
-				}
225
-				$idList[] = $nextcloudId;
226
-			}
227
-		}
228
-	}
205
+        while ($nextcloudId = array_shift($idList)) {
206
+            $update->setParameter('nextcloudId', $nextcloudId);
207
+            $update->setParameter('invalidatedUuid', 'invalidated_' . \bin2hex(\random_bytes(6)));
208
+            try {
209
+                $update->executeStatement();
210
+                $this->logger->warning(
211
+                    'LDAP user or group with ID {nid} has a duplicated UUID value which therefore was invalidated. You may double-check your LDAP configuration and trigger an update of the UUID.',
212
+                    [
213
+                        'app' => 'user_ldap',
214
+                        'nid' => $nextcloudId,
215
+                    ]
216
+                );
217
+            } catch (Exception $e) {
218
+                // Catch possible, but unlikely duplications if new invalidated errors.
219
+                // There is the theoretical chance of an infinity loop is, when
220
+                // the constraint violation has a different background. I cannot
221
+                // think of one at the moment.
222
+                if ($e->getReason() !== Exception::REASON_CONSTRAINT_VIOLATION) {
223
+                    throw $e;
224
+                }
225
+                $idList[] = $nextcloudId;
226
+            }
227
+        }
228
+    }
229 229
 
230
-	/**
231
-	 * @throws \OCP\DB\Exception
232
-	 * @return array<string>
233
-	 */
234
-	protected function getNextcloudIdsByUuid(string $table, string $uuid): array {
235
-		$select = $this->dbc->getQueryBuilder();
236
-		$select->select('owncloud_name')
237
-			->from($table)
238
-			->where($select->expr()->eq('directory_uuid', $select->createNamedParameter($uuid)));
230
+    /**
231
+     * @throws \OCP\DB\Exception
232
+     * @return array<string>
233
+     */
234
+    protected function getNextcloudIdsByUuid(string $table, string $uuid): array {
235
+        $select = $this->dbc->getQueryBuilder();
236
+        $select->select('owncloud_name')
237
+            ->from($table)
238
+            ->where($select->expr()->eq('directory_uuid', $select->createNamedParameter($uuid)));
239 239
 
240
-		$result = $select->executeQuery();
241
-		$idList = [];
242
-		while (($id = $result->fetchOne()) !== false) {
243
-			$idList[] = $id;
244
-		}
245
-		$result->closeCursor();
246
-		return $idList;
247
-	}
240
+        $result = $select->executeQuery();
241
+        $idList = [];
242
+        while (($id = $result->fetchOne()) !== false) {
243
+            $idList[] = $id;
244
+        }
245
+        $result->closeCursor();
246
+        return $idList;
247
+    }
248 248
 
249
-	/**
250
-	 * @return Generator<string>
251
-	 * @throws \OCP\DB\Exception
252
-	 */
253
-	protected function getDuplicatedUuids(string $table): Generator {
254
-		$select = $this->dbc->getQueryBuilder();
255
-		$select->select('directory_uuid')
256
-			->from($table)
257
-			->groupBy('directory_uuid')
258
-			->having($select->expr()->gt($select->func()->count('owncloud_name'), $select->createNamedParameter(1)));
249
+    /**
250
+     * @return Generator<string>
251
+     * @throws \OCP\DB\Exception
252
+     */
253
+    protected function getDuplicatedUuids(string $table): Generator {
254
+        $select = $this->dbc->getQueryBuilder();
255
+        $select->select('directory_uuid')
256
+            ->from($table)
257
+            ->groupBy('directory_uuid')
258
+            ->having($select->expr()->gt($select->func()->count('owncloud_name'), $select->createNamedParameter(1)));
259 259
 
260
-		$result = $select->executeQuery();
261
-		while (($uuid = $result->fetchOne()) !== false) {
262
-			yield $uuid;
263
-		}
264
-		$result->closeCursor();
265
-	}
260
+        $result = $select->executeQuery();
261
+        while (($uuid = $result->fetchOne()) !== false) {
262
+            yield $uuid;
263
+        }
264
+        $result->closeCursor();
265
+    }
266 266
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/Exception/BadGateway.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,12 +29,12 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
lib/private/Files/Config/CachedMountFileInfo.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,6 +53,6 @@
 block discarded – undo
53 53
 	}
54 54
 
55 55
 	public function getPath(): string {
56
-		return $this->getMountPoint() . $this->getInternalPath();
56
+		return $this->getMountPoint().$this->getInternalPath();
57 57
 	}
58 58
 }
Please login to merge, or discard this patch.
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -9,31 +9,31 @@
 block discarded – undo
9 9
 use OCP\IUser;
10 10
 
11 11
 class CachedMountFileInfo extends CachedMountInfo implements ICachedMountFileInfo {
12
-	private string $internalPath;
12
+    private string $internalPath;
13 13
 
14
-	public function __construct(
15
-		IUser $user,
16
-		int $storageId,
17
-		int $rootId,
18
-		string $mountPoint,
19
-		?int $mountId,
20
-		string $mountProvider,
21
-		string $rootInternalPath,
22
-		string $internalPath,
23
-	) {
24
-		parent::__construct($user, $storageId, $rootId, $mountPoint, $mountProvider, $mountId, $rootInternalPath);
25
-		$this->internalPath = $internalPath;
26
-	}
14
+    public function __construct(
15
+        IUser $user,
16
+        int $storageId,
17
+        int $rootId,
18
+        string $mountPoint,
19
+        ?int $mountId,
20
+        string $mountProvider,
21
+        string $rootInternalPath,
22
+        string $internalPath,
23
+    ) {
24
+        parent::__construct($user, $storageId, $rootId, $mountPoint, $mountProvider, $mountId, $rootInternalPath);
25
+        $this->internalPath = $internalPath;
26
+    }
27 27
 
28
-	public function getInternalPath(): string {
29
-		if ($this->getRootInternalPath()) {
30
-			return substr($this->internalPath, strlen($this->getRootInternalPath()) + 1);
31
-		} else {
32
-			return $this->internalPath;
33
-		}
34
-	}
28
+    public function getInternalPath(): string {
29
+        if ($this->getRootInternalPath()) {
30
+            return substr($this->internalPath, strlen($this->getRootInternalPath()) + 1);
31
+        } else {
32
+            return $this->internalPath;
33
+        }
34
+    }
35 35
 
36
-	public function getPath(): string {
37
-		return $this->getMountPoint() . $this->getInternalPath();
38
-	}
36
+    public function getPath(): string {
37
+        return $this->getMountPoint() . $this->getInternalPath();
38
+    }
39 39
 }
Please login to merge, or discard this patch.
lib/private/Files/Mount/ObjectStorePreviewCacheMountProvider.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 			foreach ($directoryRange as $child) {
68 68
 				$mountPoints[] = new MountPoint(
69 69
 					AppdataPreviewObjectStoreStorage::class,
70
-					'/appdata_' . $instanceId . '/preview/' . $parent . '/' . $child,
70
+					'/appdata_'.$instanceId.'/preview/'.$parent.'/'.$child,
71 71
 					$this->getMultiBucketObjectStore($i),
72 72
 					$loader,
73 73
 					null,
@@ -82,13 +82,13 @@  discard block
 block discarded – undo
82 82
 		$fakeRootStorage = new ObjectStoreStorage($rootStorageArguments);
83 83
 		$fakeRootStorageJail = new Jail([
84 84
 			'storage' => $fakeRootStorage,
85
-			'root' => '/appdata_' . $instanceId . '/preview',
85
+			'root' => '/appdata_'.$instanceId.'/preview',
86 86
 		]);
87 87
 
88 88
 		// add a fallback location to be able to fetch existing previews from the old bucket
89 89
 		$mountPoints[] = new MountPoint(
90 90
 			$fakeRootStorageJail,
91
-			'/appdata_' . $instanceId . '/preview/old-multibucket',
91
+			'/appdata_'.$instanceId.'/preview/old-multibucket',
92 92
 			null,
93 93
 			$loader,
94 94
 			null,
Please login to merge, or discard this patch.
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -37,119 +37,119 @@
 block discarded – undo
37 37
  * Mount provider for object store app data folder for previews
38 38
  */
39 39
 class ObjectStorePreviewCacheMountProvider implements IRootMountProvider {
40
-	private LoggerInterface $logger;
41
-	/** @var IConfig */
42
-	private $config;
43
-
44
-	public function __construct(LoggerInterface $logger, IConfig $config) {
45
-		$this->logger = $logger;
46
-		$this->config = $config;
47
-	}
48
-
49
-	/**
50
-	 * @return MountPoint[]
51
-	 * @throws \Exception
52
-	 */
53
-	public function getRootMounts(IStorageFactory $loader): array {
54
-		if (!is_array($this->config->getSystemValue('objectstore_multibucket'))) {
55
-			return [];
56
-		}
57
-		if ($this->config->getSystemValue('objectstore.multibucket.preview-distribution', false) !== true) {
58
-			return [];
59
-		}
60
-
61
-		$instanceId = $this->config->getSystemValueString('instanceid', '');
62
-		$mountPoints = [];
63
-		$directoryRange = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
64
-		$i = 0;
65
-		foreach ($directoryRange as $parent) {
66
-			foreach ($directoryRange as $child) {
67
-				$mountPoints[] = new MountPoint(
68
-					AppdataPreviewObjectStoreStorage::class,
69
-					'/appdata_' . $instanceId . '/preview/' . $parent . '/' . $child,
70
-					$this->getMultiBucketObjectStore($i),
71
-					$loader,
72
-					null,
73
-					null,
74
-					self::class
75
-				);
76
-				$i++;
77
-			}
78
-		}
79
-
80
-		$rootStorageArguments = $this->getMultiBucketObjectStoreForRoot();
81
-		$fakeRootStorage = new ObjectStoreStorage($rootStorageArguments);
82
-		$fakeRootStorageJail = new Jail([
83
-			'storage' => $fakeRootStorage,
84
-			'root' => '/appdata_' . $instanceId . '/preview',
85
-		]);
86
-
87
-		// add a fallback location to be able to fetch existing previews from the old bucket
88
-		$mountPoints[] = new MountPoint(
89
-			$fakeRootStorageJail,
90
-			'/appdata_' . $instanceId . '/preview/old-multibucket',
91
-			null,
92
-			$loader,
93
-			null,
94
-			null,
95
-			self::class
96
-		);
97
-
98
-		return $mountPoints;
99
-	}
100
-
101
-	protected function getMultiBucketObjectStore(int $number): array {
102
-		$config = $this->config->getSystemValue('objectstore_multibucket');
103
-
104
-		// sanity checks
105
-		if (empty($config['class'])) {
106
-			$this->logger->error('No class given for objectstore', ['app' => 'files']);
107
-		}
108
-		if (!isset($config['arguments'])) {
109
-			$config['arguments'] = [];
110
-		}
111
-
112
-		/*
40
+    private LoggerInterface $logger;
41
+    /** @var IConfig */
42
+    private $config;
43
+
44
+    public function __construct(LoggerInterface $logger, IConfig $config) {
45
+        $this->logger = $logger;
46
+        $this->config = $config;
47
+    }
48
+
49
+    /**
50
+     * @return MountPoint[]
51
+     * @throws \Exception
52
+     */
53
+    public function getRootMounts(IStorageFactory $loader): array {
54
+        if (!is_array($this->config->getSystemValue('objectstore_multibucket'))) {
55
+            return [];
56
+        }
57
+        if ($this->config->getSystemValue('objectstore.multibucket.preview-distribution', false) !== true) {
58
+            return [];
59
+        }
60
+
61
+        $instanceId = $this->config->getSystemValueString('instanceid', '');
62
+        $mountPoints = [];
63
+        $directoryRange = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
64
+        $i = 0;
65
+        foreach ($directoryRange as $parent) {
66
+            foreach ($directoryRange as $child) {
67
+                $mountPoints[] = new MountPoint(
68
+                    AppdataPreviewObjectStoreStorage::class,
69
+                    '/appdata_' . $instanceId . '/preview/' . $parent . '/' . $child,
70
+                    $this->getMultiBucketObjectStore($i),
71
+                    $loader,
72
+                    null,
73
+                    null,
74
+                    self::class
75
+                );
76
+                $i++;
77
+            }
78
+        }
79
+
80
+        $rootStorageArguments = $this->getMultiBucketObjectStoreForRoot();
81
+        $fakeRootStorage = new ObjectStoreStorage($rootStorageArguments);
82
+        $fakeRootStorageJail = new Jail([
83
+            'storage' => $fakeRootStorage,
84
+            'root' => '/appdata_' . $instanceId . '/preview',
85
+        ]);
86
+
87
+        // add a fallback location to be able to fetch existing previews from the old bucket
88
+        $mountPoints[] = new MountPoint(
89
+            $fakeRootStorageJail,
90
+            '/appdata_' . $instanceId . '/preview/old-multibucket',
91
+            null,
92
+            $loader,
93
+            null,
94
+            null,
95
+            self::class
96
+        );
97
+
98
+        return $mountPoints;
99
+    }
100
+
101
+    protected function getMultiBucketObjectStore(int $number): array {
102
+        $config = $this->config->getSystemValue('objectstore_multibucket');
103
+
104
+        // sanity checks
105
+        if (empty($config['class'])) {
106
+            $this->logger->error('No class given for objectstore', ['app' => 'files']);
107
+        }
108
+        if (!isset($config['arguments'])) {
109
+            $config['arguments'] = [];
110
+        }
111
+
112
+        /*
113 113
 		 * Use any provided bucket argument as prefix
114 114
 		 * and add the mapping from parent/child => bucket
115 115
 		 */
116
-		if (!isset($config['arguments']['bucket'])) {
117
-			$config['arguments']['bucket'] = '';
118
-		}
116
+        if (!isset($config['arguments']['bucket'])) {
117
+            $config['arguments']['bucket'] = '';
118
+        }
119 119
 
120
-		$config['arguments']['bucket'] .= "-preview-$number";
120
+        $config['arguments']['bucket'] .= "-preview-$number";
121 121
 
122
-		// instantiate object store implementation
123
-		$config['arguments']['objectstore'] = new $config['class']($config['arguments']);
122
+        // instantiate object store implementation
123
+        $config['arguments']['objectstore'] = new $config['class']($config['arguments']);
124 124
 
125
-		$config['arguments']['internal-id'] = $number;
125
+        $config['arguments']['internal-id'] = $number;
126 126
 
127
-		return $config['arguments'];
128
-	}
127
+        return $config['arguments'];
128
+    }
129 129
 
130
-	protected function getMultiBucketObjectStoreForRoot(): array {
131
-		$config = $this->config->getSystemValue('objectstore_multibucket');
130
+    protected function getMultiBucketObjectStoreForRoot(): array {
131
+        $config = $this->config->getSystemValue('objectstore_multibucket');
132 132
 
133
-		// sanity checks
134
-		if (empty($config['class'])) {
135
-			$this->logger->error('No class given for objectstore', ['app' => 'files']);
136
-		}
137
-		if (!isset($config['arguments'])) {
138
-			$config['arguments'] = [];
139
-		}
133
+        // sanity checks
134
+        if (empty($config['class'])) {
135
+            $this->logger->error('No class given for objectstore', ['app' => 'files']);
136
+        }
137
+        if (!isset($config['arguments'])) {
138
+            $config['arguments'] = [];
139
+        }
140 140
 
141
-		/*
141
+        /*
142 142
 		 * Use any provided bucket argument as prefix
143 143
 		 * and add the mapping from parent/child => bucket
144 144
 		 */
145
-		if (!isset($config['arguments']['bucket'])) {
146
-			$config['arguments']['bucket'] = '';
147
-		}
148
-		$config['arguments']['bucket'] .= '0';
145
+        if (!isset($config['arguments']['bucket'])) {
146
+            $config['arguments']['bucket'] = '';
147
+        }
148
+        $config['arguments']['bucket'] .= '0';
149 149
 
150
-		// instantiate object store implementation
151
-		$config['arguments']['objectstore'] = new $config['class']($config['arguments']);
150
+        // instantiate object store implementation
151
+        $config['arguments']['objectstore'] = new $config['class']($config['arguments']);
152 152
 
153
-		return $config['arguments'];
154
-	}
153
+        return $config['arguments'];
154
+    }
155 155
 }
Please login to merge, or discard this patch.