Completed
Pull Request — master (#4617)
by Julius
14:00
created
lib/private/Encryption/Exceptions/EmptyEncryptionDataException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,6 +26,6 @@
 block discarded – undo
26 26
 
27 27
 use OCP\Encryption\Exceptions\GenericEncryptionException;
28 28
 
29
-class EmptyEncryptionDataException extends GenericEncryptionException{
29
+class EmptyEncryptionDataException extends GenericEncryptionException {
30 30
 
31 31
 }
Please login to merge, or discard this patch.
lib/private/Encryption/DecryptAll.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 		$this->output = $output;
86 86
 
87 87
 		if ($user !== '' && $this->userManager->userExists($user) === false) {
88
-			$this->output->writeln('User "' . $user . '" does not exist. Please check the username and try again');
88
+			$this->output->writeln('User "'.$user.'" does not exist. Please check the username and try again');
89 89
 			return false;
90 90
 		}
91 91
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 			$this->output->writeln('Files for following users couldn\'t be decrypted, ');
104 104
 			$this->output->writeln('maybe the user is not set up in a way that supports this operation: ');
105 105
 			foreach ($this->failed as $uid => $paths) {
106
-				$this->output->writeln('    ' . $uid);
106
+				$this->output->writeln('    '.$uid);
107 107
 			}
108 108
 			$this->output->writeln('');
109 109
 		}
@@ -124,10 +124,10 @@  discard block
 block discarded – undo
124 124
 			/** @var IEncryptionModule $module */
125 125
 			$module = call_user_func($moduleDesc['callback']);
126 126
 			$this->output->writeln('');
127
-			$this->output->writeln('Prepare "' . $module->getDisplayName() . '"');
127
+			$this->output->writeln('Prepare "'.$module->getDisplayName().'"');
128 128
 			$this->output->writeln('');
129 129
 			if ($module->prepareDecryptAll($this->input, $this->output, $user) === false) {
130
-				$this->output->writeln('Module "' . $moduleDesc['displayName'] . '" does not support the functionality to decrypt all files again or the initialization of the module failed!');
130
+				$this->output->writeln('Module "'.$moduleDesc['displayName'].'" does not support the functionality to decrypt all files again or the initialization of the module failed!');
131 131
 				return false;
132 132
 			}
133 133
 		}
@@ -205,16 +205,16 @@  discard block
 block discarded – undo
205 205
 
206 206
 		$this->setupUserFS($uid);
207 207
 		$directories = array();
208
-		$directories[] = '/' . $uid . '/files';
208
+		$directories[] = '/'.$uid.'/files';
209 209
 
210 210
 		while ($root = array_pop($directories)) {
211 211
 			$content = $this->rootView->getDirectoryContent($root);
212 212
 			foreach ($content as $file) {
213 213
 				// only decrypt files owned by the user
214
-				if($file->getStorage()->instanceOfStorage('OCA\Files_Sharing\SharedStorage')) {
214
+				if ($file->getStorage()->instanceOfStorage('OCA\Files_Sharing\SharedStorage')) {
215 215
 					continue;
216 216
 				}
217
-				$path = $root . '/' . $file['name'];
217
+				$path = $root.'/'.$file['name'];
218 218
 				if ($this->rootView->is_dir($path)) {
219 219
 					$directories[] = $path;
220 220
 					continue;
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 	protected function decryptFile($path) {
253 253
 
254 254
 		$source = $path;
255
-		$target = $path . '.decrypted.' . $this->getTimestamp();
255
+		$target = $path.'.decrypted.'.$this->getTimestamp();
256 256
 
257 257
 		try {
258 258
 			$this->rootView->copy($source, $target);
Please login to merge, or discard this patch.
lib/private/Encryption/File.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@
 block discarded – undo
58 58
 		// always add owner to the list of users with access to the file
59 59
 		$userIds = array($owner);
60 60
 
61
-		if (!$this->util->isFile($owner . '/' . $ownerPath)) {
61
+		if (!$this->util->isFile($owner.'/'.$ownerPath)) {
62 62
 			return array('users' => $userIds, 'public' => false);
63 63
 		}
64 64
 
Please login to merge, or discard this patch.
lib/private/Encryption/Keys/Storage.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
 		$this->util = $util;
67 67
 
68 68
 		$this->encryption_base_dir = '/files_encryption';
69
-		$this->keys_base_dir = $this->encryption_base_dir .'/keys';
70
-		$this->backup_base_dir = $this->encryption_base_dir .'/backup';
69
+		$this->keys_base_dir = $this->encryption_base_dir.'/keys';
70
+		$this->backup_base_dir = $this->encryption_base_dir.'/backup';
71 71
 		$this->root_dir = $this->util->getKeyStorageRoot();
72 72
 	}
73 73
 
@@ -85,14 +85,14 @@  discard block
 block discarded – undo
85 85
 	public function getFileKey($path, $keyId, $encryptionModuleId) {
86 86
 		$realFile = $this->util->stripPartialFileExtension($path);
87 87
 		$keyDir = $this->getFileKeyDir($encryptionModuleId, $realFile);
88
-		$key = $this->getKey($keyDir . $keyId);
88
+		$key = $this->getKey($keyDir.$keyId);
89 89
 
90 90
 		if ($key === '' && $realFile !== $path) {
91 91
 			// Check if the part file has keys and use them, if no normal keys
92 92
 			// exist. This is required to fix copyBetweenStorage() when we
93 93
 			// rename a .part file over storage borders.
94 94
 			$keyDir = $this->getFileKeyDir($encryptionModuleId, $path);
95
-			$key = $this->getKey($keyDir . $keyId);
95
+			$key = $this->getKey($keyDir.$keyId);
96 96
 		}
97 97
 
98 98
 		return $key;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 */
120 120
 	public function setFileKey($path, $keyId, $key, $encryptionModuleId) {
121 121
 		$keyDir = $this->getFileKeyDir($encryptionModuleId, $path);
122
-		return $this->setKey($keyDir . $keyId, $key);
122
+		return $this->setKey($keyDir.$keyId, $key);
123 123
 	}
124 124
 
125 125
 	/**
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 */
144 144
 	public function deleteFileKey($path, $keyId, $encryptionModuleId) {
145 145
 		$keyDir = $this->getFileKeyDir($encryptionModuleId, $path);
146
-		return !$this->view->file_exists($keyDir . $keyId) || $this->view->unlink($keyDir . $keyId);
146
+		return !$this->view->file_exists($keyDir.$keyId) || $this->view->unlink($keyDir.$keyId);
147 147
 	}
148 148
 
149 149
 	/**
@@ -173,10 +173,10 @@  discard block
 block discarded – undo
173 173
 	protected function constructUserKeyPath($encryptionModuleId, $keyId, $uid) {
174 174
 
175 175
 		if ($uid === null) {
176
-			$path = $this->root_dir . '/' . $this->encryption_base_dir . '/' . $encryptionModuleId . '/' . $keyId;
176
+			$path = $this->root_dir.'/'.$this->encryption_base_dir.'/'.$encryptionModuleId.'/'.$keyId;
177 177
 		} else {
178
-			$path = $this->root_dir . '/' . $uid . $this->encryption_base_dir . '/'
179
-				. $encryptionModuleId . '/' . $uid . '.' . $keyId;
178
+			$path = $this->root_dir.'/'.$uid.$this->encryption_base_dir.'/'
179
+				. $encryptionModuleId.'/'.$uid.'.'.$keyId;
180 180
 		}
181 181
 
182 182
 		return \OC\Files\Filesystem::normalizePath($path);
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 
195 195
 		if ($this->view->file_exists($path)) {
196 196
 			if (isset($this->keyCache[$path])) {
197
-				$key =  $this->keyCache[$path];
197
+				$key = $this->keyCache[$path];
198 198
 			} else {
199 199
 				$key = $this->view->file_get_contents($path);
200 200
 				$this->keyCache[$path] = $key;
@@ -238,12 +238,12 @@  discard block
 block discarded – undo
238 238
 
239 239
 		// in case of system wide mount points the keys are stored directly in the data directory
240 240
 		if ($this->util->isSystemWideMountPoint($filename, $owner)) {
241
-			$keyPath = $this->root_dir . '/' . $this->keys_base_dir . $filename . '/';
241
+			$keyPath = $this->root_dir.'/'.$this->keys_base_dir.$filename.'/';
242 242
 		} else {
243
-			$keyPath = $this->root_dir . '/' . $owner . $this->keys_base_dir . $filename . '/';
243
+			$keyPath = $this->root_dir.'/'.$owner.$this->keys_base_dir.$filename.'/';
244 244
 		}
245 245
 
246
-		return Filesystem::normalizePath($keyPath . $encryptionModuleId . '/', false);
246
+		return Filesystem::normalizePath($keyPath.$encryptionModuleId.'/', false);
247 247
 	}
248 248
 
249 249
 	/**
@@ -300,13 +300,13 @@  discard block
 block discarded – undo
300 300
 	 * @since 12.0.0
301 301
 	 */
302 302
 	public function backupUserKeys($encryptionModuleId, $purpose, $uid) {
303
-		$source = $uid . $this->encryption_base_dir . '/' . $encryptionModuleId;
304
-		$backupDir = $uid . $this->backup_base_dir;
303
+		$source = $uid.$this->encryption_base_dir.'/'.$encryptionModuleId;
304
+		$backupDir = $uid.$this->backup_base_dir;
305 305
 		if (!$this->view->file_exists($backupDir)) {
306 306
 			$this->view->mkdir($backupDir);
307 307
 		}
308 308
 
309
-		$backupDir = $backupDir . '/' . $purpose . '.' . $encryptionModuleId . '.' . $this->getTimestamp();
309
+		$backupDir = $backupDir.'/'.$purpose.'.'.$encryptionModuleId.'.'.$this->getTimestamp();
310 310
 		$this->view->mkdir($backupDir);
311 311
 
312 312
 		return $this->view->copy($source, $backupDir);
@@ -332,9 +332,9 @@  discard block
 block discarded – undo
332 332
 		$systemWideMountPoint = $this->util->isSystemWideMountPoint($relativePath, $owner);
333 333
 
334 334
 		if ($systemWideMountPoint) {
335
-			$systemPath = $this->root_dir . '/' . $this->keys_base_dir . $relativePath . '/';
335
+			$systemPath = $this->root_dir.'/'.$this->keys_base_dir.$relativePath.'/';
336 336
 		} else {
337
-			$systemPath = $this->root_dir . '/' . $owner . $this->keys_base_dir . $relativePath . '/';
337
+			$systemPath = $this->root_dir.'/'.$owner.$this->keys_base_dir.$relativePath.'/';
338 338
 		}
339 339
 
340 340
 		return  Filesystem::normalizePath($systemPath, false);
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 			$sub_dirs = explode('/', ltrim($path, '/'));
352 352
 			$dir = '';
353 353
 			foreach ($sub_dirs as $sub_dir) {
354
-				$dir .= '/' . $sub_dir;
354
+				$dir .= '/'.$sub_dir;
355 355
 				if (!$this->view->is_dir($dir)) {
356 356
 					$this->view->mkdir($dir);
357 357
 				}
Please login to merge, or discard this patch.
lib/private/Encryption/Manager.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -274,7 +274,7 @@
 block discarded – undo
274 274
 		}
275 275
 
276 276
 		// check if key storage is mounted correctly
277
-		if ($this->rootView->file_exists($rootDir . '/' . Storage::KEY_STORAGE_MARKER)) {
277
+		if ($this->rootView->file_exists($rootDir.'/'.Storage::KEY_STORAGE_MARKER)) {
278 278
 			return true;
279 279
 		}
280 280
 
Please login to merge, or discard this patch.
lib/private/NaturalSort.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -117,8 +117,8 @@
 block discarded – undo
117 117
 			if ($aChunk !== $bChunk) {
118 118
 				// test first character (character comparison, not number comparison)
119 119
 				if ($aChunk[0] >= '0' && $aChunk[0] <= '9' && $bChunk[0] >= '0' && $bChunk[0] <= '9') {
120
-					$aNum = (int)$aChunk;
121
-					$bNum = (int)$bChunk;
120
+					$aNum = (int) $aChunk;
121
+					$bNum = (int) $bChunk;
122 122
 					return $aNum - $bNum;
123 123
 				}
124 124
 				return self::getCollator()->compare($aChunk, $bChunk);
Please login to merge, or discard this patch.
lib/private/Cache/File.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
 			$rootView = new View();
52 52
 			$user = \OC::$server->getUserSession()->getUser();
53 53
 			Filesystem::initMountPoints($user->getUID());
54
-			if (!$rootView->file_exists('/' . $user->getUID() . '/cache')) {
55
-				$rootView->mkdir('/' . $user->getUID() . '/cache');
54
+			if (!$rootView->file_exists('/'.$user->getUID().'/cache')) {
55
+				$rootView->mkdir('/'.$user->getUID().'/cache');
56 56
 			}
57
-			$this->storage = new View('/' . $user->getUID() . '/cache');
57
+			$this->storage = new View('/'.$user->getUID().'/cache');
58 58
 			return $this->storage;
59 59
 		} else {
60 60
 			\OCP\Util::writeLog('core', 'Can\'t get cache storage, user not logged in', \OCP\Util::ERROR);
@@ -104,12 +104,12 @@  discard block
 block discarded – undo
104 104
 		// unique id to avoid chunk collision, just in case
105 105
 		$uniqueId = \OC::$server->getSecureRandom()->generate(
106 106
 			16,
107
-			ISecureRandom::CHAR_DIGITS . ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER
107
+			ISecureRandom::CHAR_DIGITS.ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_UPPER
108 108
 		);
109 109
 
110 110
 		// use part file to prevent hasKey() to find the key
111 111
 		// while it is being written
112
-		$keyPart = $key . '.' . $uniqueId . '.part';
112
+		$keyPart = $key.'.'.$uniqueId.'.part';
113 113
 		if ($storage and $storage->file_put_contents($keyPart, $value)) {
114 114
 			if ($ttl === 0) {
115 115
 				$ttl = 86400; // 60*60*24
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 			if (is_resource($dh)) {
159 159
 				while (($file = readdir($dh)) !== false) {
160 160
 					if ($file != '.' and $file != '..' and ($prefix === '' || strpos($file, $prefix) === 0)) {
161
-						$storage->unlink('/' . $file);
161
+						$storage->unlink('/'.$file);
162 162
 					}
163 163
 				}
164 164
 			}
@@ -183,17 +183,17 @@  discard block
 block discarded – undo
183 183
 			while (($file = readdir($dh)) !== false) {
184 184
 				if ($file != '.' and $file != '..') {
185 185
 					try {
186
-						$mtime = $storage->filemtime('/' . $file);
186
+						$mtime = $storage->filemtime('/'.$file);
187 187
 						if ($mtime < $now) {
188
-							$storage->unlink('/' . $file);
188
+							$storage->unlink('/'.$file);
189 189
 						}
190 190
 					} catch (\OCP\Lock\LockedException $e) {
191 191
 						// ignore locked chunks
192
-						\OC::$server->getLogger()->debug('Could not cleanup locked chunk "' . $file . '"', array('app' => 'core'));
192
+						\OC::$server->getLogger()->debug('Could not cleanup locked chunk "'.$file.'"', array('app' => 'core'));
193 193
 					} catch (\OCP\Files\ForbiddenException $e) {
194
-						\OC::$server->getLogger()->debug('Could not cleanup forbidden chunk "' . $file . '"', array('app' => 'core'));
194
+						\OC::$server->getLogger()->debug('Could not cleanup forbidden chunk "'.$file.'"', array('app' => 'core'));
195 195
 					} catch (\OCP\Files\LockNotAcquiredException $e) {
196
-						\OC::$server->getLogger()->debug('Could not cleanup locked chunk "' . $file . '"', array('app' => 'core'));
196
+						\OC::$server->getLogger()->debug('Could not cleanup locked chunk "'.$file.'"', array('app' => 'core'));
197 197
 					}
198 198
 				}
199 199
 			}
Please login to merge, or discard this patch.
lib/private/SystemTag/SystemTagObjectMapper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -231,7 +231,7 @@
 block discarded – undo
231 231
 		$result->closeCursor();
232 232
 
233 233
 		if ($all) {
234
-			return ((int)$row[0] === count($objIds));
234
+			return ((int) $row[0] === count($objIds));
235 235
 		} else {
236 236
 			return (bool) $row;
237 237
 		}
Please login to merge, or discard this patch.
lib/private/SystemTag/SystemTagManager.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -136,14 +136,14 @@  discard block
 block discarded – undo
136 136
 			->from(self::TAG_TABLE);
137 137
 
138 138
 		if (!is_null($visibilityFilter)) {
139
-			$query->andWhere($query->expr()->eq('visibility', $query->createNamedParameter((int)$visibilityFilter)));
139
+			$query->andWhere($query->expr()->eq('visibility', $query->createNamedParameter((int) $visibilityFilter)));
140 140
 		}
141 141
 
142 142
 		if (!empty($nameSearchPattern)) {
143 143
 			$query->andWhere(
144 144
 				$query->expr()->like(
145 145
 					'name',
146
-					$query->createNamedParameter('%' . $this->connection->escapeLikeParameter($nameSearchPattern). '%')
146
+					$query->createNamedParameter('%'.$this->connection->escapeLikeParameter($nameSearchPattern).'%')
147 147
 				)
148 148
 			);
149 149
 		}
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
 	 * {@inheritdoc}
168 168
 	 */
169 169
 	public function getTag($tagName, $userVisible, $userAssignable) {
170
-		$userVisible = (int)$userVisible;
171
-		$userAssignable = (int)$userAssignable;
170
+		$userVisible = (int) $userVisible;
171
+		$userAssignable = (int) $userAssignable;
172 172
 
173 173
 		$result = $this->selectTagQuery
174 174
 			->setParameter('name', $tagName)
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 		$result->closeCursor();
181 181
 		if (!$row) {
182 182
 			throw new TagNotFoundException(
183
-				'Tag ("' . $tagName . '", '. $userVisible . ', ' . $userAssignable . ') does not exist'
183
+				'Tag ("'.$tagName.'", '.$userVisible.', '.$userAssignable.') does not exist'
184 184
 			);
185 185
 		}
186 186
 
@@ -191,8 +191,8 @@  discard block
 block discarded – undo
191 191
 	 * {@inheritdoc}
192 192
 	 */
193 193
 	public function createTag($tagName, $userVisible, $userAssignable) {
194
-		$userVisible = (int)$userVisible;
195
-		$userAssignable = (int)$userAssignable;
194
+		$userVisible = (int) $userVisible;
195
+		$userAssignable = (int) $userAssignable;
196 196
 
197 197
 		$query = $this->connection->getQueryBuilder();
198 198
 		$query->insert(self::TAG_TABLE)
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 			$query->execute();
207 207
 		} catch (UniqueConstraintViolationException $e) {
208 208
 			throw new TagAlreadyExistsException(
209
-				'Tag ("' . $tagName . '", '. $userVisible . ', ' . $userAssignable . ') already exists',
209
+				'Tag ("'.$tagName.'", '.$userVisible.', '.$userAssignable.') already exists',
210 210
 				0,
211 211
 				$e
212 212
 			);
@@ -215,10 +215,10 @@  discard block
 block discarded – undo
215 215
 		$tagId = $query->getLastInsertId();
216 216
 
217 217
 		$tag = new SystemTag(
218
-			(int)$tagId,
218
+			(int) $tagId,
219 219
 			$tagName,
220
-			(bool)$userVisible,
221
-			(bool)$userAssignable
220
+			(bool) $userVisible,
221
+			(bool) $userAssignable
222 222
 		);
223 223
 
224 224
 		$this->dispatcher->dispatch(ManagerEvent::EVENT_CREATE, new ManagerEvent(
@@ -232,8 +232,8 @@  discard block
 block discarded – undo
232 232
 	 * {@inheritdoc}
233 233
 	 */
234 234
 	public function updateTag($tagId, $tagName, $userVisible, $userAssignable) {
235
-		$userVisible = (int)$userVisible;
236
-		$userAssignable = (int)$userAssignable;
235
+		$userVisible = (int) $userVisible;
236
+		$userAssignable = (int) $userAssignable;
237 237
 
238 238
 		try {
239 239
 			$tags = $this->getTagsByIds($tagId);
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 			}
271 271
 		} catch (UniqueConstraintViolationException $e) {
272 272
 			throw new TagAlreadyExistsException(
273
-				'Tag ("' . $tagName . '", '. $userVisible . ', ' . $userAssignable . ') already exists',
273
+				'Tag ("'.$tagName.'", '.$userVisible.', '.$userAssignable.') already exists',
274 274
 				0,
275 275
 				$e
276 276
 			);
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 	}
378 378
 
379 379
 	private function createSystemTagFromRow($row) {
380
-		return new SystemTag((int)$row['id'], $row['name'], (bool)$row['visibility'], (bool)$row['editable']);
380
+		return new SystemTag((int) $row['id'], $row['name'], (bool) $row['visibility'], (bool) $row['editable']);
381 381
 	}
382 382
 
383 383
 	/**
Please login to merge, or discard this patch.