aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin/lib
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2024-10-10 12:40:31 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2024-10-15 10:40:25 +0200
commit1580c8612b01bfa780d1a7372080a27d182fb7dd (patch)
treeb2776d0cd254ac9d6e54828978ce18b702f550d5 /apps/files_trashbin/lib
parent4ff9b3e0ce53227e2be47c4c2dcb1fdc3e540b5f (diff)
downloadnextcloud-server-1580c8612b01bfa780d1a7372080a27d182fb7dd.tar.gz
nextcloud-server-1580c8612b01bfa780d1a7372080a27d182fb7dd.zip
chore(apps): Apply new rector configuration to autouse classes
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/files_trashbin/lib')
-rw-r--r--apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php3
-rw-r--r--apps/files_trashbin/lib/Command/ExpireTrash.php3
-rw-r--r--apps/files_trashbin/lib/Command/RestoreAllFiles.php3
-rw-r--r--apps/files_trashbin/lib/Controller/PreviewController.php3
-rw-r--r--apps/files_trashbin/lib/Helper.php7
-rw-r--r--apps/files_trashbin/lib/Sabre/TrashRoot.php3
-rw-r--r--apps/files_trashbin/lib/Trash/LegacyTrashBackend.php2
-rw-r--r--apps/files_trashbin/lib/Trashbin.php33
-rw-r--r--apps/files_trashbin/lib/UserMigration/TrashbinMigrator.php3
9 files changed, 35 insertions, 25 deletions
diff --git a/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php b/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php
index 651f5035c1c..b5980b27c0a 100644
--- a/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php
+++ b/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php
@@ -6,6 +6,7 @@
*/
namespace OCA\Files_Trashbin\BackgroundJob;
+use OC\Files\View;
use OCA\Files_Trashbin\Expiration;
use OCA\Files_Trashbin\Helper;
use OCA\Files_Trashbin\Trashbin;
@@ -70,7 +71,7 @@ class ExpireTrash extends TimedJob {
\OC_Util::setupFS($user);
// Check if this user has a trashbin directory
- $view = new \OC\Files\View('/' . $user);
+ $view = new View('/' . $user);
if (!$view->is_dir('/files_trashbin/files')) {
return false;
}
diff --git a/apps/files_trashbin/lib/Command/ExpireTrash.php b/apps/files_trashbin/lib/Command/ExpireTrash.php
index 33a5ac83dbf..c27d74c0c26 100644
--- a/apps/files_trashbin/lib/Command/ExpireTrash.php
+++ b/apps/files_trashbin/lib/Command/ExpireTrash.php
@@ -6,6 +6,7 @@
*/
namespace OCA\Files_Trashbin\Command;
+use OC\Files\View;
use OCA\Files_Trashbin\Expiration;
use OCA\Files_Trashbin\Helper;
use OCA\Files_Trashbin\Trashbin;
@@ -103,7 +104,7 @@ class ExpireTrash extends Command {
\OC_Util::setupFS($user);
// Check if this user has a trashbin directory
- $view = new \OC\Files\View('/' . $user);
+ $view = new View('/' . $user);
if (!$view->is_dir('/files_trashbin/files')) {
return false;
}
diff --git a/apps/files_trashbin/lib/Command/RestoreAllFiles.php b/apps/files_trashbin/lib/Command/RestoreAllFiles.php
index 969791379c1..81b59543a4e 100644
--- a/apps/files_trashbin/lib/Command/RestoreAllFiles.php
+++ b/apps/files_trashbin/lib/Command/RestoreAllFiles.php
@@ -7,6 +7,7 @@ namespace OCA\Files_Trashbin\Command;
use OC\Core\Command\Base;
use OCA\Files_Trashbin\Trash\ITrashManager;
+use OCA\Files_Trashbin\Trash\TrashItem;
use OCP\Files\IRootFolder;
use OCP\IDBConnection;
use OCP\IL10N;
@@ -246,7 +247,7 @@ class RestoreAllFiles extends Base {
$trashItemClass = get_class($trashItem);
// Check scope with exact class name for locally deleted files
- if ($scope === self::SCOPE_USER && $trashItemClass !== \OCA\Files_Trashbin\Trash\TrashItem::class) {
+ if ($scope === self::SCOPE_USER && $trashItemClass !== TrashItem::class) {
$output->writeln('Skipping <info>' . $trashItem->getName() . '</info> because it is not a user trash item', OutputInterface::VERBOSITY_VERBOSE);
continue;
}
diff --git a/apps/files_trashbin/lib/Controller/PreviewController.php b/apps/files_trashbin/lib/Controller/PreviewController.php
index b006ba5e5ac..78d501b68d4 100644
--- a/apps/files_trashbin/lib/Controller/PreviewController.php
+++ b/apps/files_trashbin/lib/Controller/PreviewController.php
@@ -14,6 +14,7 @@ use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
use OCP\AppFramework\Http\DataResponse;
+use OCP\AppFramework\Http\FileDisplayResponse;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Files\Folder;
use OCP\Files\IMimeTypeDetector;
@@ -111,7 +112,7 @@ class PreviewController extends Controller {
}
$f = $this->previewManager->getPreview($file, $x, $y, !$a, IPreview::MODE_FILL, $mimeType);
- $response = new Http\FileDisplayResponse($f, Http::STATUS_OK, ['Content-Type' => $f->getMimeType()]);
+ $response = new FileDisplayResponse($f, Http::STATUS_OK, ['Content-Type' => $f->getMimeType()]);
// Cache previews for 24H
$response->cacheFor(3600 * 24);
diff --git a/apps/files_trashbin/lib/Helper.php b/apps/files_trashbin/lib/Helper.php
index 2e7916d9c6d..7aeb737a56c 100644
--- a/apps/files_trashbin/lib/Helper.php
+++ b/apps/files_trashbin/lib/Helper.php
@@ -7,6 +7,7 @@
namespace OCA\Files_Trashbin;
use OC\Files\FileInfo;
+use OC\Files\View;
use OCP\Constants;
use OCP\Files\Cache\ICacheEntry;
@@ -25,7 +26,7 @@ class Helper {
$result = [];
$timestamp = null;
- $view = new \OC\Files\View('/' . $user . '/files_trashbin/files');
+ $view = new View('/' . $user . '/files_trashbin/files');
if (ltrim($dir, '/') !== '' && !$view->is_dir($dir)) {
throw new \Exception('Directory does not exists');
@@ -36,7 +37,7 @@ class Helper {
$absoluteDir = $view->getAbsolutePath($dir);
$internalPath = $mount->getInternalPath($absoluteDir);
- $extraData = \OCA\Files_Trashbin\Trashbin::getExtraData($user);
+ $extraData = Trashbin::getExtraData($user);
$dirContent = $storage->getCache()->getFolderContents($mount->getInternalPath($view->getAbsolutePath($dir)));
foreach ($dirContent as $entry) {
$entryName = $entry->getName();
@@ -98,7 +99,7 @@ class Helper {
$entry = \OCA\Files\Helper::formatFileInfo($i);
$entry['id'] = $i->getId();
$entry['etag'] = $entry['mtime']; // add fake etag, it is only needed to identify the preview image
- $entry['permissions'] = \OCP\Constants::PERMISSION_READ;
+ $entry['permissions'] = Constants::PERMISSION_READ;
$files[] = $entry;
}
return $files;
diff --git a/apps/files_trashbin/lib/Sabre/TrashRoot.php b/apps/files_trashbin/lib/Sabre/TrashRoot.php
index 3421a56bd5a..e2661ccdec7 100644
--- a/apps/files_trashbin/lib/Sabre/TrashRoot.php
+++ b/apps/files_trashbin/lib/Sabre/TrashRoot.php
@@ -10,6 +10,7 @@ namespace OCA\Files_Trashbin\Sabre;
use OCA\Files_Trashbin\Trash\ITrashItem;
use OCA\Files_Trashbin\Trash\ITrashManager;
+use OCA\Files_Trashbin\Trashbin;
use OCP\Files\FileInfo;
use OCP\IUser;
use Sabre\DAV\Exception\Forbidden;
@@ -30,7 +31,7 @@ class TrashRoot implements ICollection {
}
public function delete() {
- \OCA\Files_Trashbin\Trashbin::deleteAll();
+ Trashbin::deleteAll();
foreach ($this->trashManager->listTrashRoot($this->user) as $trashItem) {
$this->trashManager->removeItem($trashItem);
}
diff --git a/apps/files_trashbin/lib/Trash/LegacyTrashBackend.php b/apps/files_trashbin/lib/Trash/LegacyTrashBackend.php
index 862c746c239..0fd370a6cf1 100644
--- a/apps/files_trashbin/lib/Trash/LegacyTrashBackend.php
+++ b/apps/files_trashbin/lib/Trash/LegacyTrashBackend.php
@@ -92,7 +92,7 @@ class LegacyTrashBackend implements ITrashBackend {
$this->deletedFiles[$normalized] = $normalized;
if ($filesPath = $view->getRelativePath($normalized)) {
$filesPath = trim($filesPath, '/');
- $result = \OCA\Files_Trashbin\Trashbin::move2trash($filesPath);
+ $result = Trashbin::move2trash($filesPath);
} else {
$result = false;
}
diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php
index a30ba0ce055..f6e5a3830ad 100644
--- a/apps/files_trashbin/lib/Trashbin.php
+++ b/apps/files_trashbin/lib/Trashbin.php
@@ -19,6 +19,8 @@ use OCA\Files_Trashbin\AppInfo\Application;
use OCA\Files_Trashbin\Command\Expire;
use OCA\Files_Trashbin\Events\BeforeNodeRestoredEvent;
use OCA\Files_Trashbin\Events\NodeRestoredEvent;
+use OCA\Files_Trashbin\Exceptions\CopyRecursiveException;
+use OCA\Files_Versions\Storage;
use OCP\App\IAppManager;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\EventDispatcher\Event;
@@ -39,6 +41,7 @@ use OCP\IDBConnection;
use OCP\Lock\ILockingProvider;
use OCP\Lock\LockedException;
use OCP\Server;
+use OCP\Util;
use Psr\Log\LoggerInterface;
/** @template-implements IEventListener<BeforeNodeDeletedEvent> */
@@ -293,7 +296,7 @@ class Trashbin implements IEventListener {
if ($sourceStorage->getCache()->inCache($sourceInternalPath)) {
$trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
}
- } catch (\OCA\Files_Trashbin\Exceptions\CopyRecursiveException $e) {
+ } catch (CopyRecursiveException $e) {
$moveSuccessful = false;
if ($trashStorage->file_exists($trashInternalPath)) {
$trashStorage->unlink($trashInternalPath);
@@ -329,7 +332,7 @@ class Trashbin implements IEventListener {
if (!$result) {
\OC::$server->get(LoggerInterface::class)->error('trash bin database couldn\'t be updated', ['app' => 'files_trashbin']);
}
- \OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_moveToTrash', ['filePath' => Filesystem::normalizePath($file_path),
+ Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_moveToTrash', ['filePath' => Filesystem::normalizePath($file_path),
'trashPath' => Filesystem::normalizePath(static::getTrashFilename($filename, $timestamp))]);
self::retainVersions($filename, $owner, $ownerPath, $timestamp);
@@ -356,11 +359,11 @@ class Trashbin implements IEventListener {
$config = \OC::$server->get(IConfig::class);
$userTrashbinSize = $config->getUserValue($user, 'files_trashbin', 'trashbin_size', '-1');
if (is_numeric($userTrashbinSize) && ($userTrashbinSize > -1)) {
- return \OCP\Util::numericToNumber($userTrashbinSize);
+ return Util::numericToNumber($userTrashbinSize);
}
$systemTrashbinSize = $config->getAppValue('files_trashbin', 'trashbin_size', '-1');
if (is_numeric($systemTrashbinSize)) {
- return \OCP\Util::numericToNumber($systemTrashbinSize);
+ return Util::numericToNumber($systemTrashbinSize);
}
return -1;
}
@@ -374,7 +377,7 @@ class Trashbin implements IEventListener {
* @param int $timestamp when the file was deleted
*/
private static function retainVersions($filename, $owner, $ownerPath, $timestamp) {
- if (\OCP\Server::get(IAppManager::class)->isEnabledForUser('files_versions') && !empty($ownerPath)) {
+ if (Server::get(IAppManager::class)->isEnabledForUser('files_versions') && !empty($ownerPath)) {
$user = OC_User::getUser();
$rootView = new View('/');
@@ -383,7 +386,7 @@ class Trashbin implements IEventListener {
self::copy_recursive($owner . '/files_versions/' . $ownerPath, $owner . '/files_trashbin/versions/' . static::getTrashFilename(basename($ownerPath), $timestamp), $rootView);
}
self::move($rootView, $owner . '/files_versions/' . $ownerPath, $user . '/files_trashbin/versions/' . static::getTrashFilename($filename, $timestamp));
- } elseif ($versions = \OCA\Files_Versions\Storage::getVersions($owner, $ownerPath)) {
+ } elseif ($versions = Storage::getVersions($owner, $ownerPath)) {
foreach ($versions as $v) {
if ($owner !== $user) {
self::copy($rootView, $owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $owner . '/files_trashbin/versions/' . static::getTrashFilename($v['name'] . '.v' . $v['version'], $timestamp));
@@ -505,7 +508,7 @@ class Trashbin implements IEventListener {
$view->chroot('/' . $user . '/files');
$view->touch('/' . $location . '/' . $uniqueFilename, $mtime);
$view->chroot($fakeRoot);
- \OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', ['filePath' => $targetPath, 'trashPath' => $sourcePath]);
+ Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', ['filePath' => $targetPath, 'trashPath' => $sourcePath]);
$sourceNode = self::getNodeForPath($sourcePath);
$targetNode = self::getNodeForPath($targetPath);
@@ -542,7 +545,7 @@ class Trashbin implements IEventListener {
* @return false|null
*/
private static function restoreVersions(View $view, $file, $filename, $uniqueFilename, $location, $timestamp) {
- if (\OCP\Server::get(IAppManager::class)->isEnabledForUser('files_versions')) {
+ if (Server::get(IAppManager::class)->isEnabledForUser('files_versions')) {
$user = OC_User::getUser();
$rootView = new View('/');
@@ -700,7 +703,7 @@ class Trashbin implements IEventListener {
*/
private static function deleteVersions(View $view, $file, $filename, $timestamp, string $user): int|float {
$size = 0;
- if (\OCP\Server::get(IAppManager::class)->isEnabledForUser('files_versions')) {
+ if (Server::get(IAppManager::class)->isEnabledForUser('files_versions')) {
if ($view->is_dir('files_trashbin/versions/' . $file)) {
$size += self::calculateSize(new View('/' . $user . '/files_trashbin/versions/' . $file));
$view->unlink('files_trashbin/versions/' . $file);
@@ -778,7 +781,7 @@ class Trashbin implements IEventListener {
$quota = PHP_INT_MAX;
}
} else {
- $quota = \OCP\Util::computerFileSize($quota);
+ $quota = Util::computerFileSize($quota);
// invalid quota
if ($quota === false) {
$quota = PHP_INT_MAX;
@@ -802,7 +805,7 @@ class Trashbin implements IEventListener {
$availableSpace = $quota;
}
- return \OCP\Util::numericToNumber($availableSpace);
+ return Util::numericToNumber($availableSpace);
}
/**
@@ -902,7 +905,7 @@ class Trashbin implements IEventListener {
try {
$size += self::delete($filename, $user, $timestamp);
$count++;
- } catch (\OCP\Files\NotPermittedException $e) {
+ } catch (NotPermittedException $e) {
\OC::$server->get(LoggerInterface::class)->warning('Removing "' . $filename . '" from trashbin failed.',
[
'exception' => $e,
@@ -944,7 +947,7 @@ class Trashbin implements IEventListener {
$size += $view->filesize($pathDir);
$result = $view->copy($pathDir, $destination . '/' . $i['name']);
if (!$result) {
- throw new \OCA\Files_Trashbin\Exceptions\CopyRecursiveException();
+ throw new CopyRecursiveException();
}
$view->touch($destination . '/' . $i['name'], $view->filemtime($pathDir));
}
@@ -953,7 +956,7 @@ class Trashbin implements IEventListener {
$size += $view->filesize($source);
$result = $view->copy($source, $destination);
if (!$result) {
- throw new \OCA\Files_Trashbin\Exceptions\CopyRecursiveException();
+ throw new CopyRecursiveException();
}
$view->touch($destination, $view->filemtime($source));
}
@@ -1033,7 +1036,7 @@ class Trashbin implements IEventListener {
private static function getUniqueFilename($location, $filename, View $view) {
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$name = pathinfo($filename, PATHINFO_FILENAME);
- $l = \OCP\Util::getL10N('files_trashbin');
+ $l = Util::getL10N('files_trashbin');
$location = '/' . trim($location, '/');
diff --git a/apps/files_trashbin/lib/UserMigration/TrashbinMigrator.php b/apps/files_trashbin/lib/UserMigration/TrashbinMigrator.php
index 87c8647450f..b58efbb38a6 100644
--- a/apps/files_trashbin/lib/UserMigration/TrashbinMigrator.php
+++ b/apps/files_trashbin/lib/UserMigration/TrashbinMigrator.php
@@ -10,6 +10,7 @@ declare(strict_types=1);
namespace OCA\Files_Trashbin\UserMigration;
use OCA\Files_Trashbin\AppInfo\Application;
+use OCA\Files_Trashbin\Trashbin;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
@@ -81,7 +82,7 @@ class TrashbinMigrator implements IMigrator, ISizeEstimationMigrator {
$exportDestination->copyFolder($trashbinFolder, static::PATH_FILES_FOLDER);
$originalLocations = [];
// TODO Export all extra data and bump migrator to v2
- foreach (\OCA\Files_Trashbin\Trashbin::getExtraData($uid) as $filename => $extraData) {
+ foreach (Trashbin::getExtraData($uid) as $filename => $extraData) {
$locationData = [];
foreach ($extraData as $timestamp => ['location' => $location]) {
$locationData[$timestamp] = $location;