@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | Filesystem::initMountPoints($uid); |
| 90 | 90 | if ($uid !== OC_User::getUser()) { |
| 91 | 91 | $info = Filesystem::getFileInfo($filename); |
| 92 | - $ownerView = new View('/' . $uid . '/files'); |
|
| 92 | + $ownerView = new View('/'.$uid.'/files'); |
|
| 93 | 93 | try { |
| 94 | 94 | $filename = $ownerView->getPath($info['fileid']); |
| 95 | 95 | } catch (NotFoundException $e) { |
@@ -114,8 +114,8 @@ discard block |
||
| 114 | 114 | $array = []; |
| 115 | 115 | while ($row = $result->fetch()) { |
| 116 | 116 | $array[$row['id']][$row['timestamp']] = [ |
| 117 | - 'location' => (string)$row['location'], |
|
| 118 | - 'deletedBy' => (string)$row['deleted_by'], |
|
| 117 | + 'location' => (string) $row['location'], |
|
| 118 | + 'deletedBy' => (string) $row['deleted_by'], |
|
| 119 | 119 | ]; |
| 120 | 120 | } |
| 121 | 121 | $result->closeCursor(); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | |
| 152 | 152 | /** @param string $user */ |
| 153 | 153 | private static function setUpTrash($user): void { |
| 154 | - $view = new View('/' . $user); |
|
| 154 | + $view = new View('/'.$user); |
|
| 155 | 155 | if (!$view->is_dir('files_trashbin')) { |
| 156 | 156 | $view->mkdir('files_trashbin'); |
| 157 | 157 | } |
@@ -186,8 +186,8 @@ discard block |
||
| 186 | 186 | |
| 187 | 187 | $view = new View('/'); |
| 188 | 188 | |
| 189 | - $target = $user . '/files_trashbin/files/' . static::getTrashFilename($targetFilename, $timestamp); |
|
| 190 | - $source = $owner . '/files_trashbin/files/' . static::getTrashFilename($sourceFilename, $timestamp); |
|
| 189 | + $target = $user.'/files_trashbin/files/'.static::getTrashFilename($targetFilename, $timestamp); |
|
| 190 | + $source = $owner.'/files_trashbin/files/'.static::getTrashFilename($sourceFilename, $timestamp); |
|
| 191 | 191 | $free = $view->free_space($target); |
| 192 | 192 | $isUnknownOrUnlimitedFreeSpace = $free < 0; |
| 193 | 193 | $isEnoughFreeSpaceLeft = $view->filesize($source) < $free; |
@@ -232,14 +232,14 @@ discard block |
||
| 232 | 232 | $ownerPath = $file_path; |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - $ownerView = new View('/' . $owner); |
|
| 235 | + $ownerView = new View('/'.$owner); |
|
| 236 | 236 | |
| 237 | 237 | // file has been deleted in between |
| 238 | 238 | if (is_null($ownerPath) || $ownerPath === '') { |
| 239 | 239 | return true; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - $sourceInfo = $ownerView->getFileInfo('/files/' . $ownerPath); |
|
| 242 | + $sourceInfo = $ownerView->getFileInfo('/files/'.$ownerPath); |
|
| 243 | 243 | |
| 244 | 244 | if ($sourceInfo === false) { |
| 245 | 245 | return true; |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | $lockingProvider = Server::get(ILockingProvider::class); |
| 263 | 263 | |
| 264 | 264 | // disable proxy to prevent recursive calls |
| 265 | - $trashPath = '/files_trashbin/files/' . static::getTrashFilename($filename, $timestamp); |
|
| 265 | + $trashPath = '/files_trashbin/files/'.static::getTrashFilename($filename, $timestamp); |
|
| 266 | 266 | $gotLock = false; |
| 267 | 267 | |
| 268 | 268 | do { |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | |
| 278 | 278 | $timestamp = $timestamp + 1; |
| 279 | 279 | |
| 280 | - $trashPath = '/files_trashbin/files/' . static::getTrashFilename($filename, $timestamp); |
|
| 280 | + $trashPath = '/files_trashbin/files/'.static::getTrashFilename($filename, $timestamp); |
|
| 281 | 281 | } |
| 282 | 282 | } while (!$gotLock); |
| 283 | 283 | |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | if ($trashStorage->file_exists($trashInternalPath)) { |
| 307 | 307 | $trashStorage->unlink($trashInternalPath); |
| 308 | 308 | } |
| 309 | - Server::get(LoggerInterface::class)->error('Couldn\'t move ' . $file_path . ' to the trash bin', ['app' => 'files_trashbin']); |
|
| 309 | + Server::get(LoggerInterface::class)->error('Couldn\'t move '.$file_path.' to the trash bin', ['app' => 'files_trashbin']); |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | if ($sourceStorage->file_exists($sourceInternalPath)) { // failed to delete the original file, abort |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | return $moveSuccessful; |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - private static function getConfiguredTrashbinSize(string $user): int|float { |
|
| 363 | + private static function getConfiguredTrashbinSize(string $user): int | float { |
|
| 364 | 364 | $config = Server::get(IConfig::class); |
| 365 | 365 | $userTrashbinSize = $config->getUserValue($user, 'files_trashbin', 'trashbin_size', '-1'); |
| 366 | 366 | if (is_numeric($userTrashbinSize) && ($userTrashbinSize > -1)) { |
@@ -386,17 +386,17 @@ discard block |
||
| 386 | 386 | $user = OC_User::getUser(); |
| 387 | 387 | $rootView = new View('/'); |
| 388 | 388 | |
| 389 | - if ($rootView->is_dir($owner . '/files_versions/' . $ownerPath)) { |
|
| 389 | + if ($rootView->is_dir($owner.'/files_versions/'.$ownerPath)) { |
|
| 390 | 390 | if ($owner !== $user) { |
| 391 | - self::copy_recursive($owner . '/files_versions/' . $ownerPath, $owner . '/files_trashbin/versions/' . static::getTrashFilename(basename($ownerPath), $timestamp), $rootView); |
|
| 391 | + self::copy_recursive($owner.'/files_versions/'.$ownerPath, $owner.'/files_trashbin/versions/'.static::getTrashFilename(basename($ownerPath), $timestamp), $rootView); |
|
| 392 | 392 | } |
| 393 | - self::move($rootView, $owner . '/files_versions/' . $ownerPath, $user . '/files_trashbin/versions/' . static::getTrashFilename($filename, $timestamp)); |
|
| 393 | + self::move($rootView, $owner.'/files_versions/'.$ownerPath, $user.'/files_trashbin/versions/'.static::getTrashFilename($filename, $timestamp)); |
|
| 394 | 394 | } elseif ($versions = Storage::getVersions($owner, $ownerPath)) { |
| 395 | 395 | foreach ($versions as $v) { |
| 396 | 396 | if ($owner !== $user) { |
| 397 | - self::copy($rootView, $owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $owner . '/files_trashbin/versions/' . static::getTrashFilename($v['name'] . '.v' . $v['version'], $timestamp)); |
|
| 397 | + self::copy($rootView, $owner.'/files_versions'.$v['path'].'.v'.$v['version'], $owner.'/files_trashbin/versions/'.static::getTrashFilename($v['name'].'.v'.$v['version'], $timestamp)); |
|
| 398 | 398 | } |
| 399 | - self::move($rootView, $owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $user . '/files_trashbin/versions/' . static::getTrashFilename($filename . '.v' . $v['version'], $timestamp)); |
|
| 399 | + self::move($rootView, $owner.'/files_versions'.$v['path'].'.v'.$v['version'], $user.'/files_trashbin/versions/'.static::getTrashFilename($filename.'.v'.$v['version'], $timestamp)); |
|
| 400 | 400 | } |
| 401 | 401 | } |
| 402 | 402 | } |
@@ -461,18 +461,18 @@ discard block |
||
| 461 | 461 | if (!$user) { |
| 462 | 462 | throw new \Exception('Tried to restore a file while not logged in'); |
| 463 | 463 | } |
| 464 | - $view = new View('/' . $user); |
|
| 464 | + $view = new View('/'.$user); |
|
| 465 | 465 | |
| 466 | 466 | $location = ''; |
| 467 | 467 | if ($timestamp) { |
| 468 | 468 | $location = self::getLocation($user, $filename, $timestamp); |
| 469 | 469 | if ($location === false) { |
| 470 | - Server::get(LoggerInterface::class)->error('trash bin database inconsistent! ($user: ' . $user . ' $filename: ' . $filename . ', $timestamp: ' . $timestamp . ')', ['app' => 'files_trashbin']); |
|
| 470 | + Server::get(LoggerInterface::class)->error('trash bin database inconsistent! ($user: '.$user.' $filename: '.$filename.', $timestamp: '.$timestamp.')', ['app' => 'files_trashbin']); |
|
| 471 | 471 | } else { |
| 472 | 472 | // if location no longer exists, restore file in the root directory |
| 473 | 473 | if ($location !== '/' |
| 474 | - && (!$view->is_dir('files/' . $location) |
|
| 475 | - || !$view->isCreatable('files/' . $location)) |
|
| 474 | + && (!$view->is_dir('files/'.$location) |
|
| 475 | + || !$view->isCreatable('files/'.$location)) |
|
| 476 | 476 | ) { |
| 477 | 477 | $location = ''; |
| 478 | 478 | } |
@@ -482,8 +482,8 @@ discard block |
||
| 482 | 482 | // we need a extension in case a file/dir with the same name already exists |
| 483 | 483 | $uniqueFilename = self::getUniqueFilename($location, $filename, $view); |
| 484 | 484 | |
| 485 | - $source = Filesystem::normalizePath('files_trashbin/files/' . $file); |
|
| 486 | - $target = Filesystem::normalizePath('files/' . $location . '/' . $uniqueFilename); |
|
| 485 | + $source = Filesystem::normalizePath('files_trashbin/files/'.$file); |
|
| 486 | + $target = Filesystem::normalizePath('files/'.$location.'/'.$uniqueFilename); |
|
| 487 | 487 | if (!$view->file_exists($source)) { |
| 488 | 488 | return false; |
| 489 | 489 | } |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | $sourcePath = Filesystem::normalizePath($file); |
| 498 | - $targetPath = Filesystem::normalizePath('/' . $location . '/' . $uniqueFilename); |
|
| 498 | + $targetPath = Filesystem::normalizePath('/'.$location.'/'.$uniqueFilename); |
|
| 499 | 499 | |
| 500 | 500 | $sourceNode = self::getNodeForPath($user, $sourcePath); |
| 501 | 501 | $targetNode = self::getNodeForPath($user, $targetPath, 'files'); |
@@ -513,8 +513,8 @@ discard block |
||
| 513 | 513 | // handle the restore result |
| 514 | 514 | if ($restoreResult) { |
| 515 | 515 | $fakeRoot = $view->getRoot(); |
| 516 | - $view->chroot('/' . $user . '/files'); |
|
| 517 | - $view->touch('/' . $location . '/' . $uniqueFilename, $mtime); |
|
| 516 | + $view->chroot('/'.$user.'/files'); |
|
| 517 | + $view->touch('/'.$location.'/'.$uniqueFilename, $mtime); |
|
| 518 | 518 | $view->chroot($fakeRoot); |
| 519 | 519 | Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', ['filePath' => $targetPath, 'trashPath' => $sourcePath]); |
| 520 | 520 | |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | $user = OC_User::getUser(); |
| 558 | 558 | $rootView = new View('/'); |
| 559 | 559 | |
| 560 | - $target = Filesystem::normalizePath('/' . $location . '/' . $uniqueFilename); |
|
| 560 | + $target = Filesystem::normalizePath('/'.$location.'/'.$uniqueFilename); |
|
| 561 | 561 | |
| 562 | 562 | [$owner, $ownerPath] = self::getUidAndFilename($target); |
| 563 | 563 | |
@@ -572,14 +572,14 @@ discard block |
||
| 572 | 572 | $versionedFile = $file; |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - if ($view->is_dir('/files_trashbin/versions/' . $file)) { |
|
| 576 | - $rootView->rename(Filesystem::normalizePath($user . '/files_trashbin/versions/' . $file), Filesystem::normalizePath($owner . '/files_versions/' . $ownerPath)); |
|
| 575 | + if ($view->is_dir('/files_trashbin/versions/'.$file)) { |
|
| 576 | + $rootView->rename(Filesystem::normalizePath($user.'/files_trashbin/versions/'.$file), Filesystem::normalizePath($owner.'/files_versions/'.$ownerPath)); |
|
| 577 | 577 | } elseif ($versions = self::getVersionsFromTrash($versionedFile, $timestamp, $user)) { |
| 578 | 578 | foreach ($versions as $v) { |
| 579 | 579 | if ($timestamp) { |
| 580 | - $rootView->rename($user . '/files_trashbin/versions/' . static::getTrashFilename($versionedFile . '.v' . $v, $timestamp), $owner . '/files_versions/' . $ownerPath . '.v' . $v); |
|
| 580 | + $rootView->rename($user.'/files_trashbin/versions/'.static::getTrashFilename($versionedFile.'.v'.$v, $timestamp), $owner.'/files_versions/'.$ownerPath.'.v'.$v); |
|
| 581 | 581 | } else { |
| 582 | - $rootView->rename($user . '/files_trashbin/versions/' . $versionedFile . '.v' . $v, $owner . '/files_versions/' . $ownerPath . '.v' . $v); |
|
| 582 | + $rootView->rename($user.'/files_trashbin/versions/'.$versionedFile.'.v'.$v, $owner.'/files_versions/'.$ownerPath.'.v'.$v); |
|
| 583 | 583 | } |
| 584 | 584 | } |
| 585 | 585 | } |
@@ -592,7 +592,7 @@ discard block |
||
| 592 | 592 | public static function deleteAll() { |
| 593 | 593 | $user = OC_User::getUser(); |
| 594 | 594 | $userRoot = \OC::$server->getUserFolder($user)->getParent(); |
| 595 | - $view = new View('/' . $user); |
|
| 595 | + $view = new View('/'.$user); |
|
| 596 | 596 | $fileInfos = $view->getDirectoryContent('files_trashbin/files'); |
| 597 | 597 | |
| 598 | 598 | try { |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | */ |
| 668 | 668 | public static function delete($filename, $user, $timestamp = null) { |
| 669 | 669 | $userRoot = \OC::$server->getUserFolder($user)->getParent(); |
| 670 | - $view = new View('/' . $user); |
|
| 670 | + $view = new View('/'.$user); |
|
| 671 | 671 | $size = 0; |
| 672 | 672 | |
| 673 | 673 | if ($timestamp) { |
@@ -686,20 +686,20 @@ discard block |
||
| 686 | 686 | $size += self::deleteVersions($view, $file, $filename, $timestamp, $user); |
| 687 | 687 | |
| 688 | 688 | try { |
| 689 | - $node = $userRoot->get('/files_trashbin/files/' . $file); |
|
| 689 | + $node = $userRoot->get('/files_trashbin/files/'.$file); |
|
| 690 | 690 | } catch (NotFoundException $e) { |
| 691 | 691 | return $size; |
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | if ($node instanceof Folder) { |
| 695 | - $size += self::calculateSize(new View('/' . $user . '/files_trashbin/files/' . $file)); |
|
| 695 | + $size += self::calculateSize(new View('/'.$user.'/files_trashbin/files/'.$file)); |
|
| 696 | 696 | } elseif ($node instanceof File) { |
| 697 | - $size += $view->filesize('/files_trashbin/files/' . $file); |
|
| 697 | + $size += $view->filesize('/files_trashbin/files/'.$file); |
|
| 698 | 698 | } |
| 699 | 699 | |
| 700 | - self::emitTrashbinPreDelete('/files_trashbin/files/' . $file); |
|
| 700 | + self::emitTrashbinPreDelete('/files_trashbin/files/'.$file); |
|
| 701 | 701 | $node->delete(); |
| 702 | - self::emitTrashbinPostDelete('/files_trashbin/files/' . $file); |
|
| 702 | + self::emitTrashbinPostDelete('/files_trashbin/files/'.$file); |
|
| 703 | 703 | |
| 704 | 704 | return $size; |
| 705 | 705 | } |
@@ -709,20 +709,20 @@ discard block |
||
| 709 | 709 | * @param string $filename |
| 710 | 710 | * @param ?int $timestamp |
| 711 | 711 | */ |
| 712 | - private static function deleteVersions(View $view, $file, $filename, $timestamp, string $user): int|float { |
|
| 712 | + private static function deleteVersions(View $view, $file, $filename, $timestamp, string $user): int | float { |
|
| 713 | 713 | $size = 0; |
| 714 | 714 | if (Server::get(IAppManager::class)->isEnabledForUser('files_versions')) { |
| 715 | - if ($view->is_dir('files_trashbin/versions/' . $file)) { |
|
| 716 | - $size += self::calculateSize(new View('/' . $user . '/files_trashbin/versions/' . $file)); |
|
| 717 | - $view->unlink('files_trashbin/versions/' . $file); |
|
| 715 | + if ($view->is_dir('files_trashbin/versions/'.$file)) { |
|
| 716 | + $size += self::calculateSize(new View('/'.$user.'/files_trashbin/versions/'.$file)); |
|
| 717 | + $view->unlink('files_trashbin/versions/'.$file); |
|
| 718 | 718 | } elseif ($versions = self::getVersionsFromTrash($filename, $timestamp, $user)) { |
| 719 | 719 | foreach ($versions as $v) { |
| 720 | 720 | if ($timestamp) { |
| 721 | - $size += $view->filesize('/files_trashbin/versions/' . static::getTrashFilename($filename . '.v' . $v, $timestamp)); |
|
| 722 | - $view->unlink('/files_trashbin/versions/' . static::getTrashFilename($filename . '.v' . $v, $timestamp)); |
|
| 721 | + $size += $view->filesize('/files_trashbin/versions/'.static::getTrashFilename($filename.'.v'.$v, $timestamp)); |
|
| 722 | + $view->unlink('/files_trashbin/versions/'.static::getTrashFilename($filename.'.v'.$v, $timestamp)); |
|
| 723 | 723 | } else { |
| 724 | - $size += $view->filesize('/files_trashbin/versions/' . $filename . '.v' . $v); |
|
| 725 | - $view->unlink('/files_trashbin/versions/' . $filename . '.v' . $v); |
|
| 724 | + $size += $view->filesize('/files_trashbin/versions/'.$filename.'.v'.$v); |
|
| 725 | + $view->unlink('/files_trashbin/versions/'.$filename.'.v'.$v); |
|
| 726 | 726 | } |
| 727 | 727 | } |
| 728 | 728 | } |
@@ -739,13 +739,13 @@ discard block |
||
| 739 | 739 | */ |
| 740 | 740 | public static function file_exists($filename, $timestamp = null) { |
| 741 | 741 | $user = OC_User::getUser(); |
| 742 | - $view = new View('/' . $user); |
|
| 742 | + $view = new View('/'.$user); |
|
| 743 | 743 | |
| 744 | 744 | if ($timestamp) { |
| 745 | 745 | $filename = static::getTrashFilename($filename, $timestamp); |
| 746 | 746 | } |
| 747 | 747 | |
| 748 | - $target = Filesystem::normalizePath('files_trashbin/files/' . $filename); |
|
| 748 | + $target = Filesystem::normalizePath('files_trashbin/files/'.$filename); |
|
| 749 | 749 | return $view->file_exists($target); |
| 750 | 750 | } |
| 751 | 751 | |
@@ -759,7 +759,7 @@ discard block |
||
| 759 | 759 | $query = Server::get(IDBConnection::class)->getQueryBuilder(); |
| 760 | 760 | $query->delete('files_trash') |
| 761 | 761 | ->where($query->expr()->eq('user', $query->createNamedParameter($uid))); |
| 762 | - return (bool)$query->executeStatement(); |
|
| 762 | + return (bool) $query->executeStatement(); |
|
| 763 | 763 | } |
| 764 | 764 | |
| 765 | 765 | /** |
@@ -769,7 +769,7 @@ discard block |
||
| 769 | 769 | * @param string $user |
| 770 | 770 | * @return int|float available free space for trash bin |
| 771 | 771 | */ |
| 772 | - private static function calculateFreeSpace(int|float $trashbinSize, string $user): int|float { |
|
| 772 | + private static function calculateFreeSpace(int | float $trashbinSize, string $user): int | float { |
|
| 773 | 773 | $configuredTrashbinSize = static::getConfiguredTrashbinSize($user); |
| 774 | 774 | if ($configuredTrashbinSize > -1) { |
| 775 | 775 | return $configuredTrashbinSize - $trashbinSize; |
@@ -871,7 +871,7 @@ discard block |
||
| 871 | 871 | * @param int|float $availableSpace available disc space |
| 872 | 872 | * @return int|float size of deleted files |
| 873 | 873 | */ |
| 874 | - protected static function deleteFiles(array $files, string $user, int|float $availableSpace): int|float { |
|
| 874 | + protected static function deleteFiles(array $files, string $user, int | float $availableSpace): int | float { |
|
| 875 | 875 | $expiration = Server::get(Expiration::class); |
| 876 | 876 | $size = 0; |
| 877 | 877 | |
@@ -880,7 +880,7 @@ discard block |
||
| 880 | 880 | if ($availableSpace <= 0 && $expiration->isExpired($file['mtime'], true)) { |
| 881 | 881 | $tmp = self::delete($file['name'], $user, $file['mtime']); |
| 882 | 882 | Server::get(LoggerInterface::class)->info( |
| 883 | - 'remove "' . $file['name'] . '" (' . $tmp . 'B) to meet the limit of trash bin size (50% of available quota) for user "{user}"', |
|
| 883 | + 'remove "'.$file['name'].'" ('.$tmp.'B) to meet the limit of trash bin size (50% of available quota) for user "{user}"', |
|
| 884 | 884 | [ |
| 885 | 885 | 'app' => 'files_trashbin', |
| 886 | 886 | 'user' => $user, |
@@ -915,7 +915,7 @@ discard block |
||
| 915 | 915 | $size += self::delete($filename, $user, $timestamp); |
| 916 | 916 | $count++; |
| 917 | 917 | } catch (NotPermittedException $e) { |
| 918 | - Server::get(LoggerInterface::class)->warning('Removing "' . $filename . '" from trashbin failed for user "{user}"', |
|
| 918 | + Server::get(LoggerInterface::class)->warning('Removing "'.$filename.'" from trashbin failed for user "{user}"', |
|
| 919 | 919 | [ |
| 920 | 920 | 'exception' => $e, |
| 921 | 921 | 'app' => 'files_trashbin', |
@@ -924,7 +924,7 @@ discard block |
||
| 924 | 924 | ); |
| 925 | 925 | } |
| 926 | 926 | Server::get(LoggerInterface::class)->info( |
| 927 | - 'Remove "' . $filename . '" from trashbin for user "{user}" because it exceeds max retention obligation term.', |
|
| 927 | + 'Remove "'.$filename.'" from trashbin for user "{user}" because it exceeds max retention obligation term.', |
|
| 928 | 928 | [ |
| 929 | 929 | 'app' => 'files_trashbin', |
| 930 | 930 | 'user' => $user, |
@@ -947,22 +947,22 @@ discard block |
||
| 947 | 947 | * @return int|float |
| 948 | 948 | * @throws Exceptions\CopyRecursiveException |
| 949 | 949 | */ |
| 950 | - private static function copy_recursive($source, $destination, View $view): int|float { |
|
| 950 | + private static function copy_recursive($source, $destination, View $view): int | float { |
|
| 951 | 951 | $size = 0; |
| 952 | 952 | if ($view->is_dir($source)) { |
| 953 | 953 | $view->mkdir($destination); |
| 954 | 954 | $view->touch($destination, $view->filemtime($source)); |
| 955 | 955 | foreach ($view->getDirectoryContent($source) as $i) { |
| 956 | - $pathDir = $source . '/' . $i['name']; |
|
| 956 | + $pathDir = $source.'/'.$i['name']; |
|
| 957 | 957 | if ($view->is_dir($pathDir)) { |
| 958 | - $size += self::copy_recursive($pathDir, $destination . '/' . $i['name'], $view); |
|
| 958 | + $size += self::copy_recursive($pathDir, $destination.'/'.$i['name'], $view); |
|
| 959 | 959 | } else { |
| 960 | 960 | $size += $view->filesize($pathDir); |
| 961 | - $result = $view->copy($pathDir, $destination . '/' . $i['name']); |
|
| 961 | + $result = $view->copy($pathDir, $destination.'/'.$i['name']); |
|
| 962 | 962 | if (!$result) { |
| 963 | 963 | throw new CopyRecursiveException(); |
| 964 | 964 | } |
| 965 | - $view->touch($destination . '/' . $i['name'], $view->filemtime($pathDir)); |
|
| 965 | + $view->touch($destination.'/'.$i['name'], $view->filemtime($pathDir)); |
|
| 966 | 966 | } |
| 967 | 967 | } |
| 968 | 968 | } else { |
@@ -983,17 +983,17 @@ discard block |
||
| 983 | 983 | * @param int $timestamp timestamp when the file was deleted |
| 984 | 984 | */ |
| 985 | 985 | private static function getVersionsFromTrash($filename, $timestamp, string $user): array { |
| 986 | - $view = new View('/' . $user . '/files_trashbin/versions'); |
|
| 986 | + $view = new View('/'.$user.'/files_trashbin/versions'); |
|
| 987 | 987 | $versions = []; |
| 988 | 988 | |
| 989 | 989 | /** @var \OC\Files\Storage\Storage $storage */ |
| 990 | - [$storage,] = $view->resolvePath('/'); |
|
| 990 | + [$storage, ] = $view->resolvePath('/'); |
|
| 991 | 991 | |
| 992 | 992 | $pattern = Server::get(IDBConnection::class)->escapeLikeParameter(basename($filename)); |
| 993 | 993 | if ($timestamp) { |
| 994 | 994 | // fetch for old versions |
| 995 | - $escapedTimestamp = Server::get(IDBConnection::class)->escapeLikeParameter((string)$timestamp); |
|
| 996 | - $pattern .= '.v%.d' . $escapedTimestamp; |
|
| 995 | + $escapedTimestamp = Server::get(IDBConnection::class)->escapeLikeParameter((string) $timestamp); |
|
| 996 | + $pattern .= '.v%.d'.$escapedTimestamp; |
|
| 997 | 997 | $offset = -strlen($escapedTimestamp) - 2; |
| 998 | 998 | } else { |
| 999 | 999 | $pattern .= '.v%'; |
@@ -1005,7 +1005,7 @@ discard block |
||
| 1005 | 1005 | Server::get(IDBConnection::class)->getQueryBuilder(), |
| 1006 | 1006 | Server::get(IFilesMetadataManager::class), |
| 1007 | 1007 | ); |
| 1008 | - $normalizedParentPath = ltrim(Filesystem::normalizePath(dirname('files_trashbin/versions/' . $filename)), '/'); |
|
| 1008 | + $normalizedParentPath = ltrim(Filesystem::normalizePath(dirname('files_trashbin/versions/'.$filename)), '/'); |
|
| 1009 | 1009 | $parentId = $cache->getId($normalizedParentPath); |
| 1010 | 1010 | if ($parentId === -1) { |
| 1011 | 1011 | return []; |
@@ -1021,7 +1021,7 @@ discard block |
||
| 1021 | 1021 | $result->closeCursor(); |
| 1022 | 1022 | |
| 1023 | 1023 | /** @var CacheEntry[] $matches */ |
| 1024 | - $matches = array_map(function (array $data) { |
|
| 1024 | + $matches = array_map(function(array $data) { |
|
| 1025 | 1025 | return Cache::cacheEntryFromData($data, Server::get(IMimeTypeLoader::class)); |
| 1026 | 1026 | }, $entries); |
| 1027 | 1027 | |
@@ -1051,18 +1051,18 @@ discard block |
||
| 1051 | 1051 | $name = pathinfo($filename, PATHINFO_FILENAME); |
| 1052 | 1052 | $l = Util::getL10N('files_trashbin'); |
| 1053 | 1053 | |
| 1054 | - $location = '/' . trim($location, '/'); |
|
| 1054 | + $location = '/'.trim($location, '/'); |
|
| 1055 | 1055 | |
| 1056 | 1056 | // if extension is not empty we set a dot in front of it |
| 1057 | 1057 | if ($ext !== '') { |
| 1058 | - $ext = '.' . $ext; |
|
| 1058 | + $ext = '.'.$ext; |
|
| 1059 | 1059 | } |
| 1060 | 1060 | |
| 1061 | - if ($view->file_exists('files' . $location . '/' . $filename)) { |
|
| 1061 | + if ($view->file_exists('files'.$location.'/'.$filename)) { |
|
| 1062 | 1062 | $i = 2; |
| 1063 | - $uniqueName = $name . ' (' . $l->t('restored') . ')' . $ext; |
|
| 1064 | - while ($view->file_exists('files' . $location . '/' . $uniqueName)) { |
|
| 1065 | - $uniqueName = $name . ' (' . $l->t('restored') . ' ' . $i . ')' . $ext; |
|
| 1063 | + $uniqueName = $name.' ('.$l->t('restored').')'.$ext; |
|
| 1064 | + while ($view->file_exists('files'.$location.'/'.$uniqueName)) { |
|
| 1065 | + $uniqueName = $name.' ('.$l->t('restored').' '.$i.')'.$ext; |
|
| 1066 | 1066 | $i++; |
| 1067 | 1067 | } |
| 1068 | 1068 | |
@@ -1078,8 +1078,8 @@ discard block |
||
| 1078 | 1078 | * @param View $view file view on the root folder |
| 1079 | 1079 | * @return int|float size of the folder |
| 1080 | 1080 | */ |
| 1081 | - private static function calculateSize(View $view): int|float { |
|
| 1082 | - $root = Server::get(IConfig::class)->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . $view->getAbsolutePath(''); |
|
| 1081 | + private static function calculateSize(View $view): int | float { |
|
| 1082 | + $root = Server::get(IConfig::class)->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data').$view->getAbsolutePath(''); |
|
| 1083 | 1083 | if (!file_exists($root)) { |
| 1084 | 1084 | return 0; |
| 1085 | 1085 | } |
@@ -1109,8 +1109,8 @@ discard block |
||
| 1109 | 1109 | * @param string $user user who owns the trash bin |
| 1110 | 1110 | * @return int|float trash bin size |
| 1111 | 1111 | */ |
| 1112 | - private static function getTrashbinSize(string $user): int|float { |
|
| 1113 | - $view = new View('/' . $user); |
|
| 1112 | + private static function getTrashbinSize(string $user): int | float { |
|
| 1113 | + $view = new View('/'.$user); |
|
| 1114 | 1114 | $fileInfo = $view->getFileInfo('/files_trashbin'); |
| 1115 | 1115 | return isset($fileInfo['size']) ? $fileInfo['size'] : 0; |
| 1116 | 1116 | } |
@@ -1122,7 +1122,7 @@ discard block |
||
| 1122 | 1122 | * @return bool |
| 1123 | 1123 | */ |
| 1124 | 1124 | public static function isEmpty($user) { |
| 1125 | - $view = new View('/' . $user . '/files_trashbin'); |
|
| 1125 | + $view = new View('/'.$user.'/files_trashbin'); |
|
| 1126 | 1126 | if ($view->is_dir('/files') && $dh = $view->opendir('/files')) { |
| 1127 | 1127 | while (($file = readdir($dh)) !== false) { |
| 1128 | 1128 | if (!Filesystem::isIgnoredDir($file)) { |
@@ -1145,7 +1145,7 @@ discard block |
||
| 1145 | 1145 | * Return the filename used in the trash bin |
| 1146 | 1146 | */ |
| 1147 | 1147 | public static function getTrashFilename(string $filename, int $timestamp): string { |
| 1148 | - $trashFilename = $filename . '.d' . $timestamp; |
|
| 1148 | + $trashFilename = $filename.'.d'.$timestamp; |
|
| 1149 | 1149 | $length = strlen($trashFilename); |
| 1150 | 1150 | // oc_filecache `name` column has a limit of 250 chars |
| 1151 | 1151 | $maxLength = 250; |
@@ -1173,7 +1173,7 @@ discard block |
||
| 1173 | 1173 | } |
| 1174 | 1174 | |
| 1175 | 1175 | $view = Server::get(View::class); |
| 1176 | - $fullPath = '/' . $user . '/' . $baseDir . '/' . $path; |
|
| 1176 | + $fullPath = '/'.$user.'/'.$baseDir.'/'.$path; |
|
| 1177 | 1177 | |
| 1178 | 1178 | if (Filesystem::is_dir($path)) { |
| 1179 | 1179 | return new NonExistingFolder($rootFolder, $view, $fullPath); |