@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | Filesystem::initMountPoints($uid); |
| 101 | 101 | if ($uid !== User::getUser()) { |
| 102 | 102 | $info = Filesystem::getFileInfo($filename); |
| 103 | - $ownerView = new View('/' . $uid . '/files'); |
|
| 103 | + $ownerView = new View('/'.$uid.'/files'); |
|
| 104 | 104 | try { |
| 105 | 105 | $filename = $ownerView->getPath($info['fileid']); |
| 106 | 106 | } catch (NotFoundException $e) { |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | private static function setUpTrash($user) { |
| 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/' . $targetFilename . '.d' . $timestamp; |
|
| 190 | - $source = $owner . '/files_trashbin/files/' . $sourceFilename . '.d' . $timestamp; |
|
| 189 | + $target = $user.'/files_trashbin/files/'.$targetFilename.'.d'.$timestamp; |
|
| 190 | + $source = $owner.'/files_trashbin/files/'.$sourceFilename.'.d'.$timestamp; |
|
| 191 | 191 | self::copy_recursive($source, $target, $view); |
| 192 | 192 | |
| 193 | 193 | |
@@ -221,9 +221,9 @@ discard block |
||
| 221 | 221 | $ownerPath = $file_path; |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - $ownerView = new View('/' . $owner); |
|
| 224 | + $ownerView = new View('/'.$owner); |
|
| 225 | 225 | // file has been deleted in between |
| 226 | - if (is_null($ownerPath) || $ownerPath === '' || !$ownerView->file_exists('/files/' . $ownerPath)) { |
|
| 226 | + if (is_null($ownerPath) || $ownerPath === '' || !$ownerView->file_exists('/files/'.$ownerPath)) { |
|
| 227 | 227 | return true; |
| 228 | 228 | } |
| 229 | 229 | |
@@ -240,12 +240,12 @@ discard block |
||
| 240 | 240 | $timestamp = time(); |
| 241 | 241 | |
| 242 | 242 | // disable proxy to prevent recursive calls |
| 243 | - $trashPath = '/files_trashbin/files/' . $filename . '.d' . $timestamp; |
|
| 243 | + $trashPath = '/files_trashbin/files/'.$filename.'.d'.$timestamp; |
|
| 244 | 244 | |
| 245 | 245 | /** @var \OC\Files\Storage\Storage $trashStorage */ |
| 246 | 246 | list($trashStorage, $trashInternalPath) = $ownerView->resolvePath($trashPath); |
| 247 | 247 | /** @var \OC\Files\Storage\Storage $sourceStorage */ |
| 248 | - list($sourceStorage, $sourceInternalPath) = $ownerView->resolvePath('/files/' . $ownerPath); |
|
| 248 | + list($sourceStorage, $sourceInternalPath) = $ownerView->resolvePath('/files/'.$ownerPath); |
|
| 249 | 249 | try { |
| 250 | 250 | $moveSuccessful = true; |
| 251 | 251 | if ($trashStorage->file_exists($trashInternalPath)) { |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | if ($trashStorage->file_exists($trashInternalPath)) { |
| 258 | 258 | $trashStorage->unlink($trashInternalPath); |
| 259 | 259 | } |
| 260 | - \OC::$server->getLogger()->error('Couldn\'t move ' . $file_path . ' to the trash bin', ['app' => 'files_trashbin']); |
|
| 260 | + \OC::$server->getLogger()->error('Couldn\'t move '.$file_path.' to the trash bin', ['app' => 'files_trashbin']); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | if ($sourceStorage->file_exists($sourceInternalPath)) { // failed to delete the original file, abort |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | \OC::$server->getLogger()->error('trash bin database couldn\'t be updated', ['app' => 'files_trashbin']); |
| 279 | 279 | } |
| 280 | 280 | \OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_moveToTrash', array('filePath' => Filesystem::normalizePath($file_path), |
| 281 | - 'trashPath' => Filesystem::normalizePath($filename . '.d' . $timestamp))); |
|
| 281 | + 'trashPath' => Filesystem::normalizePath($filename.'.d'.$timestamp))); |
|
| 282 | 282 | |
| 283 | 283 | self::retainVersions($filename, $owner, $ownerPath, $timestamp); |
| 284 | 284 | |
@@ -312,18 +312,18 @@ discard block |
||
| 312 | 312 | $user = User::getUser(); |
| 313 | 313 | $rootView = new View('/'); |
| 314 | 314 | |
| 315 | - if ($rootView->is_dir($owner . '/files_versions/' . $ownerPath)) { |
|
| 315 | + if ($rootView->is_dir($owner.'/files_versions/'.$ownerPath)) { |
|
| 316 | 316 | if ($owner !== $user) { |
| 317 | - self::copy_recursive($owner . '/files_versions/' . $ownerPath, $owner . '/files_trashbin/versions/' . basename($ownerPath) . '.d' . $timestamp, $rootView); |
|
| 317 | + self::copy_recursive($owner.'/files_versions/'.$ownerPath, $owner.'/files_trashbin/versions/'.basename($ownerPath).'.d'.$timestamp, $rootView); |
|
| 318 | 318 | } |
| 319 | - self::move($rootView, $owner . '/files_versions/' . $ownerPath, $user . '/files_trashbin/versions/' . $filename . '.d' . $timestamp); |
|
| 319 | + self::move($rootView, $owner.'/files_versions/'.$ownerPath, $user.'/files_trashbin/versions/'.$filename.'.d'.$timestamp); |
|
| 320 | 320 | } else if ($versions = \OCA\Files_Versions\Storage::getVersions($owner, $ownerPath)) { |
| 321 | 321 | |
| 322 | 322 | foreach ($versions as $v) { |
| 323 | 323 | if ($owner !== $user) { |
| 324 | - self::copy($rootView, $owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $owner . '/files_trashbin/versions/' . $v['name'] . '.v' . $v['version'] . '.d' . $timestamp); |
|
| 324 | + self::copy($rootView, $owner.'/files_versions'.$v['path'].'.v'.$v['version'], $owner.'/files_trashbin/versions/'.$v['name'].'.v'.$v['version'].'.d'.$timestamp); |
|
| 325 | 325 | } |
| 326 | - self::move($rootView, $owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $user . '/files_trashbin/versions/' . $filename . '.v' . $v['version'] . '.d' . $timestamp); |
|
| 326 | + self::move($rootView, $owner.'/files_versions'.$v['path'].'.v'.$v['version'], $user.'/files_trashbin/versions/'.$filename.'.v'.$v['version'].'.d'.$timestamp); |
|
| 327 | 327 | } |
| 328 | 328 | } |
| 329 | 329 | } |
@@ -385,18 +385,18 @@ discard block |
||
| 385 | 385 | */ |
| 386 | 386 | public static function restore($file, $filename, $timestamp) { |
| 387 | 387 | $user = User::getUser(); |
| 388 | - $view = new View('/' . $user); |
|
| 388 | + $view = new View('/'.$user); |
|
| 389 | 389 | |
| 390 | 390 | $location = ''; |
| 391 | 391 | if ($timestamp) { |
| 392 | 392 | $location = self::getLocation($user, $filename, $timestamp); |
| 393 | 393 | if ($location === false) { |
| 394 | - \OC::$server->getLogger()->error('trash bin database inconsistent! ($user: ' . $user . ' $filename: ' . $filename . ', $timestamp: ' . $timestamp . ')', ['app' => 'files_trashbin']); |
|
| 394 | + \OC::$server->getLogger()->error('trash bin database inconsistent! ($user: '.$user.' $filename: '.$filename.', $timestamp: '.$timestamp.')', ['app' => 'files_trashbin']); |
|
| 395 | 395 | } else { |
| 396 | 396 | // if location no longer exists, restore file in the root directory |
| 397 | 397 | if ($location !== '/' && |
| 398 | - (!$view->is_dir('files/' . $location) || |
|
| 399 | - !$view->isCreatable('files/' . $location)) |
|
| 398 | + (!$view->is_dir('files/'.$location) || |
|
| 399 | + !$view->isCreatable('files/'.$location)) |
|
| 400 | 400 | ) { |
| 401 | 401 | $location = ''; |
| 402 | 402 | } |
@@ -406,8 +406,8 @@ discard block |
||
| 406 | 406 | // we need a extension in case a file/dir with the same name already exists |
| 407 | 407 | $uniqueFilename = self::getUniqueFilename($location, $filename, $view); |
| 408 | 408 | |
| 409 | - $source = Filesystem::normalizePath('files_trashbin/files/' . $file); |
|
| 410 | - $target = Filesystem::normalizePath('files/' . $location . '/' . $uniqueFilename); |
|
| 409 | + $source = Filesystem::normalizePath('files_trashbin/files/'.$file); |
|
| 410 | + $target = Filesystem::normalizePath('files/'.$location.'/'.$uniqueFilename); |
|
| 411 | 411 | if (!$view->file_exists($source)) { |
| 412 | 412 | return false; |
| 413 | 413 | } |
@@ -419,10 +419,10 @@ discard block |
||
| 419 | 419 | // handle the restore result |
| 420 | 420 | if ($restoreResult) { |
| 421 | 421 | $fakeRoot = $view->getRoot(); |
| 422 | - $view->chroot('/' . $user . '/files'); |
|
| 423 | - $view->touch('/' . $location . '/' . $uniqueFilename, $mtime); |
|
| 422 | + $view->chroot('/'.$user.'/files'); |
|
| 423 | + $view->touch('/'.$location.'/'.$uniqueFilename, $mtime); |
|
| 424 | 424 | $view->chroot($fakeRoot); |
| 425 | - \OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', array('filePath' => Filesystem::normalizePath('/' . $location . '/' . $uniqueFilename), |
|
| 425 | + \OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', array('filePath' => Filesystem::normalizePath('/'.$location.'/'.$uniqueFilename), |
|
| 426 | 426 | 'trashPath' => Filesystem::normalizePath($file))); |
| 427 | 427 | |
| 428 | 428 | self::restoreVersions($view, $file, $filename, $uniqueFilename, $location, $timestamp); |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | $user = User::getUser(); |
| 457 | 457 | $rootView = new View('/'); |
| 458 | 458 | |
| 459 | - $target = Filesystem::normalizePath('/' . $location . '/' . $uniqueFilename); |
|
| 459 | + $target = Filesystem::normalizePath('/'.$location.'/'.$uniqueFilename); |
|
| 460 | 460 | |
| 461 | 461 | list($owner, $ownerPath) = self::getUidAndFilename($target); |
| 462 | 462 | |
@@ -471,14 +471,14 @@ discard block |
||
| 471 | 471 | $versionedFile = $file; |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | - if ($view->is_dir('/files_trashbin/versions/' . $file)) { |
|
| 475 | - $rootView->rename(Filesystem::normalizePath($user . '/files_trashbin/versions/' . $file), Filesystem::normalizePath($owner . '/files_versions/' . $ownerPath)); |
|
| 474 | + if ($view->is_dir('/files_trashbin/versions/'.$file)) { |
|
| 475 | + $rootView->rename(Filesystem::normalizePath($user.'/files_trashbin/versions/'.$file), Filesystem::normalizePath($owner.'/files_versions/'.$ownerPath)); |
|
| 476 | 476 | } else if ($versions = self::getVersionsFromTrash($versionedFile, $timestamp, $user)) { |
| 477 | 477 | foreach ($versions as $v) { |
| 478 | 478 | if ($timestamp) { |
| 479 | - $rootView->rename($user . '/files_trashbin/versions/' . $versionedFile . '.v' . $v . '.d' . $timestamp, $owner . '/files_versions/' . $ownerPath . '.v' . $v); |
|
| 479 | + $rootView->rename($user.'/files_trashbin/versions/'.$versionedFile.'.v'.$v.'.d'.$timestamp, $owner.'/files_versions/'.$ownerPath.'.v'.$v); |
|
| 480 | 480 | } else { |
| 481 | - $rootView->rename($user . '/files_trashbin/versions/' . $versionedFile . '.v' . $v, $owner . '/files_versions/' . $ownerPath . '.v' . $v); |
|
| 481 | + $rootView->rename($user.'/files_trashbin/versions/'.$versionedFile.'.v'.$v, $owner.'/files_versions/'.$ownerPath.'.v'.$v); |
|
| 482 | 482 | } |
| 483 | 483 | } |
| 484 | 484 | } |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | public static function deleteAll() { |
| 492 | 492 | $user = User::getUser(); |
| 493 | 493 | $userRoot = \OC::$server->getUserFolder($user)->getParent(); |
| 494 | - $view = new View('/' . $user); |
|
| 494 | + $view = new View('/'.$user); |
|
| 495 | 495 | $fileInfos = $view->getDirectoryContent('files_trashbin/files'); |
| 496 | 496 | |
| 497 | 497 | try { |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | |
| 503 | 503 | // Array to store the relative path in (after the file is deleted, the view won't be able to relativise the path anymore) |
| 504 | 504 | $filePaths = array(); |
| 505 | - foreach($fileInfos as $fileInfo){ |
|
| 505 | + foreach ($fileInfos as $fileInfo) { |
|
| 506 | 506 | $filePaths[] = $view->getRelativePath($fileInfo->getPath()); |
| 507 | 507 | } |
| 508 | 508 | unset($fileInfos); // save memory |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | \OC_Hook::emit('\OCP\Trashbin', 'preDeleteAll', array('paths' => $filePaths)); |
| 512 | 512 | |
| 513 | 513 | // Single-File Hooks |
| 514 | - foreach($filePaths as $path){ |
|
| 514 | + foreach ($filePaths as $path) { |
|
| 515 | 515 | self::emitTrashbinPreDelete($path); |
| 516 | 516 | } |
| 517 | 517 | |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | \OC_Hook::emit('\OCP\Trashbin', 'deleteAll', array('paths' => $filePaths)); |
| 525 | 525 | |
| 526 | 526 | // Single-File Hooks |
| 527 | - foreach($filePaths as $path){ |
|
| 527 | + foreach ($filePaths as $path) { |
|
| 528 | 528 | self::emitTrashbinPostDelete($path); |
| 529 | 529 | } |
| 530 | 530 | |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | * wrapper function to emit the 'preDelete' hook of \OCP\Trashbin before a file is deleted |
| 539 | 539 | * @param string $path |
| 540 | 540 | */ |
| 541 | - protected static function emitTrashbinPreDelete($path){ |
|
| 541 | + protected static function emitTrashbinPreDelete($path) { |
|
| 542 | 542 | \OC_Hook::emit('\OCP\Trashbin', 'preDelete', array('path' => $path)); |
| 543 | 543 | } |
| 544 | 544 | |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | * wrapper function to emit the 'delete' hook of \OCP\Trashbin after a file has been deleted |
| 547 | 547 | * @param string $path |
| 548 | 548 | */ |
| 549 | - protected static function emitTrashbinPostDelete($path){ |
|
| 549 | + protected static function emitTrashbinPostDelete($path) { |
|
| 550 | 550 | \OC_Hook::emit('\OCP\Trashbin', 'delete', array('path' => $path)); |
| 551 | 551 | } |
| 552 | 552 | |
@@ -561,13 +561,13 @@ discard block |
||
| 561 | 561 | */ |
| 562 | 562 | public static function delete($filename, $user, $timestamp = null) { |
| 563 | 563 | $userRoot = \OC::$server->getUserFolder($user)->getParent(); |
| 564 | - $view = new View('/' . $user); |
|
| 564 | + $view = new View('/'.$user); |
|
| 565 | 565 | $size = 0; |
| 566 | 566 | |
| 567 | 567 | if ($timestamp) { |
| 568 | 568 | $query = \OC_DB::prepare('DELETE FROM `*PREFIX*files_trash` WHERE `user`=? AND `id`=? AND `timestamp`=?'); |
| 569 | 569 | $query->execute(array($user, $filename, $timestamp)); |
| 570 | - $file = $filename . '.d' . $timestamp; |
|
| 570 | + $file = $filename.'.d'.$timestamp; |
|
| 571 | 571 | } else { |
| 572 | 572 | $file = $filename; |
| 573 | 573 | } |
@@ -575,20 +575,20 @@ discard block |
||
| 575 | 575 | $size += self::deleteVersions($view, $file, $filename, $timestamp, $user); |
| 576 | 576 | |
| 577 | 577 | try { |
| 578 | - $node = $userRoot->get('/files_trashbin/files/' . $file); |
|
| 578 | + $node = $userRoot->get('/files_trashbin/files/'.$file); |
|
| 579 | 579 | } catch (NotFoundException $e) { |
| 580 | 580 | return $size; |
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | if ($node instanceof Folder) { |
| 584 | - $size += self::calculateSize(new View('/' . $user . '/files_trashbin/files/' . $file)); |
|
| 584 | + $size += self::calculateSize(new View('/'.$user.'/files_trashbin/files/'.$file)); |
|
| 585 | 585 | } else if ($node instanceof File) { |
| 586 | - $size += $view->filesize('/files_trashbin/files/' . $file); |
|
| 586 | + $size += $view->filesize('/files_trashbin/files/'.$file); |
|
| 587 | 587 | } |
| 588 | 588 | |
| 589 | - self::emitTrashbinPreDelete('/files_trashbin/files/' . $file); |
|
| 589 | + self::emitTrashbinPreDelete('/files_trashbin/files/'.$file); |
|
| 590 | 590 | $node->delete(); |
| 591 | - self::emitTrashbinPostDelete('/files_trashbin/files/' . $file); |
|
| 591 | + self::emitTrashbinPostDelete('/files_trashbin/files/'.$file); |
|
| 592 | 592 | |
| 593 | 593 | return $size; |
| 594 | 594 | } |
@@ -604,17 +604,17 @@ discard block |
||
| 604 | 604 | private static function deleteVersions(View $view, $file, $filename, $timestamp, $user) { |
| 605 | 605 | $size = 0; |
| 606 | 606 | if (\OCP\App::isEnabled('files_versions')) { |
| 607 | - if ($view->is_dir('files_trashbin/versions/' . $file)) { |
|
| 608 | - $size += self::calculateSize(new View('/' . $user . '/files_trashbin/versions/' . $file)); |
|
| 609 | - $view->unlink('files_trashbin/versions/' . $file); |
|
| 607 | + if ($view->is_dir('files_trashbin/versions/'.$file)) { |
|
| 608 | + $size += self::calculateSize(new View('/'.$user.'/files_trashbin/versions/'.$file)); |
|
| 609 | + $view->unlink('files_trashbin/versions/'.$file); |
|
| 610 | 610 | } else if ($versions = self::getVersionsFromTrash($filename, $timestamp, $user)) { |
| 611 | 611 | foreach ($versions as $v) { |
| 612 | 612 | if ($timestamp) { |
| 613 | - $size += $view->filesize('/files_trashbin/versions/' . $filename . '.v' . $v . '.d' . $timestamp); |
|
| 614 | - $view->unlink('/files_trashbin/versions/' . $filename . '.v' . $v . '.d' . $timestamp); |
|
| 613 | + $size += $view->filesize('/files_trashbin/versions/'.$filename.'.v'.$v.'.d'.$timestamp); |
|
| 614 | + $view->unlink('/files_trashbin/versions/'.$filename.'.v'.$v.'.d'.$timestamp); |
|
| 615 | 615 | } else { |
| 616 | - $size += $view->filesize('/files_trashbin/versions/' . $filename . '.v' . $v); |
|
| 617 | - $view->unlink('/files_trashbin/versions/' . $filename . '.v' . $v); |
|
| 616 | + $size += $view->filesize('/files_trashbin/versions/'.$filename.'.v'.$v); |
|
| 617 | + $view->unlink('/files_trashbin/versions/'.$filename.'.v'.$v); |
|
| 618 | 618 | } |
| 619 | 619 | } |
| 620 | 620 | } |
@@ -631,13 +631,13 @@ discard block |
||
| 631 | 631 | */ |
| 632 | 632 | public static function file_exists($filename, $timestamp = null) { |
| 633 | 633 | $user = User::getUser(); |
| 634 | - $view = new View('/' . $user); |
|
| 634 | + $view = new View('/'.$user); |
|
| 635 | 635 | |
| 636 | 636 | if ($timestamp) { |
| 637 | - $filename = $filename . '.d' . $timestamp; |
|
| 637 | + $filename = $filename.'.d'.$timestamp; |
|
| 638 | 638 | } |
| 639 | 639 | |
| 640 | - $target = Filesystem::normalizePath('files_trashbin/files/' . $filename); |
|
| 640 | + $target = Filesystem::normalizePath('files_trashbin/files/'.$filename); |
|
| 641 | 641 | return $view->file_exists($target); |
| 642 | 642 | } |
| 643 | 643 | |
@@ -662,7 +662,7 @@ discard block |
||
| 662 | 662 | private static function calculateFreeSpace($trashbinSize, $user) { |
| 663 | 663 | $softQuota = true; |
| 664 | 664 | $userObject = \OC::$server->getUserManager()->get($user); |
| 665 | - if(is_null($userObject)) { |
|
| 665 | + if (is_null($userObject)) { |
|
| 666 | 666 | return 0; |
| 667 | 667 | } |
| 668 | 668 | $quota = $userObject->getQuota(); |
@@ -681,7 +681,7 @@ discard block |
||
| 681 | 681 | // subtract size of files and current trash bin size from quota |
| 682 | 682 | if ($softQuota) { |
| 683 | 683 | $userFolder = \OC::$server->getUserFolder($user); |
| 684 | - if(is_null($userFolder)) { |
|
| 684 | + if (is_null($userFolder)) { |
|
| 685 | 685 | return 0; |
| 686 | 686 | } |
| 687 | 687 | $free = $quota - $userFolder->getSize(false); // remaining free space for user |
@@ -763,7 +763,7 @@ discard block |
||
| 763 | 763 | foreach ($files as $file) { |
| 764 | 764 | if ($availableSpace < 0 && $expiration->isExpired($file['mtime'], true)) { |
| 765 | 765 | $tmp = self::delete($file['name'], $user, $file['mtime']); |
| 766 | - \OC::$server->getLogger()->info('remove "' . $file['name'] . '" (' . $tmp . 'B) to meet the limit of trash bin size (50% of available quota)', ['app' => 'files_trashbin']); |
|
| 766 | + \OC::$server->getLogger()->info('remove "'.$file['name'].'" ('.$tmp.'B) to meet the limit of trash bin size (50% of available quota)', ['app' => 'files_trashbin']); |
|
| 767 | 767 | $availableSpace += $tmp; |
| 768 | 768 | $size += $tmp; |
| 769 | 769 | } else { |
@@ -794,10 +794,10 @@ discard block |
||
| 794 | 794 | $size += self::delete($filename, $user, $timestamp); |
| 795 | 795 | $count++; |
| 796 | 796 | } catch (\OCP\Files\NotPermittedException $e) { |
| 797 | - \OC::$server->getLogger()->logException($e, ['app' => 'files_trashbin', 'level' => \OCP\ILogger::WARN, 'message' => 'Removing "' . $filename . '" from trashbin failed.']); |
|
| 797 | + \OC::$server->getLogger()->logException($e, ['app' => 'files_trashbin', 'level' => \OCP\ILogger::WARN, 'message' => 'Removing "'.$filename.'" from trashbin failed.']); |
|
| 798 | 798 | } |
| 799 | 799 | \OC::$server->getLogger()->info( |
| 800 | - 'Remove "' . $filename . '" from trashbin because it exceeds max retention obligation term.', |
|
| 800 | + 'Remove "'.$filename.'" from trashbin because it exceeds max retention obligation term.', |
|
| 801 | 801 | ['app' => 'files_trashbin'] |
| 802 | 802 | ); |
| 803 | 803 | } else { |
@@ -823,16 +823,16 @@ discard block |
||
| 823 | 823 | $view->mkdir($destination); |
| 824 | 824 | $view->touch($destination, $view->filemtime($source)); |
| 825 | 825 | foreach ($view->getDirectoryContent($source) as $i) { |
| 826 | - $pathDir = $source . '/' . $i['name']; |
|
| 826 | + $pathDir = $source.'/'.$i['name']; |
|
| 827 | 827 | if ($view->is_dir($pathDir)) { |
| 828 | - $size += self::copy_recursive($pathDir, $destination . '/' . $i['name'], $view); |
|
| 828 | + $size += self::copy_recursive($pathDir, $destination.'/'.$i['name'], $view); |
|
| 829 | 829 | } else { |
| 830 | 830 | $size += $view->filesize($pathDir); |
| 831 | - $result = $view->copy($pathDir, $destination . '/' . $i['name']); |
|
| 831 | + $result = $view->copy($pathDir, $destination.'/'.$i['name']); |
|
| 832 | 832 | if (!$result) { |
| 833 | 833 | throw new \OCA\Files_Trashbin\Exceptions\CopyRecursiveException(); |
| 834 | 834 | } |
| 835 | - $view->touch($destination . '/' . $i['name'], $view->filemtime($pathDir)); |
|
| 835 | + $view->touch($destination.'/'.$i['name'], $view->filemtime($pathDir)); |
|
| 836 | 836 | } |
| 837 | 837 | } |
| 838 | 838 | } else { |
@@ -854,7 +854,7 @@ discard block |
||
| 854 | 854 | * @return array |
| 855 | 855 | */ |
| 856 | 856 | private static function getVersionsFromTrash($filename, $timestamp, $user) { |
| 857 | - $view = new View('/' . $user . '/files_trashbin/versions'); |
|
| 857 | + $view = new View('/'.$user.'/files_trashbin/versions'); |
|
| 858 | 858 | $versions = array(); |
| 859 | 859 | |
| 860 | 860 | //force rescan of versions, local storage may not have updated the cache |
@@ -867,10 +867,10 @@ discard block |
||
| 867 | 867 | |
| 868 | 868 | if ($timestamp) { |
| 869 | 869 | // fetch for old versions |
| 870 | - $matches = $view->searchRaw($filename . '.v%.d' . $timestamp); |
|
| 870 | + $matches = $view->searchRaw($filename.'.v%.d'.$timestamp); |
|
| 871 | 871 | $offset = -strlen($timestamp) - 2; |
| 872 | 872 | } else { |
| 873 | - $matches = $view->searchRaw($filename . '.v%'); |
|
| 873 | + $matches = $view->searchRaw($filename.'.v%'); |
|
| 874 | 874 | } |
| 875 | 875 | |
| 876 | 876 | if (is_array($matches)) { |
@@ -900,18 +900,18 @@ discard block |
||
| 900 | 900 | $name = pathinfo($filename, PATHINFO_FILENAME); |
| 901 | 901 | $l = \OC::$server->getL10N('files_trashbin'); |
| 902 | 902 | |
| 903 | - $location = '/' . trim($location, '/'); |
|
| 903 | + $location = '/'.trim($location, '/'); |
|
| 904 | 904 | |
| 905 | 905 | // if extension is not empty we set a dot in front of it |
| 906 | 906 | if ($ext !== '') { |
| 907 | - $ext = '.' . $ext; |
|
| 907 | + $ext = '.'.$ext; |
|
| 908 | 908 | } |
| 909 | 909 | |
| 910 | - if ($view->file_exists('files' . $location . '/' . $filename)) { |
|
| 910 | + if ($view->file_exists('files'.$location.'/'.$filename)) { |
|
| 911 | 911 | $i = 2; |
| 912 | - $uniqueName = $name . " (" . $l->t("restored") . ")" . $ext; |
|
| 913 | - while ($view->file_exists('files' . $location . '/' . $uniqueName)) { |
|
| 914 | - $uniqueName = $name . " (" . $l->t("restored") . " " . $i . ")" . $ext; |
|
| 912 | + $uniqueName = $name." (".$l->t("restored").")".$ext; |
|
| 913 | + while ($view->file_exists('files'.$location.'/'.$uniqueName)) { |
|
| 914 | + $uniqueName = $name." (".$l->t("restored")." ".$i.")".$ext; |
|
| 915 | 915 | $i++; |
| 916 | 916 | } |
| 917 | 917 | |
@@ -928,7 +928,7 @@ discard block |
||
| 928 | 928 | * @return integer size of the folder |
| 929 | 929 | */ |
| 930 | 930 | private static function calculateSize($view) { |
| 931 | - $root = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . $view->getAbsolutePath(''); |
|
| 931 | + $root = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data').$view->getAbsolutePath(''); |
|
| 932 | 932 | if (!file_exists($root)) { |
| 933 | 933 | return 0; |
| 934 | 934 | } |
@@ -959,7 +959,7 @@ discard block |
||
| 959 | 959 | * @return integer trash bin size |
| 960 | 960 | */ |
| 961 | 961 | private static function getTrashbinSize($user) { |
| 962 | - $view = new View('/' . $user); |
|
| 962 | + $view = new View('/'.$user); |
|
| 963 | 963 | $fileInfo = $view->getFileInfo('/files_trashbin'); |
| 964 | 964 | return isset($fileInfo['size']) ? $fileInfo['size'] : 0; |
| 965 | 965 | } |
@@ -986,7 +986,7 @@ discard block |
||
| 986 | 986 | */ |
| 987 | 987 | public static function isEmpty($user) { |
| 988 | 988 | |
| 989 | - $view = new View('/' . $user . '/files_trashbin'); |
|
| 989 | + $view = new View('/'.$user.'/files_trashbin'); |
|
| 990 | 990 | if ($view->is_dir('/files') && $dh = $view->opendir('/files')) { |
| 991 | 991 | while ($file = readdir($dh)) { |
| 992 | 992 | if (!Filesystem::isIgnoredDir($file)) { |