@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | case 'database': |
92 | 92 | case 'mysql': |
93 | 93 | case 'sqlite': |
94 | - \OCP\Util::writeLog('core', 'Adding user backend ' . $backend . '.', ILogger::DEBUG); |
|
94 | + \OCP\Util::writeLog('core', 'Adding user backend '.$backend.'.', ILogger::DEBUG); |
|
95 | 95 | self::$_usedBackends[$backend] = new \OC\User\Database(); |
96 | 96 | \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]); |
97 | 97 | break; |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]); |
101 | 101 | break; |
102 | 102 | default: |
103 | - \OCP\Util::writeLog('core', 'Adding default user backend ' . $backend . '.', ILogger::DEBUG); |
|
104 | - $className = 'OC_USER_' . strtoupper($backend); |
|
103 | + \OCP\Util::writeLog('core', 'Adding default user backend '.$backend.'.', ILogger::DEBUG); |
|
104 | + $className = 'OC_USER_'.strtoupper($backend); |
|
105 | 105 | self::$_usedBackends[$backend] = new $className(); |
106 | 106 | \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]); |
107 | 107 | break; |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | self::useBackend($backend); |
146 | 146 | self::$_setupedBackends[] = $i; |
147 | 147 | } else { |
148 | - \OCP\Util::writeLog('core', 'User backend ' . $class . ' already initialized.', ILogger::DEBUG); |
|
148 | + \OCP\Util::writeLog('core', 'User backend '.$class.' already initialized.', ILogger::DEBUG); |
|
149 | 149 | } |
150 | 150 | } else { |
151 | - \OCP\Util::writeLog('core', 'User backend ' . $class . ' not found.', ILogger::ERROR); |
|
151 | + \OCP\Util::writeLog('core', 'User backend '.$class.' not found.', ILogger::ERROR); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | if ($user) { |
367 | 367 | return $user->getHome(); |
368 | 368 | } else { |
369 | - return \OC::$server->getSystemConfig()->getValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $uid; |
|
369 | + return \OC::$server->getSystemConfig()->getValue('datadirectory', OC::$SERVERROOT.'/data').'/'.$uid; |
|
370 | 370 | } |
371 | 371 | } |
372 | 372 |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | private static function sendHeaders($filename, $name, array $rangeArray) { |
77 | 77 | OC_Response::setContentDispositionHeader($name, 'attachment'); |
78 | 78 | header('Content-Transfer-Encoding: binary', true); |
79 | - header('Pragma: public');// enable caching in IE |
|
79 | + header('Pragma: public'); // enable caching in IE |
|
80 | 80 | header('Expires: 0'); |
81 | 81 | header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
82 | 82 | $fileSize = \OC\Files\Filesystem::filesize($filename); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | } |
121 | 121 | |
122 | 122 | if (!is_array($files)) { |
123 | - $filename = $dir . '/' . $files; |
|
123 | + $filename = $dir.'/'.$files; |
|
124 | 124 | if (!$view->is_dir($filename)) { |
125 | 125 | self::getSingleFile($view, $dir, $files, is_null($params) ? array() : $params); |
126 | 126 | return; |
@@ -135,9 +135,9 @@ discard block |
||
135 | 135 | $name = $basename; |
136 | 136 | } |
137 | 137 | |
138 | - $filename = $dir . '/' . $name; |
|
138 | + $filename = $dir.'/'.$name; |
|
139 | 139 | } else { |
140 | - $filename = $dir . '/' . $files; |
|
140 | + $filename = $dir.'/'.$files; |
|
141 | 141 | $getType = self::ZIP_DIR; |
142 | 142 | // downloading root ? |
143 | 143 | if ($files !== '') { |
@@ -152,13 +152,13 @@ discard block |
||
152 | 152 | $fileInfos = array(); |
153 | 153 | $fileSize = 0; |
154 | 154 | foreach ($files as $file) { |
155 | - $fileInfo = \OC\Files\Filesystem::getFileInfo($dir . '/' . $file); |
|
155 | + $fileInfo = \OC\Files\Filesystem::getFileInfo($dir.'/'.$file); |
|
156 | 156 | $fileSize += $fileInfo->getSize(); |
157 | 157 | $fileInfos[] = $fileInfo; |
158 | 158 | } |
159 | 159 | $numberOfFiles = self::getNumberOfFiles($fileInfos); |
160 | 160 | } elseif ($getType === self::ZIP_DIR) { |
161 | - $fileInfo = \OC\Files\Filesystem::getFileInfo($dir . '/' . $files); |
|
161 | + $fileInfo = \OC\Files\Filesystem::getFileInfo($dir.'/'.$files); |
|
162 | 162 | $fileSize = $fileInfo->getSize(); |
163 | 163 | $numberOfFiles = self::getNumberOfFiles(array($fileInfo)); |
164 | 164 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | OC_Util::obEnd(); |
168 | 168 | |
169 | 169 | $streamer->sendHeaders($name); |
170 | - $executionTime = (int)OC::$server->getIniWrapper()->getNumeric('max_execution_time'); |
|
170 | + $executionTime = (int) OC::$server->getIniWrapper()->getNumeric('max_execution_time'); |
|
171 | 171 | if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
172 | 172 | @set_time_limit(0); |
173 | 173 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | |
176 | 176 | if ($getType === self::ZIP_FILES) { |
177 | 177 | foreach ($files as $file) { |
178 | - $file = $dir . '/' . $file; |
|
178 | + $file = $dir.'/'.$file; |
|
179 | 179 | if (\OC\Files\Filesystem::is_file($file)) { |
180 | 180 | $fileSize = \OC\Files\Filesystem::filesize($file); |
181 | 181 | $fileTime = \OC\Files\Filesystem::filemtime($file); |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | } |
188 | 188 | } |
189 | 189 | } elseif ($getType === self::ZIP_DIR) { |
190 | - $file = $dir . '/' . $files; |
|
190 | + $file = $dir.'/'.$files; |
|
191 | 191 | $streamer->addDirRecursive($file); |
192 | 192 | } |
193 | 193 | $streamer->finalize(); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @return array $rangeArray ('from'=>int,'to'=>int), ... |
220 | 220 | */ |
221 | 221 | private static function parseHttpRangeHeader($rangeHeaderPos, $fileSize) { |
222 | - $rArray=explode(',', $rangeHeaderPos); |
|
222 | + $rArray = explode(',', $rangeHeaderPos); |
|
223 | 223 | $minOffset = 0; |
224 | 224 | $ind = 0; |
225 | 225 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | if ($ranges[0] < $minOffset) { // case: bytes=500-700,601-999 |
232 | 232 | $ranges[0] = $minOffset; |
233 | 233 | } |
234 | - if ($ind > 0 && $rangeArray[$ind-1]['to']+1 == $ranges[0]) { // case: bytes=500-600,601-999 |
|
234 | + if ($ind > 0 && $rangeArray[$ind - 1]['to'] + 1 == $ranges[0]) { // case: bytes=500-600,601-999 |
|
235 | 235 | $ind--; |
236 | 236 | $ranges[0] = $rangeArray[$ind]['from']; |
237 | 237 | } |
@@ -240,9 +240,9 @@ discard block |
||
240 | 240 | if (is_numeric($ranges[0]) && is_numeric($ranges[1]) && $ranges[0] < $fileSize && $ranges[0] <= $ranges[1]) { |
241 | 241 | // case: x-x |
242 | 242 | if ($ranges[1] >= $fileSize) { |
243 | - $ranges[1] = $fileSize-1; |
|
243 | + $ranges[1] = $fileSize - 1; |
|
244 | 244 | } |
245 | - $rangeArray[$ind++] = array( 'from' => $ranges[0], 'to' => $ranges[1], 'size' => $fileSize ); |
|
245 | + $rangeArray[$ind++] = array('from' => $ranges[0], 'to' => $ranges[1], 'size' => $fileSize); |
|
246 | 246 | $minOffset = $ranges[1] + 1; |
247 | 247 | if ($minOffset >= $fileSize) { |
248 | 248 | break; |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | } |
251 | 251 | elseif (is_numeric($ranges[0]) && $ranges[0] < $fileSize) { |
252 | 252 | // case: x- |
253 | - $rangeArray[$ind++] = array( 'from' => $ranges[0], 'to' => $fileSize-1, 'size' => $fileSize ); |
|
253 | + $rangeArray[$ind++] = array('from' => $ranges[0], 'to' => $fileSize - 1, 'size' => $fileSize); |
|
254 | 254 | break; |
255 | 255 | } |
256 | 256 | elseif (is_numeric($ranges[1])) { |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | if ($ranges[1] > $fileSize) { |
259 | 259 | $ranges[1] = $fileSize; |
260 | 260 | } |
261 | - $rangeArray[$ind++] = array( 'from' => $fileSize-$ranges[1], 'to' => $fileSize-1, 'size' => $fileSize ); |
|
261 | + $rangeArray[$ind++] = array('from' => $fileSize - $ranges[1], 'to' => $fileSize - 1, 'size' => $fileSize); |
|
262 | 262 | break; |
263 | 263 | } |
264 | 264 | } |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * @param array $params ; 'head' boolean to only send header of the request ; 'range' http range header |
273 | 273 | */ |
274 | 274 | private static function getSingleFile($view, $dir, $name, $params) { |
275 | - $filename = $dir . '/' . $name; |
|
275 | + $filename = $dir.'/'.$name; |
|
276 | 276 | OC_Util::obEnd(); |
277 | 277 | $view->lockFile($filename, ILockingProvider::LOCK_SHARED); |
278 | 278 | |
@@ -361,17 +361,17 @@ discard block |
||
361 | 361 | */ |
362 | 362 | public static function lockFiles($view, $dir, $files) { |
363 | 363 | if (!is_array($files)) { |
364 | - $file = $dir . '/' . $files; |
|
364 | + $file = $dir.'/'.$files; |
|
365 | 365 | $files = [$file]; |
366 | 366 | } |
367 | 367 | foreach ($files as $file) { |
368 | - $file = $dir . '/' . $file; |
|
368 | + $file = $dir.'/'.$file; |
|
369 | 369 | $view->lockFile($file, ILockingProvider::LOCK_SHARED); |
370 | 370 | if ($view->is_dir($file)) { |
371 | 371 | $contents = $view->getDirectoryContent($file); |
372 | 372 | $contents = array_map(function($fileInfo) use ($file) { |
373 | 373 | /** @var \OCP\Files\FileInfo $fileInfo */ |
374 | - return $file . '/' . $fileInfo->getName(); |
|
374 | + return $file.'/'.$fileInfo->getName(); |
|
375 | 375 | }, $contents); |
376 | 376 | self::lockFiles($view, $dir, $contents); |
377 | 377 | } |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | */ |
388 | 388 | public static function setUploadLimit($size, $files = []) { |
389 | 389 | //don't allow user to break his config |
390 | - $size = (int)$size; |
|
390 | + $size = (int) $size; |
|
391 | 391 | if ($size < self::UPLOAD_MIN_LIMIT_BYTES) { |
392 | 392 | return false; |
393 | 393 | } |
@@ -400,8 +400,8 @@ discard block |
||
400 | 400 | |
401 | 401 | // default locations if not overridden by $files |
402 | 402 | $files = array_merge([ |
403 | - '.htaccess' => OC::$SERVERROOT . '/.htaccess', |
|
404 | - '.user.ini' => OC::$SERVERROOT . '/.user.ini' |
|
403 | + '.htaccess' => OC::$SERVERROOT.'/.htaccess', |
|
404 | + '.user.ini' => OC::$SERVERROOT.'/.user.ini' |
|
405 | 405 | ], $files); |
406 | 406 | |
407 | 407 | $updateFiles = [ |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | $handle = @fopen($filename, 'r+'); |
423 | 423 | if (!$handle) { |
424 | 424 | \OCP\Util::writeLog('files', |
425 | - 'Can\'t write upload limit to ' . $filename . '. Please check the file permissions', |
|
425 | + 'Can\'t write upload limit to '.$filename.'. Please check the file permissions', |
|
426 | 426 | ILogger::WARN); |
427 | 427 | $success = false; |
428 | 428 | continue; // try to update as many files as possible |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | $content = $newContent; |
443 | 443 | } |
444 | 444 | if ($hasReplaced === 0) { |
445 | - $content .= "\n" . $setting; |
|
445 | + $content .= "\n".$setting; |
|
446 | 446 | } |
447 | 447 | } |
448 | 448 | |
@@ -473,12 +473,12 @@ discard block |
||
473 | 473 | } |
474 | 474 | if ($getType === self::ZIP_FILES) { |
475 | 475 | foreach ($files as $file) { |
476 | - $file = $dir . '/' . $file; |
|
476 | + $file = $dir.'/'.$file; |
|
477 | 477 | $view->unlockFile($file, ILockingProvider::LOCK_SHARED); |
478 | 478 | } |
479 | 479 | } |
480 | 480 | if ($getType === self::ZIP_DIR) { |
481 | - $file = $dir . '/' . $files; |
|
481 | + $file = $dir.'/'.$files; |
|
482 | 482 | $view->unlockFile($file, ILockingProvider::LOCK_SHARED); |
483 | 483 | } |
484 | 484 | } |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | throw new \Exception("Access Key, Secret and Bucket have to be configured."); |
53 | 53 | } |
54 | 54 | |
55 | - $this->id = 'amazon::' . $params['bucket']; |
|
55 | + $this->id = 'amazon::'.$params['bucket']; |
|
56 | 56 | |
57 | 57 | $this->test = isset($params['test']); |
58 | 58 | $this->bucket = $params['bucket']; |
59 | 59 | $this->timeout = !isset($params['timeout']) ? 15 : $params['timeout']; |
60 | 60 | $params['region'] = empty($params['region']) ? 'eu-west-1' : $params['region']; |
61 | - $params['hostname'] = empty($params['hostname']) ? 's3.' . $params['region'] . '.amazonaws.com' : $params['hostname']; |
|
61 | + $params['hostname'] = empty($params['hostname']) ? 's3.'.$params['region'].'.amazonaws.com' : $params['hostname']; |
|
62 | 62 | if (!isset($params['port']) || $params['port'] === '') { |
63 | 63 | $params['port'] = (isset($params['use_ssl']) && $params['use_ssl'] === false) ? 80 : 443; |
64 | 64 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | } |
79 | 79 | |
80 | 80 | $scheme = (isset($this->params['use_ssl']) && $this->params['use_ssl'] === false) ? 'http' : 'https'; |
81 | - $base_url = $scheme . '://' . $this->params['hostname'] . ':' . $this->params['port'] . '/'; |
|
81 | + $base_url = $scheme.'://'.$this->params['hostname'].':'.$this->params['port'].'/'; |
|
82 | 82 | |
83 | 83 | $options = [ |
84 | 84 | 'version' => isset($this->params['version']) ? $this->params['version'] : 'latest', |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | $this->connection = new S3Client($options); |
101 | 101 | |
102 | 102 | if (!$this->connection->isBucketDnsCompatible($this->bucket)) { |
103 | - throw new \Exception("The configured bucket name is invalid: " . $this->bucket); |
|
103 | + throw new \Exception("The configured bucket name is invalid: ".$this->bucket); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | if (!$this->connection->doesBucketExist($this->bucket)) { |
107 | 107 | $logger = \OC::$server->getLogger(); |
108 | 108 | try { |
109 | - $logger->info('Bucket "' . $this->bucket . '" does not exist - creating it.', ['app' => 'objectstore']); |
|
109 | + $logger->info('Bucket "'.$this->bucket.'" does not exist - creating it.', ['app' => 'objectstore']); |
|
110 | 110 | $this->connection->createBucket(array( |
111 | 111 | 'Bucket' => $this->bucket |
112 | 112 | )); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | 'level' => ILogger::DEBUG, |
118 | 118 | 'app' => 'objectstore', |
119 | 119 | ]); |
120 | - throw new \Exception('Creation of bucket "' . $this->bucket . '" failed. ' . $e->getMessage()); |
|
120 | + throw new \Exception('Creation of bucket "'.$this->bucket.'" failed. '.$e->getMessage()); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | } else { |
107 | 107 | // Update old classes to new namespace |
108 | 108 | if (strpos($storage, 'OC_Filestorage_') !== false) { |
109 | - $storage = '\OC\Files\Storage\\' . substr($storage, 15); |
|
109 | + $storage = '\OC\Files\Storage\\'.substr($storage, 15); |
|
110 | 110 | } |
111 | 111 | $this->class = $storage; |
112 | 112 | $this->arguments = $arguments; |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | return; |
159 | 159 | } |
160 | 160 | } else { |
161 | - \OCP\Util::writeLog('core', 'storage backend ' . $this->class . ' not found', ILogger::ERROR); |
|
161 | + \OCP\Util::writeLog('core', 'storage backend '.$this->class.' not found', ILogger::ERROR); |
|
162 | 162 | $this->invalidStorage = true; |
163 | 163 | return; |
164 | 164 | } |
@@ -208,13 +208,13 @@ discard block |
||
208 | 208 | */ |
209 | 209 | public function getInternalPath($path) { |
210 | 210 | $path = Filesystem::normalizePath($path, true, false, true); |
211 | - if ($this->mountPoint === $path or $this->mountPoint . '/' === $path) { |
|
211 | + if ($this->mountPoint === $path or $this->mountPoint.'/' === $path) { |
|
212 | 212 | $internalPath = ''; |
213 | 213 | } else { |
214 | 214 | $internalPath = substr($path, strlen($this->mountPoint)); |
215 | 215 | } |
216 | 216 | // substr returns false instead of an empty string, we always want a string |
217 | - return (string)$internalPath; |
|
217 | + return (string) $internalPath; |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | /** |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | */ |
268 | 268 | public function getStorageRootId() { |
269 | 269 | if (is_null($this->rootId)) { |
270 | - $this->rootId = (int)$this->getStorage()->getCache()->getId(''); |
|
270 | + $this->rootId = (int) $this->getStorage()->getCache()->getId(''); |
|
271 | 271 | } |
272 | 272 | return $this->rootId; |
273 | 273 | } |
@@ -368,8 +368,8 @@ discard block |
||
368 | 368 | // check if the file is stored in the array cache, this means that we |
369 | 369 | // copy a file over to the versions folder, in this case we don't want to |
370 | 370 | // decrypt it |
371 | - if ($this->arrayCache->hasKey('encryption_copy_version_' . $path)) { |
|
372 | - $this->arrayCache->remove('encryption_copy_version_' . $path); |
|
371 | + if ($this->arrayCache->hasKey('encryption_copy_version_'.$path)) { |
|
372 | + $this->arrayCache->remove('encryption_copy_version_'.$path); |
|
373 | 373 | return $this->storage->fopen($path, $mode); |
374 | 374 | } |
375 | 375 | |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | } |
441 | 441 | } catch (ModuleDoesNotExistsException $e) { |
442 | 442 | $this->logger->logException($e, [ |
443 | - 'message' => 'Encryption module "' . $encryptionModuleId . '" not found, file will be stored unencrypted', |
|
443 | + 'message' => 'Encryption module "'.$encryptionModuleId.'" not found, file will be stored unencrypted', |
|
444 | 444 | 'level' => ILogger::WARN, |
445 | 445 | 'app' => 'core', |
446 | 446 | ]); |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | try { |
496 | 496 | $result = $this->fixUnencryptedSize($path, $size, $unencryptedSize); |
497 | 497 | } catch (\Exception $e) { |
498 | - $this->logger->error('Couldn\'t re-calculate unencrypted size for '. $path); |
|
498 | + $this->logger->error('Couldn\'t re-calculate unencrypted size for '.$path); |
|
499 | 499 | $this->logger->logException($e); |
500 | 500 | } |
501 | 501 | unset($this->fixUnencryptedSizeOf[$this->getFullPath($path)]); |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | |
525 | 525 | // if we couldn't open the file we return the old unencrypted size |
526 | 526 | if (!is_resource($stream)) { |
527 | - $this->logger->error('Could not open ' . $path . '. Recalculation of unencrypted size aborted.'); |
|
527 | + $this->logger->error('Could not open '.$path.'. Recalculation of unencrypted size aborted.'); |
|
528 | 528 | return $unencryptedSize; |
529 | 529 | } |
530 | 530 | |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | // next highest is end of chunks, one subtracted is last one |
550 | 550 | // we have to read the last chunk, we can't just calculate it (because of padding etc) |
551 | 551 | |
552 | - $lastChunkNr = ceil($size/ $blockSize)-1; |
|
552 | + $lastChunkNr = ceil($size / $blockSize) - 1; |
|
553 | 553 | // calculate last chunk position |
554 | 554 | $lastChunkPos = ($lastChunkNr * $blockSize); |
555 | 555 | // try to fseek to the last chunk, if it fails we have to read the whole file |
@@ -557,16 +557,16 @@ discard block |
||
557 | 557 | $newUnencryptedSize += $lastChunkNr * $unencryptedBlockSize; |
558 | 558 | } |
559 | 559 | |
560 | - $lastChunkContentEncrypted=''; |
|
560 | + $lastChunkContentEncrypted = ''; |
|
561 | 561 | $count = $blockSize; |
562 | 562 | |
563 | 563 | while ($count > 0) { |
564 | - $data=fread($stream, $blockSize); |
|
565 | - $count=strlen($data); |
|
564 | + $data = fread($stream, $blockSize); |
|
565 | + $count = strlen($data); |
|
566 | 566 | $lastChunkContentEncrypted .= $data; |
567 | - if(strlen($lastChunkContentEncrypted) > $blockSize) { |
|
567 | + if (strlen($lastChunkContentEncrypted) > $blockSize) { |
|
568 | 568 | $newUnencryptedSize += $unencryptedBlockSize; |
569 | - $lastChunkContentEncrypted=substr($lastChunkContentEncrypted, $blockSize); |
|
569 | + $lastChunkContentEncrypted = substr($lastChunkContentEncrypted, $blockSize); |
|
570 | 570 | } |
571 | 571 | } |
572 | 572 | |
@@ -574,8 +574,8 @@ discard block |
||
574 | 574 | |
575 | 575 | // we have to decrypt the last chunk to get it actual size |
576 | 576 | $encryptionModule->begin($this->getFullPath($path), $this->uid, 'r', $header, []); |
577 | - $decryptedLastChunk = $encryptionModule->decrypt($lastChunkContentEncrypted, $lastChunkNr . 'end'); |
|
578 | - $decryptedLastChunk .= $encryptionModule->end($this->getFullPath($path), $lastChunkNr . 'end'); |
|
577 | + $decryptedLastChunk = $encryptionModule->decrypt($lastChunkContentEncrypted, $lastChunkNr.'end'); |
|
578 | + $decryptedLastChunk .= $encryptionModule->end($this->getFullPath($path), $lastChunkNr.'end'); |
|
579 | 579 | |
580 | 580 | // calc the real file size with the size of the last chunk |
581 | 581 | $newUnencryptedSize += strlen($decryptedLastChunk); |
@@ -659,7 +659,7 @@ discard block |
||
659 | 659 | $cacheInformation = [ |
660 | 660 | 'encrypted' => $isEncrypted, |
661 | 661 | ]; |
662 | - if($isEncrypted) { |
|
662 | + if ($isEncrypted) { |
|
663 | 663 | $encryptedVersion = $sourceStorage->getCache()->get($sourceInternalPath)['encryptedVersion']; |
664 | 664 | |
665 | 665 | // In case of a move operation from an unencrypted to an encrypted |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | // correct value would be "1". Thus we manually set the value to "1" |
668 | 668 | // for those cases. |
669 | 669 | // See also https://github.com/owncloud/core/issues/23078 |
670 | - if($encryptedVersion === 0 || !$keepEncryptionVersion) { |
|
670 | + if ($encryptedVersion === 0 || !$keepEncryptionVersion) { |
|
671 | 671 | $encryptedVersion = 1; |
672 | 672 | } |
673 | 673 | |
@@ -703,9 +703,9 @@ discard block |
||
703 | 703 | // remember that we try to create a version so that we can detect it during |
704 | 704 | // fopen($sourceInternalPath) and by-pass the encryption in order to |
705 | 705 | // create a 1:1 copy of the file |
706 | - $this->arrayCache->set('encryption_copy_version_' . $sourceInternalPath, true); |
|
706 | + $this->arrayCache->set('encryption_copy_version_'.$sourceInternalPath, true); |
|
707 | 707 | $result = $this->storage->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); |
708 | - $this->arrayCache->remove('encryption_copy_version_' . $sourceInternalPath); |
|
708 | + $this->arrayCache->remove('encryption_copy_version_'.$sourceInternalPath); |
|
709 | 709 | if ($result) { |
710 | 710 | $info = $this->getCache('', $sourceStorage)->get($sourceInternalPath); |
711 | 711 | // make sure that we update the unencrypted size for the version |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | $mount = $this->mountManager->findByStorageId($sourceStorage->getId()); |
726 | 726 | if (count($mount) === 1) { |
727 | 727 | $mountPoint = $mount[0]->getMountPoint(); |
728 | - $source = $mountPoint . '/' . $sourceInternalPath; |
|
728 | + $source = $mountPoint.'/'.$sourceInternalPath; |
|
729 | 729 | $target = $this->getFullPath($targetInternalPath); |
730 | 730 | $this->copyKeys($source, $target); |
731 | 731 | } else { |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | if (is_resource($dh)) { |
739 | 739 | while ($result and ($file = readdir($dh)) !== false) { |
740 | 740 | if (!Filesystem::isIgnoredDir($file)) { |
741 | - $result &= $this->copyFromStorage($sourceStorage, $sourceInternalPath . '/' . $file, $targetInternalPath . '/' . $file, false, $isRename); |
|
741 | + $result &= $this->copyFromStorage($sourceStorage, $sourceInternalPath.'/'.$file, $targetInternalPath.'/'.$file, false, $isRename); |
|
742 | 742 | } |
743 | 743 | } |
744 | 744 | } |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | fclose($target); |
755 | 755 | throw $e; |
756 | 756 | } |
757 | - if($result) { |
|
757 | + if ($result) { |
|
758 | 758 | if ($preserveMtime) { |
759 | 759 | $this->touch($targetInternalPath, $sourceStorage->filemtime($sourceInternalPath)); |
760 | 760 | } |
@@ -766,7 +766,7 @@ discard block |
||
766 | 766 | $this->getCache()->remove($targetInternalPath); |
767 | 767 | } |
768 | 768 | } |
769 | - return (bool)$result; |
|
769 | + return (bool) $result; |
|
770 | 770 | |
771 | 771 | } |
772 | 772 | |
@@ -837,7 +837,7 @@ discard block |
||
837 | 837 | * @return string full path including mount point |
838 | 838 | */ |
839 | 839 | protected function getFullPath($path) { |
840 | - return Filesystem::normalizePath($this->mountPoint . '/' . $path); |
|
840 | + return Filesystem::normalizePath($this->mountPoint.'/'.$path); |
|
841 | 841 | } |
842 | 842 | |
843 | 843 | /** |
@@ -893,7 +893,7 @@ discard block |
||
893 | 893 | $header = substr($header, 0, $endAt + strlen(Util::HEADER_END)); |
894 | 894 | |
895 | 895 | // +1 to not start with an ':' which would result in empty element at the beginning |
896 | - $exploded = explode(':', substr($header, strlen(Util::HEADER_START)+1)); |
|
896 | + $exploded = explode(':', substr($header, strlen(Util::HEADER_START) + 1)); |
|
897 | 897 | |
898 | 898 | $element = array_shift($exploded); |
899 | 899 | while ($element !== Util::HEADER_END) { |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | try { |
957 | 957 | $encryptionModule = $this->encryptionManager->getEncryptionModule($encryptionModuleId); |
958 | 958 | } catch (ModuleDoesNotExistsException $e) { |
959 | - $this->logger->critical('Encryption module defined in "' . $path . '" not loaded!'); |
|
959 | + $this->logger->critical('Encryption module defined in "'.$path.'" not loaded!'); |
|
960 | 960 | throw $e; |
961 | 961 | } |
962 | 962 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | if (is_string($params['secure'])) { |
104 | 104 | $this->secure = ($params['secure'] === 'true'); |
105 | 105 | } else { |
106 | - $this->secure = (bool)$params['secure']; |
|
106 | + $this->secure = (bool) $params['secure']; |
|
107 | 107 | } |
108 | 108 | } else { |
109 | 109 | $this->secure = false; |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | } |
121 | 121 | } |
122 | 122 | $this->root = $params['root'] ?? '/'; |
123 | - $this->root = '/' . ltrim($this->root, '/'); |
|
124 | - $this->root = rtrim($this->root, '/') . '/'; |
|
123 | + $this->root = '/'.ltrim($this->root, '/'); |
|
124 | + $this->root = rtrim($this->root, '/').'/'; |
|
125 | 125 | } else { |
126 | 126 | throw new \Exception('Invalid webdav storage configuration'); |
127 | 127 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | |
164 | 164 | /** {@inheritdoc} */ |
165 | 165 | public function getId() { |
166 | - return 'webdav::' . $this->user . '@' . $this->host . '/' . $this->root; |
|
166 | + return 'webdav::'.$this->user.'@'.$this->host.'/'.$this->root; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** {@inheritdoc} */ |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | if ($this->secure) { |
173 | 173 | $baseUri .= 's'; |
174 | 174 | } |
175 | - $baseUri .= '://' . $this->host . $this->root; |
|
175 | + $baseUri .= '://'.$this->host.$this->root; |
|
176 | 176 | return $baseUri; |
177 | 177 | } |
178 | 178 | |
@@ -193,8 +193,8 @@ discard block |
||
193 | 193 | $path = $this->cleanPath($path); |
194 | 194 | // FIXME: some WebDAV impl return 403 when trying to DELETE |
195 | 195 | // a non-empty folder |
196 | - $result = $this->simpleResponse('DELETE', $path . '/', null, 204); |
|
197 | - $this->statCache->clear($path . '/'); |
|
196 | + $result = $this->simpleResponse('DELETE', $path.'/', null, 204); |
|
197 | + $this->statCache->clear($path.'/'); |
|
198 | 198 | $this->statCache->remove($path); |
199 | 199 | return $result; |
200 | 200 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | $this->statCache->set($path, $response); |
270 | 270 | } catch (ClientHttpException $e) { |
271 | 271 | if ($e->getHttpStatus() === 404) { |
272 | - $this->statCache->clear($path . '/'); |
|
272 | + $this->statCache->clear($path.'/'); |
|
273 | 273 | $this->statCache->set($path, false); |
274 | 274 | return false; |
275 | 275 | } |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | $this->init(); |
327 | 327 | $path = $this->cleanPath($path); |
328 | 328 | $result = $this->simpleResponse('DELETE', $path, null, 204); |
329 | - $this->statCache->clear($path . '/'); |
|
329 | + $this->statCache->clear($path.'/'); |
|
330 | 330 | $this->statCache->remove($path); |
331 | 331 | return $result; |
332 | 332 | } |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | try { |
342 | 342 | $response = $this->httpClientService |
343 | 343 | ->newClient() |
344 | - ->get($this->createBaseUri() . $this->encodePath($path), [ |
|
344 | + ->get($this->createBaseUri().$this->encodePath($path), [ |
|
345 | 345 | 'auth' => [$this->user, $this->password], |
346 | 346 | 'stream' => true |
347 | 347 | ]); |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | if ($response->getStatusCode() === Http::STATUS_LOCKED) { |
359 | 359 | throw new \OCP\Lock\LockedException($path); |
360 | 360 | } else { |
361 | - Util::writeLog("webdav client", 'Guzzle get returned status code ' . $response->getStatusCode(), ILogger::ERROR); |
|
361 | + Util::writeLog("webdav client", 'Guzzle get returned status code '.$response->getStatusCode(), ILogger::ERROR); |
|
362 | 362 | } |
363 | 363 | } |
364 | 364 | |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | $tmpFile = $tempManager->getTemporaryFile($ext); |
399 | 399 | } |
400 | 400 | $handle = fopen($tmpFile, $mode); |
401 | - return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) { |
|
401 | + return CallbackWrapper::wrap($handle, null, null, function() use ($path, $tmpFile) { |
|
402 | 402 | $this->writeBack($tmpFile, $path); |
403 | 403 | }); |
404 | 404 | } |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | return FileInfo::SPACE_UNKNOWN; |
424 | 424 | } |
425 | 425 | if (isset($response['{DAV:}quota-available-bytes'])) { |
426 | - return (int)$response['{DAV:}quota-available-bytes']; |
|
426 | + return (int) $response['{DAV:}quota-available-bytes']; |
|
427 | 427 | } else { |
428 | 428 | return FileInfo::SPACE_UNKNOWN; |
429 | 429 | } |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | |
500 | 500 | $this->httpClientService |
501 | 501 | ->newClient() |
502 | - ->put($this->createBaseUri() . $this->encodePath($target), [ |
|
502 | + ->put($this->createBaseUri().$this->encodePath($target), [ |
|
503 | 503 | 'body' => $source, |
504 | 504 | 'auth' => [$this->user, $this->password] |
505 | 505 | ]); |
@@ -516,18 +516,18 @@ discard block |
||
516 | 516 | // overwrite directory ? |
517 | 517 | if ($this->is_dir($path2)) { |
518 | 518 | // needs trailing slash in destination |
519 | - $path2 = rtrim($path2, '/') . '/'; |
|
519 | + $path2 = rtrim($path2, '/').'/'; |
|
520 | 520 | } |
521 | 521 | $this->client->request( |
522 | 522 | 'MOVE', |
523 | 523 | $this->encodePath($path1), |
524 | 524 | null, |
525 | 525 | [ |
526 | - 'Destination' => $this->createBaseUri() . $this->encodePath($path2), |
|
526 | + 'Destination' => $this->createBaseUri().$this->encodePath($path2), |
|
527 | 527 | ] |
528 | 528 | ); |
529 | - $this->statCache->clear($path1 . '/'); |
|
530 | - $this->statCache->clear($path2 . '/'); |
|
529 | + $this->statCache->clear($path1.'/'); |
|
530 | + $this->statCache->clear($path2.'/'); |
|
531 | 531 | $this->statCache->set($path1, false); |
532 | 532 | $this->statCache->set($path2, true); |
533 | 533 | $this->removeCachedFile($path1); |
@@ -548,17 +548,17 @@ discard block |
||
548 | 548 | // overwrite directory ? |
549 | 549 | if ($this->is_dir($path2)) { |
550 | 550 | // needs trailing slash in destination |
551 | - $path2 = rtrim($path2, '/') . '/'; |
|
551 | + $path2 = rtrim($path2, '/').'/'; |
|
552 | 552 | } |
553 | 553 | $this->client->request( |
554 | 554 | 'COPY', |
555 | 555 | $this->encodePath($path1), |
556 | 556 | null, |
557 | 557 | [ |
558 | - 'Destination' => $this->createBaseUri() . $this->encodePath($path2), |
|
558 | + 'Destination' => $this->createBaseUri().$this->encodePath($path2), |
|
559 | 559 | ] |
560 | 560 | ); |
561 | - $this->statCache->clear($path2 . '/'); |
|
561 | + $this->statCache->clear($path2.'/'); |
|
562 | 562 | $this->statCache->set($path2, true); |
563 | 563 | $this->removeCachedFile($path2); |
564 | 564 | return true; |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | } |
578 | 578 | return [ |
579 | 579 | 'mtime' => strtotime($response['{DAV:}getlastmodified']), |
580 | - 'size' => (int)isset($response['{DAV:}getcontentlength']) ? $response['{DAV:}getcontentlength'] : 0, |
|
580 | + 'size' => (int) isset($response['{DAV:}getcontentlength']) ? $response['{DAV:}getcontentlength'] : 0, |
|
581 | 581 | ]; |
582 | 582 | } catch (\Exception $e) { |
583 | 583 | $this->convertException($e, $path); |
@@ -659,7 +659,7 @@ discard block |
||
659 | 659 | return $response['statusCode'] == $expected; |
660 | 660 | } catch (ClientHttpException $e) { |
661 | 661 | if ($e->getHttpStatus() === 404 && $method === 'DELETE') { |
662 | - $this->statCache->clear($path . '/'); |
|
662 | + $this->statCache->clear($path.'/'); |
|
663 | 663 | $this->statCache->set($path, false); |
664 | 664 | return false; |
665 | 665 | } |
@@ -680,22 +680,22 @@ discard block |
||
680 | 680 | |
681 | 681 | /** {@inheritdoc} */ |
682 | 682 | public function isUpdatable($path) { |
683 | - return (bool)($this->getPermissions($path) & Constants::PERMISSION_UPDATE); |
|
683 | + return (bool) ($this->getPermissions($path) & Constants::PERMISSION_UPDATE); |
|
684 | 684 | } |
685 | 685 | |
686 | 686 | /** {@inheritdoc} */ |
687 | 687 | public function isCreatable($path) { |
688 | - return (bool)($this->getPermissions($path) & Constants::PERMISSION_CREATE); |
|
688 | + return (bool) ($this->getPermissions($path) & Constants::PERMISSION_CREATE); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | /** {@inheritdoc} */ |
692 | 692 | public function isSharable($path) { |
693 | - return (bool)($this->getPermissions($path) & Constants::PERMISSION_SHARE); |
|
693 | + return (bool) ($this->getPermissions($path) & Constants::PERMISSION_SHARE); |
|
694 | 694 | } |
695 | 695 | |
696 | 696 | /** {@inheritdoc} */ |
697 | 697 | public function isDeletable($path) { |
698 | - return (bool)($this->getPermissions($path) & Constants::PERMISSION_DELETE); |
|
698 | + return (bool) ($this->getPermissions($path) & Constants::PERMISSION_DELETE); |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | /** {@inheritdoc} */ |
@@ -784,7 +784,7 @@ discard block |
||
784 | 784 | if (!empty($etag) && $cachedData['etag'] !== $etag) { |
785 | 785 | return true; |
786 | 786 | } else if (isset($response['{http://open-collaboration-services.org/ns}share-permissions'])) { |
787 | - $sharePermissions = (int)$response['{http://open-collaboration-services.org/ns}share-permissions']; |
|
787 | + $sharePermissions = (int) $response['{http://open-collaboration-services.org/ns}share-permissions']; |
|
788 | 788 | return $sharePermissions !== $cachedData['permissions']; |
789 | 789 | } else if (isset($response['{http://owncloud.org/ns}permissions'])) { |
790 | 790 | $permissions = $this->parsePermissions($response['{http://owncloud.org/ns}permissions']); |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | if ($e->getHttpStatus() === 405) { |
801 | 801 | if ($path === '') { |
802 | 802 | // if root is gone it means the storage is not available |
803 | - throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage()); |
|
803 | + throw new StorageNotAvailableException(get_class($e).': '.$e->getMessage()); |
|
804 | 804 | } |
805 | 805 | return false; |
806 | 806 | } |
@@ -834,19 +834,19 @@ discard block |
||
834 | 834 | } |
835 | 835 | if ($e->getHttpStatus() === Http::STATUS_UNAUTHORIZED) { |
836 | 836 | // either password was changed or was invalid all along |
837 | - throw new StorageInvalidException(get_class($e) . ': ' . $e->getMessage()); |
|
837 | + throw new StorageInvalidException(get_class($e).': '.$e->getMessage()); |
|
838 | 838 | } else if ($e->getHttpStatus() === Http::STATUS_METHOD_NOT_ALLOWED) { |
839 | 839 | // ignore exception for MethodNotAllowed, false will be returned |
840 | 840 | return; |
841 | 841 | } |
842 | - throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage()); |
|
842 | + throw new StorageNotAvailableException(get_class($e).': '.$e->getMessage()); |
|
843 | 843 | } else if ($e instanceof ClientException) { |
844 | 844 | // connection timeout or refused, server could be temporarily down |
845 | - throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage()); |
|
845 | + throw new StorageNotAvailableException(get_class($e).': '.$e->getMessage()); |
|
846 | 846 | } else if ($e instanceof \InvalidArgumentException) { |
847 | 847 | // parse error because the server returned HTML instead of XML, |
848 | 848 | // possibly temporarily down |
849 | - throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage()); |
|
849 | + throw new StorageNotAvailableException(get_class($e).': '.$e->getMessage()); |
|
850 | 850 | } else if (($e instanceof StorageNotAvailableException) || ($e instanceof StorageInvalidException)) { |
851 | 851 | // rethrow |
852 | 852 | throw $e; |
@@ -33,21 +33,21 @@ discard block |
||
33 | 33 | use Icewind\Streams\CallbackWrapper; |
34 | 34 | use OCP\ILogger; |
35 | 35 | |
36 | -class ZIP extends Archive{ |
|
36 | +class ZIP extends Archive { |
|
37 | 37 | /** |
38 | 38 | * @var \ZipArchive zip |
39 | 39 | */ |
40 | - private $zip=null; |
|
40 | + private $zip = null; |
|
41 | 41 | private $path; |
42 | 42 | |
43 | 43 | /** |
44 | 44 | * @param string $source |
45 | 45 | */ |
46 | 46 | public function __construct($source) { |
47 | - $this->path=$source; |
|
48 | - $this->zip=new \ZipArchive(); |
|
49 | - if($this->zip->open($source, \ZipArchive::CREATE)) { |
|
50 | - }else{ |
|
47 | + $this->path = $source; |
|
48 | + $this->zip = new \ZipArchive(); |
|
49 | + if ($this->zip->open($source, \ZipArchive::CREATE)) { |
|
50 | + } else { |
|
51 | 51 | \OCP\Util::writeLog('files_archive', 'Error while opening archive '.$source, ILogger::WARN); |
52 | 52 | } |
53 | 53 | } |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | * @param string $source either a local file or string data |
66 | 66 | * @return bool |
67 | 67 | */ |
68 | - public function addFile($path, $source='') { |
|
69 | - if($source and $source[0]=='/' and file_exists($source)) { |
|
70 | - $result=$this->zip->addFile($source, $path); |
|
71 | - }else{ |
|
72 | - $result=$this->zip->addFromString($path, $source); |
|
68 | + public function addFile($path, $source = '') { |
|
69 | + if ($source and $source[0] == '/' and file_exists($source)) { |
|
70 | + $result = $this->zip->addFile($source, $path); |
|
71 | + } else { |
|
72 | + $result = $this->zip->addFromString($path, $source); |
|
73 | 73 | } |
74 | - if($result) { |
|
75 | - $this->zip->close();//close and reopen to save the zip |
|
74 | + if ($result) { |
|
75 | + $this->zip->close(); //close and reopen to save the zip |
|
76 | 76 | $this->zip->open($this->path); |
77 | 77 | } |
78 | 78 | return $result; |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | * @return boolean|null |
85 | 85 | */ |
86 | 86 | public function rename($source, $dest) { |
87 | - $source=$this->stripPath($source); |
|
88 | - $dest=$this->stripPath($dest); |
|
87 | + $source = $this->stripPath($source); |
|
88 | + $dest = $this->stripPath($dest); |
|
89 | 89 | $this->zip->renameName($source, $dest); |
90 | 90 | } |
91 | 91 | /** |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @return int |
95 | 95 | */ |
96 | 96 | public function filesize($path) { |
97 | - $stat=$this->zip->statName($path); |
|
97 | + $stat = $this->zip->statName($path); |
|
98 | 98 | return $stat['size']; |
99 | 99 | } |
100 | 100 | /** |
@@ -111,13 +111,13 @@ discard block |
||
111 | 111 | * @return array |
112 | 112 | */ |
113 | 113 | public function getFolder($path) { |
114 | - $files=$this->getFiles(); |
|
115 | - $folderContent=array(); |
|
116 | - $pathLength=strlen($path); |
|
117 | - foreach($files as $file) { |
|
118 | - if(substr($file, 0, $pathLength)==$path and $file!=$path) { |
|
119 | - if(strrpos(substr($file, 0, -1), '/')<=$pathLength) { |
|
120 | - $folderContent[]=substr($file, $pathLength); |
|
114 | + $files = $this->getFiles(); |
|
115 | + $folderContent = array(); |
|
116 | + $pathLength = strlen($path); |
|
117 | + foreach ($files as $file) { |
|
118 | + if (substr($file, 0, $pathLength) == $path and $file != $path) { |
|
119 | + if (strrpos(substr($file, 0, -1), '/') <= $pathLength) { |
|
120 | + $folderContent[] = substr($file, $pathLength); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 | } |
@@ -128,10 +128,10 @@ discard block |
||
128 | 128 | * @return array |
129 | 129 | */ |
130 | 130 | public function getFiles() { |
131 | - $fileCount=$this->zip->numFiles; |
|
132 | - $files=array(); |
|
133 | - for($i=0;$i<$fileCount;$i++) { |
|
134 | - $files[]=$this->zip->getNameIndex($i); |
|
131 | + $fileCount = $this->zip->numFiles; |
|
132 | + $files = array(); |
|
133 | + for ($i = 0; $i < $fileCount; $i++) { |
|
134 | + $files[] = $this->zip->getNameIndex($i); |
|
135 | 135 | } |
136 | 136 | return $files; |
137 | 137 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * @return bool |
168 | 168 | */ |
169 | 169 | public function fileExists($path) { |
170 | - return ($this->zip->locateName($path)!==false) or ($this->zip->locateName($path.'/')!==false); |
|
170 | + return ($this->zip->locateName($path) !== false) or ($this->zip->locateName($path.'/') !== false); |
|
171 | 171 | } |
172 | 172 | /** |
173 | 173 | * remove a file or folder from the archive |
@@ -175,9 +175,9 @@ discard block |
||
175 | 175 | * @return bool |
176 | 176 | */ |
177 | 177 | public function remove($path) { |
178 | - if($this->fileExists($path.'/')) { |
|
178 | + if ($this->fileExists($path.'/')) { |
|
179 | 179 | return $this->zip->deleteName($path.'/'); |
180 | - }else{ |
|
180 | + } else { |
|
181 | 181 | return $this->zip->deleteName($path); |
182 | 182 | } |
183 | 183 | } |
@@ -188,23 +188,23 @@ discard block |
||
188 | 188 | * @return resource |
189 | 189 | */ |
190 | 190 | public function getStream($path, $mode) { |
191 | - if($mode=='r' or $mode=='rb') { |
|
191 | + if ($mode == 'r' or $mode == 'rb') { |
|
192 | 192 | return $this->zip->getStream($path); |
193 | 193 | } else { |
194 | 194 | //since we can't directly get a writable stream, |
195 | 195 | //make a temp copy of the file and put it back |
196 | 196 | //in the archive when the stream is closed |
197 | - if(strrpos($path, '.')!==false) { |
|
198 | - $ext=substr($path, strrpos($path, '.')); |
|
199 | - }else{ |
|
200 | - $ext=''; |
|
197 | + if (strrpos($path, '.') !== false) { |
|
198 | + $ext = substr($path, strrpos($path, '.')); |
|
199 | + } else { |
|
200 | + $ext = ''; |
|
201 | 201 | } |
202 | 202 | $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext); |
203 | - if($this->fileExists($path)) { |
|
203 | + if ($this->fileExists($path)) { |
|
204 | 204 | $this->extractFile($path, $tmpFile); |
205 | 205 | } |
206 | 206 | $handle = fopen($tmpFile, $mode); |
207 | - return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) { |
|
207 | + return CallbackWrapper::wrap($handle, null, null, function() use ($path, $tmpFile) { |
|
208 | 208 | $this->writeBack($tmpFile, $path); |
209 | 209 | }); |
210 | 210 | } |
@@ -223,9 +223,9 @@ discard block |
||
223 | 223 | * @return string |
224 | 224 | */ |
225 | 225 | private function stripPath($path) { |
226 | - if(!$path || $path[0]=='/') { |
|
226 | + if (!$path || $path[0] == '/') { |
|
227 | 227 | return substr($path, 1); |
228 | - }else{ |
|
228 | + } else { |
|
229 | 229 | return $path; |
230 | 230 | } |
231 | 231 | } |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | $rootView = new View(); |
54 | 54 | $user = \OC::$server->getUserSession()->getUser(); |
55 | 55 | Filesystem::initMountPoints($user->getUID()); |
56 | - if (!$rootView->file_exists('/' . $user->getUID() . '/cache')) { |
|
57 | - $rootView->mkdir('/' . $user->getUID() . '/cache'); |
|
56 | + if (!$rootView->file_exists('/'.$user->getUID().'/cache')) { |
|
57 | + $rootView->mkdir('/'.$user->getUID().'/cache'); |
|
58 | 58 | } |
59 | - $this->storage = new View('/' . $user->getUID() . '/cache'); |
|
59 | + $this->storage = new View('/'.$user->getUID().'/cache'); |
|
60 | 60 | return $this->storage; |
61 | 61 | } else { |
62 | 62 | \OCP\Util::writeLog('core', 'Can\'t get cache storage, user not logged in', ILogger::ERROR); |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | // unique id to avoid chunk collision, just in case |
107 | 107 | $uniqueId = \OC::$server->getSecureRandom()->generate( |
108 | 108 | 16, |
109 | - ISecureRandom::CHAR_DIGITS . ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER |
|
109 | + ISecureRandom::CHAR_DIGITS.ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_UPPER |
|
110 | 110 | ); |
111 | 111 | |
112 | 112 | // use part file to prevent hasKey() to find the key |
113 | 113 | // while it is being written |
114 | - $keyPart = $key . '.' . $uniqueId . '.part'; |
|
114 | + $keyPart = $key.'.'.$uniqueId.'.part'; |
|
115 | 115 | if ($storage and $storage->file_put_contents($keyPart, $value)) { |
116 | 116 | if ($ttl === 0) { |
117 | 117 | $ttl = 86400; // 60*60*24 |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | if (is_resource($dh)) { |
161 | 161 | while (($file = readdir($dh)) !== false) { |
162 | 162 | if ($file != '.' and $file != '..' and ($prefix === '' || strpos($file, $prefix) === 0)) { |
163 | - $storage->unlink('/' . $file); |
|
163 | + $storage->unlink('/'.$file); |
|
164 | 164 | } |
165 | 165 | } |
166 | 166 | } |
@@ -185,17 +185,17 @@ discard block |
||
185 | 185 | while (($file = readdir($dh)) !== false) { |
186 | 186 | if ($file != '.' and $file != '..') { |
187 | 187 | try { |
188 | - $mtime = $storage->filemtime('/' . $file); |
|
188 | + $mtime = $storage->filemtime('/'.$file); |
|
189 | 189 | if ($mtime < $now) { |
190 | - $storage->unlink('/' . $file); |
|
190 | + $storage->unlink('/'.$file); |
|
191 | 191 | } |
192 | 192 | } catch (\OCP\Lock\LockedException $e) { |
193 | 193 | // ignore locked chunks |
194 | - \OC::$server->getLogger()->debug('Could not cleanup locked chunk "' . $file . '"', array('app' => 'core')); |
|
194 | + \OC::$server->getLogger()->debug('Could not cleanup locked chunk "'.$file.'"', array('app' => 'core')); |
|
195 | 195 | } catch (\OCP\Files\ForbiddenException $e) { |
196 | - \OC::$server->getLogger()->debug('Could not cleanup forbidden chunk "' . $file . '"', array('app' => 'core')); |
|
196 | + \OC::$server->getLogger()->debug('Could not cleanup forbidden chunk "'.$file.'"', array('app' => 'core')); |
|
197 | 197 | } catch (\OCP\Files\LockNotAcquiredException $e) { |
198 | - \OC::$server->getLogger()->debug('Could not cleanup locked chunk "' . $file . '"', array('app' => 'core')); |
|
198 | + \OC::$server->getLogger()->debug('Could not cleanup locked chunk "'.$file.'"', array('app' => 'core')); |
|
199 | 199 | } |
200 | 200 | } |
201 | 201 | } |
@@ -39,23 +39,23 @@ |
||
39 | 39 | /** |
40 | 40 | * @since 14.0.0 |
41 | 41 | */ |
42 | - const DEBUG=0; |
|
42 | + const DEBUG = 0; |
|
43 | 43 | /** |
44 | 44 | * @since 14.0.0 |
45 | 45 | */ |
46 | - const INFO=1; |
|
46 | + const INFO = 1; |
|
47 | 47 | /** |
48 | 48 | * @since 14.0.0 |
49 | 49 | */ |
50 | - const WARN=2; |
|
50 | + const WARN = 2; |
|
51 | 51 | /** |
52 | 52 | * @since 14.0.0 |
53 | 53 | */ |
54 | - const ERROR=3; |
|
54 | + const ERROR = 3; |
|
55 | 55 | /** |
56 | 56 | * @since 14.0.0 |
57 | 57 | */ |
58 | - const FATAL=4; |
|
58 | + const FATAL = 4; |
|
59 | 59 | |
60 | 60 | /** |
61 | 61 | * System is unusable. |