|
@@ -112,7 +112,7 @@ discard block |
|
|
block discarded – undo |
|
112
|
112
|
Filesystem::initMountPoints($uid); |
|
113
|
113
|
if ($uid !== User::getUser()) { |
|
114
|
114
|
$info = Filesystem::getFileInfo($filename); |
|
115
|
|
- $ownerView = new View('/' . $uid . '/files'); |
|
|
115
|
+ $ownerView = new View('/'.$uid.'/files'); |
|
116
|
116
|
try { |
|
117
|
117
|
$filename = $ownerView->getPath($info['fileid']); |
|
118
|
118
|
} catch (NotFoundException $e) { |
|
@@ -174,7 +174,7 @@ discard block |
|
|
block discarded – undo |
|
174
|
174
|
} |
|
175
|
175
|
|
|
176
|
176
|
private static function setUpTrash($user) { |
|
177
|
|
- $view = new View('/' . $user); |
|
|
177
|
+ $view = new View('/'.$user); |
|
178
|
178
|
if (!$view->is_dir('files_trashbin')) { |
|
179
|
179
|
$view->mkdir('files_trashbin'); |
|
180
|
180
|
} |
|
@@ -209,8 +209,8 @@ discard block |
|
|
block discarded – undo |
|
209
|
209
|
|
|
210
|
210
|
$view = new View('/'); |
|
211
|
211
|
|
|
212
|
|
- $target = $user . '/files_trashbin/files/' . $targetFilename . '.d' . $timestamp; |
|
213
|
|
- $source = $owner . '/files_trashbin/files/' . $sourceFilename . '.d' . $timestamp; |
|
|
212
|
+ $target = $user.'/files_trashbin/files/'.$targetFilename.'.d'.$timestamp; |
|
|
213
|
+ $source = $owner.'/files_trashbin/files/'.$sourceFilename.'.d'.$timestamp; |
|
214
|
214
|
$free = $view->free_space($target); |
|
215
|
215
|
$isUnknownOrUnlimitedFreeSpace = $free < 0; |
|
216
|
216
|
$isEnoughFreeSpaceLeft = $view->filesize($source) < $free; |
|
@@ -254,9 +254,9 @@ discard block |
|
|
block discarded – undo |
|
254
|
254
|
$ownerPath = $file_path; |
|
255
|
255
|
} |
|
256
|
256
|
|
|
257
|
|
- $ownerView = new View('/' . $owner); |
|
|
257
|
+ $ownerView = new View('/'.$owner); |
|
258
|
258
|
// file has been deleted in between |
|
259
|
|
- if (is_null($ownerPath) || $ownerPath === '' || !$ownerView->file_exists('/files/' . $ownerPath)) { |
|
|
259
|
+ if (is_null($ownerPath) || $ownerPath === '' || !$ownerView->file_exists('/files/'.$ownerPath)) { |
|
260
|
260
|
return true; |
|
261
|
261
|
} |
|
262
|
262
|
|
|
@@ -277,7 +277,7 @@ discard block |
|
|
block discarded – undo |
|
277
|
277
|
$lockingProvider = \OC::$server->getLockingProvider(); |
|
278
|
278
|
|
|
279
|
279
|
// disable proxy to prevent recursive calls |
|
280
|
|
- $trashPath = '/files_trashbin/files/' . $filename . '.d' . $timestamp; |
|
|
280
|
+ $trashPath = '/files_trashbin/files/'.$filename.'.d'.$timestamp; |
|
281
|
281
|
$gotLock = false; |
|
282
|
282
|
|
|
283
|
283
|
while (!$gotLock) { |
|
@@ -293,12 +293,12 @@ discard block |
|
|
block discarded – undo |
|
293
|
293
|
|
|
294
|
294
|
$timestamp = $timestamp + 1; |
|
295
|
295
|
|
|
296
|
|
- $trashPath = '/files_trashbin/files/' . $filename . '.d' . $timestamp; |
|
|
296
|
+ $trashPath = '/files_trashbin/files/'.$filename.'.d'.$timestamp; |
|
297
|
297
|
} |
|
298
|
298
|
} |
|
299
|
299
|
|
|
300
|
300
|
/** @var \OC\Files\Storage\Storage $sourceStorage */ |
|
301
|
|
- [$sourceStorage, $sourceInternalPath] = $ownerView->resolvePath('/files/' . $ownerPath); |
|
|
301
|
+ [$sourceStorage, $sourceInternalPath] = $ownerView->resolvePath('/files/'.$ownerPath); |
|
302
|
302
|
|
|
303
|
303
|
|
|
304
|
304
|
if ($trashStorage->file_exists($trashInternalPath)) { |
|
@@ -306,8 +306,8 @@ discard block |
|
|
block discarded – undo |
|
306
|
306
|
} |
|
307
|
307
|
|
|
308
|
308
|
$config = \OC::$server->getConfig(); |
|
309
|
|
- $systemTrashbinSize = (int)$config->getAppValue('files_trashbin', 'trashbin_size', '-1'); |
|
310
|
|
- $userTrashbinSize = (int)$config->getUserValue($owner, 'files_trashbin', 'trashbin_size', '-1'); |
|
|
309
|
+ $systemTrashbinSize = (int) $config->getAppValue('files_trashbin', 'trashbin_size', '-1'); |
|
|
310
|
+ $userTrashbinSize = (int) $config->getUserValue($owner, 'files_trashbin', 'trashbin_size', '-1'); |
|
311
|
311
|
$configuredTrashbinSize = ($userTrashbinSize < 0) ? $systemTrashbinSize : $userTrashbinSize; |
|
312
|
312
|
if ($configuredTrashbinSize >= 0 && $sourceStorage->filesize($sourceInternalPath) >= $configuredTrashbinSize) { |
|
313
|
313
|
return false; |
|
@@ -327,7 +327,7 @@ discard block |
|
|
block discarded – undo |
|
327
|
327
|
if ($trashStorage->file_exists($trashInternalPath)) { |
|
328
|
328
|
$trashStorage->unlink($trashInternalPath); |
|
329
|
329
|
} |
|
330
|
|
- \OC::$server->getLogger()->error('Couldn\'t move ' . $file_path . ' to the trash bin', ['app' => 'files_trashbin']); |
|
|
330
|
+ \OC::$server->getLogger()->error('Couldn\'t move '.$file_path.' to the trash bin', ['app' => 'files_trashbin']); |
|
331
|
331
|
} |
|
332
|
332
|
|
|
333
|
333
|
if ($sourceStorage->file_exists($sourceInternalPath)) { // failed to delete the original file, abort |
|
@@ -358,7 +358,7 @@ discard block |
|
|
block discarded – undo |
|
358
|
358
|
\OC::$server->getLogger()->error('trash bin database couldn\'t be updated', ['app' => 'files_trashbin']); |
|
359
|
359
|
} |
|
360
|
360
|
\OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_moveToTrash', ['filePath' => Filesystem::normalizePath($file_path), |
|
361
|
|
- 'trashPath' => Filesystem::normalizePath($filename . '.d' . $timestamp)]); |
|
|
361
|
+ 'trashPath' => Filesystem::normalizePath($filename.'.d'.$timestamp)]); |
|
362
|
362
|
|
|
363
|
363
|
self::retainVersions($filename, $owner, $ownerPath, $timestamp); |
|
364
|
364
|
|
|
@@ -393,17 +393,17 @@ discard block |
|
|
block discarded – undo |
|
393
|
393
|
$user = User::getUser(); |
|
394
|
394
|
$rootView = new View('/'); |
|
395
|
395
|
|
|
396
|
|
- if ($rootView->is_dir($owner . '/files_versions/' . $ownerPath)) { |
|
|
396
|
+ if ($rootView->is_dir($owner.'/files_versions/'.$ownerPath)) { |
|
397
|
397
|
if ($owner !== $user) { |
|
398
|
|
- self::copy_recursive($owner . '/files_versions/' . $ownerPath, $owner . '/files_trashbin/versions/' . basename($ownerPath) . '.d' . $timestamp, $rootView); |
|
|
398
|
+ self::copy_recursive($owner.'/files_versions/'.$ownerPath, $owner.'/files_trashbin/versions/'.basename($ownerPath).'.d'.$timestamp, $rootView); |
|
399
|
399
|
} |
|
400
|
|
- self::move($rootView, $owner . '/files_versions/' . $ownerPath, $user . '/files_trashbin/versions/' . $filename . '.d' . $timestamp); |
|
|
400
|
+ self::move($rootView, $owner.'/files_versions/'.$ownerPath, $user.'/files_trashbin/versions/'.$filename.'.d'.$timestamp); |
|
401
|
401
|
} elseif ($versions = \OCA\Files_Versions\Storage::getVersions($owner, $ownerPath)) { |
|
402
|
402
|
foreach ($versions as $v) { |
|
403
|
403
|
if ($owner !== $user) { |
|
404
|
|
- self::copy($rootView, $owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $owner . '/files_trashbin/versions/' . $v['name'] . '.v' . $v['version'] . '.d' . $timestamp); |
|
|
404
|
+ self::copy($rootView, $owner.'/files_versions'.$v['path'].'.v'.$v['version'], $owner.'/files_trashbin/versions/'.$v['name'].'.v'.$v['version'].'.d'.$timestamp); |
|
405
|
405
|
} |
|
406
|
|
- self::move($rootView, $owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $user . '/files_trashbin/versions/' . $filename . '.v' . $v['version'] . '.d' . $timestamp); |
|
|
406
|
+ self::move($rootView, $owner.'/files_versions'.$v['path'].'.v'.$v['version'], $user.'/files_trashbin/versions/'.$filename.'.v'.$v['version'].'.d'.$timestamp); |
|
407
|
407
|
} |
|
408
|
408
|
} |
|
409
|
409
|
} |
|
@@ -465,18 +465,18 @@ discard block |
|
|
block discarded – undo |
|
465
|
465
|
*/ |
|
466
|
466
|
public static function restore($file, $filename, $timestamp) { |
|
467
|
467
|
$user = User::getUser(); |
|
468
|
|
- $view = new View('/' . $user); |
|
|
468
|
+ $view = new View('/'.$user); |
|
469
|
469
|
|
|
470
|
470
|
$location = ''; |
|
471
|
471
|
if ($timestamp) { |
|
472
|
472
|
$location = self::getLocation($user, $filename, $timestamp); |
|
473
|
473
|
if ($location === false) { |
|
474
|
|
- \OC::$server->getLogger()->error('trash bin database inconsistent! ($user: ' . $user . ' $filename: ' . $filename . ', $timestamp: ' . $timestamp . ')', ['app' => 'files_trashbin']); |
|
|
474
|
+ \OC::$server->getLogger()->error('trash bin database inconsistent! ($user: '.$user.' $filename: '.$filename.', $timestamp: '.$timestamp.')', ['app' => 'files_trashbin']); |
|
475
|
475
|
} else { |
|
476
|
476
|
// if location no longer exists, restore file in the root directory |
|
477
|
477
|
if ($location !== '/' && |
|
478
|
|
- (!$view->is_dir('files/' . $location) || |
|
479
|
|
- !$view->isCreatable('files/' . $location)) |
|
|
478
|
+ (!$view->is_dir('files/'.$location) || |
|
|
479
|
+ !$view->isCreatable('files/'.$location)) |
|
480
|
480
|
) { |
|
481
|
481
|
$location = ''; |
|
482
|
482
|
} |
|
@@ -486,8 +486,8 @@ discard block |
|
|
block discarded – undo |
|
486
|
486
|
// we need a extension in case a file/dir with the same name already exists |
|
487
|
487
|
$uniqueFilename = self::getUniqueFilename($location, $filename, $view); |
|
488
|
488
|
|
|
489
|
|
- $source = Filesystem::normalizePath('files_trashbin/files/' . $file); |
|
490
|
|
- $target = Filesystem::normalizePath('files/' . $location . '/' . $uniqueFilename); |
|
|
489
|
+ $source = Filesystem::normalizePath('files_trashbin/files/'.$file); |
|
|
490
|
+ $target = Filesystem::normalizePath('files/'.$location.'/'.$uniqueFilename); |
|
491
|
491
|
if (!$view->file_exists($source)) { |
|
492
|
492
|
return false; |
|
493
|
493
|
} |
|
@@ -502,10 +502,10 @@ discard block |
|
|
block discarded – undo |
|
502
|
502
|
// handle the restore result |
|
503
|
503
|
if ($restoreResult) { |
|
504
|
504
|
$fakeRoot = $view->getRoot(); |
|
505
|
|
- $view->chroot('/' . $user . '/files'); |
|
506
|
|
- $view->touch('/' . $location . '/' . $uniqueFilename, $mtime); |
|
|
505
|
+ $view->chroot('/'.$user.'/files'); |
|
|
506
|
+ $view->touch('/'.$location.'/'.$uniqueFilename, $mtime); |
|
507
|
507
|
$view->chroot($fakeRoot); |
|
508
|
|
- \OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', ['filePath' => Filesystem::normalizePath('/' . $location . '/' . $uniqueFilename), |
|
|
508
|
+ \OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', ['filePath' => Filesystem::normalizePath('/'.$location.'/'.$uniqueFilename), |
|
509
|
509
|
'trashPath' => Filesystem::normalizePath($file)]); |
|
510
|
510
|
|
|
511
|
511
|
self::restoreVersions($view, $file, $filename, $uniqueFilename, $location, $timestamp); |
|
@@ -541,7 +541,7 @@ discard block |
|
|
block discarded – undo |
|
541
|
541
|
$user = User::getUser(); |
|
542
|
542
|
$rootView = new View('/'); |
|
543
|
543
|
|
|
544
|
|
- $target = Filesystem::normalizePath('/' . $location . '/' . $uniqueFilename); |
|
|
544
|
+ $target = Filesystem::normalizePath('/'.$location.'/'.$uniqueFilename); |
|
545
|
545
|
|
|
546
|
546
|
[$owner, $ownerPath] = self::getUidAndFilename($target); |
|
547
|
547
|
|
|
@@ -556,14 +556,14 @@ discard block |
|
|
block discarded – undo |
|
556
|
556
|
$versionedFile = $file; |
|
557
|
557
|
} |
|
558
|
558
|
|
|
559
|
|
- if ($view->is_dir('/files_trashbin/versions/' . $file)) { |
|
560
|
|
- $rootView->rename(Filesystem::normalizePath($user . '/files_trashbin/versions/' . $file), Filesystem::normalizePath($owner . '/files_versions/' . $ownerPath)); |
|
|
559
|
+ if ($view->is_dir('/files_trashbin/versions/'.$file)) { |
|
|
560
|
+ $rootView->rename(Filesystem::normalizePath($user.'/files_trashbin/versions/'.$file), Filesystem::normalizePath($owner.'/files_versions/'.$ownerPath)); |
|
561
|
561
|
} elseif ($versions = self::getVersionsFromTrash($versionedFile, $timestamp, $user)) { |
|
562
|
562
|
foreach ($versions as $v) { |
|
563
|
563
|
if ($timestamp) { |
|
564
|
|
- $rootView->rename($user . '/files_trashbin/versions/' . $versionedFile . '.v' . $v . '.d' . $timestamp, $owner . '/files_versions/' . $ownerPath . '.v' . $v); |
|
|
564
|
+ $rootView->rename($user.'/files_trashbin/versions/'.$versionedFile.'.v'.$v.'.d'.$timestamp, $owner.'/files_versions/'.$ownerPath.'.v'.$v); |
|
565
|
565
|
} else { |
|
566
|
|
- $rootView->rename($user . '/files_trashbin/versions/' . $versionedFile . '.v' . $v, $owner . '/files_versions/' . $ownerPath . '.v' . $v); |
|
|
566
|
+ $rootView->rename($user.'/files_trashbin/versions/'.$versionedFile.'.v'.$v, $owner.'/files_versions/'.$ownerPath.'.v'.$v); |
|
567
|
567
|
} |
|
568
|
568
|
} |
|
569
|
569
|
} |
|
@@ -576,7 +576,7 @@ discard block |
|
|
block discarded – undo |
|
576
|
576
|
public static function deleteAll() { |
|
577
|
577
|
$user = User::getUser(); |
|
578
|
578
|
$userRoot = \OC::$server->getUserFolder($user)->getParent(); |
|
579
|
|
- $view = new View('/' . $user); |
|
|
579
|
+ $view = new View('/'.$user); |
|
580
|
580
|
$fileInfos = $view->getDirectoryContent('files_trashbin/files'); |
|
581
|
581
|
|
|
582
|
582
|
try { |
|
@@ -651,7 +651,7 @@ discard block |
|
|
block discarded – undo |
|
651
|
651
|
*/ |
|
652
|
652
|
public static function delete($filename, $user, $timestamp = null) { |
|
653
|
653
|
$userRoot = \OC::$server->getUserFolder($user)->getParent(); |
|
654
|
|
- $view = new View('/' . $user); |
|
|
654
|
+ $view = new View('/'.$user); |
|
655
|
655
|
$size = 0; |
|
656
|
656
|
|
|
657
|
657
|
if ($timestamp) { |
|
@@ -662,7 +662,7 @@ discard block |
|
|
block discarded – undo |
|
662
|
662
|
->andWhere($query->expr()->eq('timestamp', $query->createNamedParameter($timestamp))); |
|
663
|
663
|
$query->executeUpdate(); |
|
664
|
664
|
|
|
665
|
|
- $file = $filename . '.d' . $timestamp; |
|
|
665
|
+ $file = $filename.'.d'.$timestamp; |
|
666
|
666
|
} else { |
|
667
|
667
|
$file = $filename; |
|
668
|
668
|
} |
|
@@ -670,20 +670,20 @@ discard block |
|
|
block discarded – undo |
|
670
|
670
|
$size += self::deleteVersions($view, $file, $filename, $timestamp, $user); |
|
671
|
671
|
|
|
672
|
672
|
try { |
|
673
|
|
- $node = $userRoot->get('/files_trashbin/files/' . $file); |
|
|
673
|
+ $node = $userRoot->get('/files_trashbin/files/'.$file); |
|
674
|
674
|
} catch (NotFoundException $e) { |
|
675
|
675
|
return $size; |
|
676
|
676
|
} |
|
677
|
677
|
|
|
678
|
678
|
if ($node instanceof Folder) { |
|
679
|
|
- $size += self::calculateSize(new View('/' . $user . '/files_trashbin/files/' . $file)); |
|
|
679
|
+ $size += self::calculateSize(new View('/'.$user.'/files_trashbin/files/'.$file)); |
|
680
|
680
|
} elseif ($node instanceof File) { |
|
681
|
|
- $size += $view->filesize('/files_trashbin/files/' . $file); |
|
|
681
|
+ $size += $view->filesize('/files_trashbin/files/'.$file); |
|
682
|
682
|
} |
|
683
|
683
|
|
|
684
|
|
- self::emitTrashbinPreDelete('/files_trashbin/files/' . $file); |
|
|
684
|
+ self::emitTrashbinPreDelete('/files_trashbin/files/'.$file); |
|
685
|
685
|
$node->delete(); |
|
686
|
|
- self::emitTrashbinPostDelete('/files_trashbin/files/' . $file); |
|
|
686
|
+ self::emitTrashbinPostDelete('/files_trashbin/files/'.$file); |
|
687
|
687
|
|
|
688
|
688
|
return $size; |
|
689
|
689
|
} |
|
@@ -699,17 +699,17 @@ discard block |
|
|
block discarded – undo |
|
699
|
699
|
private static function deleteVersions(View $view, $file, $filename, $timestamp, $user) { |
|
700
|
700
|
$size = 0; |
|
701
|
701
|
if (\OCP\App::isEnabled('files_versions')) { |
|
702
|
|
- if ($view->is_dir('files_trashbin/versions/' . $file)) { |
|
703
|
|
- $size += self::calculateSize(new View('/' . $user . '/files_trashbin/versions/' . $file)); |
|
704
|
|
- $view->unlink('files_trashbin/versions/' . $file); |
|
|
702
|
+ if ($view->is_dir('files_trashbin/versions/'.$file)) { |
|
|
703
|
+ $size += self::calculateSize(new View('/'.$user.'/files_trashbin/versions/'.$file)); |
|
|
704
|
+ $view->unlink('files_trashbin/versions/'.$file); |
|
705
|
705
|
} elseif ($versions = self::getVersionsFromTrash($filename, $timestamp, $user)) { |
|
706
|
706
|
foreach ($versions as $v) { |
|
707
|
707
|
if ($timestamp) { |
|
708
|
|
- $size += $view->filesize('/files_trashbin/versions/' . $filename . '.v' . $v . '.d' . $timestamp); |
|
709
|
|
- $view->unlink('/files_trashbin/versions/' . $filename . '.v' . $v . '.d' . $timestamp); |
|
|
708
|
+ $size += $view->filesize('/files_trashbin/versions/'.$filename.'.v'.$v.'.d'.$timestamp); |
|
|
709
|
+ $view->unlink('/files_trashbin/versions/'.$filename.'.v'.$v.'.d'.$timestamp); |
|
710
|
710
|
} else { |
|
711
|
|
- $size += $view->filesize('/files_trashbin/versions/' . $filename . '.v' . $v); |
|
712
|
|
- $view->unlink('/files_trashbin/versions/' . $filename . '.v' . $v); |
|
|
711
|
+ $size += $view->filesize('/files_trashbin/versions/'.$filename.'.v'.$v); |
|
|
712
|
+ $view->unlink('/files_trashbin/versions/'.$filename.'.v'.$v); |
|
713
|
713
|
} |
|
714
|
714
|
} |
|
715
|
715
|
} |
|
@@ -726,13 +726,13 @@ discard block |
|
|
block discarded – undo |
|
726
|
726
|
*/ |
|
727
|
727
|
public static function file_exists($filename, $timestamp = null) { |
|
728
|
728
|
$user = User::getUser(); |
|
729
|
|
- $view = new View('/' . $user); |
|
|
729
|
+ $view = new View('/'.$user); |
|
730
|
730
|
|
|
731
|
731
|
if ($timestamp) { |
|
732
|
|
- $filename = $filename . '.d' . $timestamp; |
|
|
732
|
+ $filename = $filename.'.d'.$timestamp; |
|
733
|
733
|
} |
|
734
|
734
|
|
|
735
|
|
- $target = Filesystem::normalizePath('files_trashbin/files/' . $filename); |
|
|
735
|
+ $target = Filesystem::normalizePath('files_trashbin/files/'.$filename); |
|
736
|
736
|
return $view->file_exists($target); |
|
737
|
737
|
} |
|
738
|
738
|
|
|
@@ -758,11 +758,11 @@ discard block |
|
|
block discarded – undo |
|
758
|
758
|
*/ |
|
759
|
759
|
private static function calculateFreeSpace($trashbinSize, $user) { |
|
760
|
760
|
$config = \OC::$server->getConfig(); |
|
761
|
|
- $userTrashbinSize = (int)$config->getUserValue($user, 'files_trashbin', 'trashbin_size', '-1'); |
|
|
761
|
+ $userTrashbinSize = (int) $config->getUserValue($user, 'files_trashbin', 'trashbin_size', '-1'); |
|
762
|
762
|
if ($userTrashbinSize > -1) { |
|
763
|
763
|
return $userTrashbinSize - $trashbinSize; |
|
764
|
764
|
} |
|
765
|
|
- $systemTrashbinSize = (int)$config->getAppValue('files_trashbin', 'trashbin_size', '-1'); |
|
|
765
|
+ $systemTrashbinSize = (int) $config->getAppValue('files_trashbin', 'trashbin_size', '-1'); |
|
766
|
766
|
if ($systemTrashbinSize > -1) { |
|
767
|
767
|
return $systemTrashbinSize - $trashbinSize; |
|
768
|
768
|
} |
|
@@ -871,7 +871,7 @@ discard block |
|
|
block discarded – undo |
|
871
|
871
|
foreach ($files as $file) { |
|
872
|
872
|
if ($availableSpace < 0 && $expiration->isExpired($file['mtime'], true)) { |
|
873
|
873
|
$tmp = self::delete($file['name'], $user, $file['mtime']); |
|
874
|
|
- \OC::$server->getLogger()->info('remove "' . $file['name'] . '" (' . $tmp . 'B) to meet the limit of trash bin size (50% of available quota)', ['app' => 'files_trashbin']); |
|
|
874
|
+ \OC::$server->getLogger()->info('remove "'.$file['name'].'" ('.$tmp.'B) to meet the limit of trash bin size (50% of available quota)', ['app' => 'files_trashbin']); |
|
875
|
875
|
$availableSpace += $tmp; |
|
876
|
876
|
$size += $tmp; |
|
877
|
877
|
} else { |
|
@@ -902,10 +902,10 @@ discard block |
|
|
block discarded – undo |
|
902
|
902
|
$size += self::delete($filename, $user, $timestamp); |
|
903
|
903
|
$count++; |
|
904
|
904
|
} catch (\OCP\Files\NotPermittedException $e) { |
|
905
|
|
- \OC::$server->getLogger()->logException($e, ['app' => 'files_trashbin', 'level' => \OCP\ILogger::WARN, 'message' => 'Removing "' . $filename . '" from trashbin failed.']); |
|
|
905
|
+ \OC::$server->getLogger()->logException($e, ['app' => 'files_trashbin', 'level' => \OCP\ILogger::WARN, 'message' => 'Removing "'.$filename.'" from trashbin failed.']); |
|
906
|
906
|
} |
|
907
|
907
|
\OC::$server->getLogger()->info( |
|
908
|
|
- 'Remove "' . $filename . '" from trashbin because it exceeds max retention obligation term.', |
|
|
908
|
+ 'Remove "'.$filename.'" from trashbin because it exceeds max retention obligation term.', |
|
909
|
909
|
['app' => 'files_trashbin'] |
|
910
|
910
|
); |
|
911
|
911
|
} else { |
|
@@ -931,16 +931,16 @@ discard block |
|
|
block discarded – undo |
|
931
|
931
|
$view->mkdir($destination); |
|
932
|
932
|
$view->touch($destination, $view->filemtime($source)); |
|
933
|
933
|
foreach ($view->getDirectoryContent($source) as $i) { |
|
934
|
|
- $pathDir = $source . '/' . $i['name']; |
|
|
934
|
+ $pathDir = $source.'/'.$i['name']; |
|
935
|
935
|
if ($view->is_dir($pathDir)) { |
|
936
|
|
- $size += self::copy_recursive($pathDir, $destination . '/' . $i['name'], $view); |
|
|
936
|
+ $size += self::copy_recursive($pathDir, $destination.'/'.$i['name'], $view); |
|
937
|
937
|
} else { |
|
938
|
938
|
$size += $view->filesize($pathDir); |
|
939
|
|
- $result = $view->copy($pathDir, $destination . '/' . $i['name']); |
|
|
939
|
+ $result = $view->copy($pathDir, $destination.'/'.$i['name']); |
|
940
|
940
|
if (!$result) { |
|
941
|
941
|
throw new \OCA\Files_Trashbin\Exceptions\CopyRecursiveException(); |
|
942
|
942
|
} |
|
943
|
|
- $view->touch($destination . '/' . $i['name'], $view->filemtime($pathDir)); |
|
|
943
|
+ $view->touch($destination.'/'.$i['name'], $view->filemtime($pathDir)); |
|
944
|
944
|
} |
|
945
|
945
|
} |
|
946
|
946
|
} else { |
|
@@ -962,11 +962,11 @@ discard block |
|
|
block discarded – undo |
|
962
|
962
|
* @return array |
|
963
|
963
|
*/ |
|
964
|
964
|
private static function getVersionsFromTrash($filename, $timestamp, $user) { |
|
965
|
|
- $view = new View('/' . $user . '/files_trashbin/versions'); |
|
|
965
|
+ $view = new View('/'.$user.'/files_trashbin/versions'); |
|
966
|
966
|
$versions = []; |
|
967
|
967
|
|
|
968
|
968
|
/** @var \OC\Files\Storage\Storage $storage */ |
|
969
|
|
- [$storage,] = $view->resolvePath('/'); |
|
|
969
|
+ [$storage, ] = $view->resolvePath('/'); |
|
970
|
970
|
|
|
971
|
971
|
//force rescan of versions, local storage may not have updated the cache |
|
972
|
972
|
if (!self::$scannedVersions) { |
|
@@ -978,7 +978,7 @@ discard block |
|
|
block discarded – undo |
|
978
|
978
|
if ($timestamp) { |
|
979
|
979
|
// fetch for old versions |
|
980
|
980
|
$escapedTimestamp = \OC::$server->getDatabaseConnection()->escapeLikeParameter($timestamp); |
|
981
|
|
- $pattern .= '.v%.d' . $escapedTimestamp; |
|
|
981
|
+ $pattern .= '.v%.d'.$escapedTimestamp; |
|
982
|
982
|
$offset = -strlen($escapedTimestamp) - 2; |
|
983
|
983
|
} else { |
|
984
|
984
|
$pattern .= '.v%'; |
|
@@ -992,7 +992,7 @@ discard block |
|
|
block discarded – undo |
|
992
|
992
|
\OC::$server->getLogger(), |
|
993
|
993
|
$cache |
|
994
|
994
|
); |
|
995
|
|
- $normalizedParentPath = ltrim(Filesystem::normalizePath(dirname('files_trashbin/versions/'. $filename)), '/'); |
|
|
995
|
+ $normalizedParentPath = ltrim(Filesystem::normalizePath(dirname('files_trashbin/versions/'.$filename)), '/'); |
|
996
|
996
|
$parentId = $cache->getId($normalizedParentPath); |
|
997
|
997
|
if ($parentId === -1) { |
|
998
|
998
|
return []; |
|
@@ -1008,7 +1008,7 @@ discard block |
|
|
block discarded – undo |
|
1008
|
1008
|
$result->closeCursor(); |
|
1009
|
1009
|
|
|
1010
|
1010
|
/** @var CacheEntry[] $matches */ |
|
1011
|
|
- $matches = array_map(function (array $data) { |
|
|
1011
|
+ $matches = array_map(function(array $data) { |
|
1012
|
1012
|
return Cache::cacheEntryFromData($data, \OC::$server->getMimeTypeLoader()); |
|
1013
|
1013
|
}, $entries); |
|
1014
|
1014
|
|
|
@@ -1038,18 +1038,18 @@ discard block |
|
|
block discarded – undo |
|
1038
|
1038
|
$name = pathinfo($filename, PATHINFO_FILENAME); |
|
1039
|
1039
|
$l = \OC::$server->getL10N('files_trashbin'); |
|
1040
|
1040
|
|
|
1041
|
|
- $location = '/' . trim($location, '/'); |
|
|
1041
|
+ $location = '/'.trim($location, '/'); |
|
1042
|
1042
|
|
|
1043
|
1043
|
// if extension is not empty we set a dot in front of it |
|
1044
|
1044
|
if ($ext !== '') { |
|
1045
|
|
- $ext = '.' . $ext; |
|
|
1045
|
+ $ext = '.'.$ext; |
|
1046
|
1046
|
} |
|
1047
|
1047
|
|
|
1048
|
|
- if ($view->file_exists('files' . $location . '/' . $filename)) { |
|
|
1048
|
+ if ($view->file_exists('files'.$location.'/'.$filename)) { |
|
1049
|
1049
|
$i = 2; |
|
1050
|
|
- $uniqueName = $name . " (" . $l->t("restored") . ")" . $ext; |
|
1051
|
|
- while ($view->file_exists('files' . $location . '/' . $uniqueName)) { |
|
1052
|
|
- $uniqueName = $name . " (" . $l->t("restored") . " " . $i . ")" . $ext; |
|
|
1050
|
+ $uniqueName = $name." (".$l->t("restored").")".$ext; |
|
|
1051
|
+ while ($view->file_exists('files'.$location.'/'.$uniqueName)) { |
|
|
1052
|
+ $uniqueName = $name." (".$l->t("restored")." ".$i.")".$ext; |
|
1053
|
1053
|
$i++; |
|
1054
|
1054
|
} |
|
1055
|
1055
|
|
|
@@ -1066,7 +1066,7 @@ discard block |
|
|
block discarded – undo |
|
1066
|
1066
|
* @return integer size of the folder |
|
1067
|
1067
|
*/ |
|
1068
|
1068
|
private static function calculateSize($view) { |
|
1069
|
|
- $root = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . $view->getAbsolutePath(''); |
|
|
1069
|
+ $root = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data').$view->getAbsolutePath(''); |
|
1070
|
1070
|
if (!file_exists($root)) { |
|
1071
|
1071
|
return 0; |
|
1072
|
1072
|
} |
|
@@ -1097,7 +1097,7 @@ discard block |
|
|
block discarded – undo |
|
1097
|
1097
|
* @return integer trash bin size |
|
1098
|
1098
|
*/ |
|
1099
|
1099
|
private static function getTrashbinSize($user) { |
|
1100
|
|
- $view = new View('/' . $user); |
|
|
1100
|
+ $view = new View('/'.$user); |
|
1101
|
1101
|
$fileInfo = $view->getFileInfo('/files_trashbin'); |
|
1102
|
1102
|
return isset($fileInfo['size']) ? $fileInfo['size'] : 0; |
|
1103
|
1103
|
} |
|
@@ -1109,7 +1109,7 @@ discard block |
|
|
block discarded – undo |
|
1109
|
1109
|
* @return bool |
|
1110
|
1110
|
*/ |
|
1111
|
1111
|
public static function isEmpty($user) { |
|
1112
|
|
- $view = new View('/' . $user . '/files_trashbin'); |
|
|
1112
|
+ $view = new View('/'.$user.'/files_trashbin'); |
|
1113
|
1113
|
if ($view->is_dir('/files') && $dh = $view->opendir('/files')) { |
|
1114
|
1114
|
while ($file = readdir($dh)) { |
|
1115
|
1115
|
if (!Filesystem::isIgnoredDir($file)) { |