diff options
Diffstat (limited to 'apps/files/lib')
-rw-r--r-- | apps/files/lib/Command/Scan.php | 3 | ||||
-rw-r--r-- | apps/files/lib/Command/ScanAppData.php | 3 | ||||
-rw-r--r-- | apps/files/lib/Controller/ApiController.php | 8 | ||||
-rw-r--r-- | apps/files/lib/Controller/ViewController.php | 8 | ||||
-rw-r--r-- | apps/files/lib/Helper.php | 12 | ||||
-rw-r--r-- | apps/files/lib/Listener/LoadSearchPluginsListener.php | 3 | ||||
-rw-r--r-- | apps/files/lib/Listener/RenderReferenceEventListener.php | 3 | ||||
-rw-r--r-- | apps/files/lib/Service/OwnershipTransferService.php | 13 | ||||
-rw-r--r-- | apps/files/lib/Settings/PersonalSettings.php | 3 |
9 files changed, 35 insertions, 21 deletions
diff --git a/apps/files/lib/Command/Scan.php b/apps/files/lib/Command/Scan.php index 283ce17cd85..cf1cb04b9af 100644 --- a/apps/files/lib/Command/Scan.php +++ b/apps/files/lib/Command/Scan.php @@ -11,6 +11,7 @@ use OC\Core\Command\Base; use OC\Core\Command\InterruptedException; use OC\DB\Connection; use OC\DB\ConnectionAdapter; +use OC\Files\Utils\Scanner; use OC\FilesMetadata\FilesMetadataManager; use OC\ForbiddenException; use OCP\EventDispatcher\IEventDispatcher; @@ -98,7 +99,7 @@ class Scan extends Base { protected function scanFiles(string $user, string $path, ?string $scanMetadata, OutputInterface $output, bool $backgroundScan = false, bool $recursive = true, bool $homeOnly = false): void { $connection = $this->reconnectToDatabase($output); - $scanner = new \OC\Files\Utils\Scanner( + $scanner = new Scanner( $user, new ConnectionAdapter($connection), \OC::$server->get(IEventDispatcher::class), diff --git a/apps/files/lib/Command/ScanAppData.php b/apps/files/lib/Command/ScanAppData.php index 4d89389fe32..4c52297003f 100644 --- a/apps/files/lib/Command/ScanAppData.php +++ b/apps/files/lib/Command/ScanAppData.php @@ -9,6 +9,7 @@ use OC\Core\Command\Base; use OC\Core\Command\InterruptedException; use OC\DB\Connection; use OC\DB\ConnectionAdapter; +use OC\Files\Utils\Scanner; use OC\ForbiddenException; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\IRootFolder; @@ -65,7 +66,7 @@ class ScanAppData extends Base { } $connection = $this->reconnectToDatabase($output); - $scanner = new \OC\Files\Utils\Scanner( + $scanner = new Scanner( null, new ConnectionAdapter($connection), \OC::$server->query(IEventDispatcher::class), diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php index 0ca4a1efd4b..118a4fcb9e2 100644 --- a/apps/files/lib/Controller/ApiController.php +++ b/apps/files/lib/Controller/ApiController.php @@ -8,6 +8,7 @@ namespace OCA\Files\Controller; use OC\Files\Node\Node; +use OCA\Files\Helper; use OCA\Files\ResponseDefinitions; use OCA\Files\Service\TagService; use OCA\Files\Service\UserConfig; @@ -30,6 +31,7 @@ use OCP\Files\File; use OCP\Files\Folder; use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; +use OCP\Files\StorageNotAvailableException; use OCP\IConfig; use OCP\IL10N; use OCP\IPreview; @@ -124,11 +126,11 @@ class ApiController extends Controller { if (!is_null($tags)) { try { $this->tagService->updateFileTags($path, $tags); - } catch (\OCP\Files\NotFoundException $e) { + } catch (NotFoundException $e) { return new DataResponse([ 'message' => $e->getMessage() ], Http::STATUS_NOT_FOUND); - } catch (\OCP\Files\StorageNotAvailableException $e) { + } catch (StorageNotAvailableException $e) { return new DataResponse([ 'message' => $e->getMessage() ], Http::STATUS_SERVICE_UNAVAILABLE); @@ -150,7 +152,7 @@ class ApiController extends Controller { $shareTypesForNodes = $this->getShareTypesForNodes($nodes); return array_values(array_map(function (Node $node) use ($shareTypesForNodes) { $shareTypes = $shareTypesForNodes[$node->getId()] ?? []; - $file = \OCA\Files\Helper::formatFileInfo($node->getFileInfo()); + $file = Helper::formatFileInfo($node->getFileInfo()); $file['hasPreview'] = $this->previewManager->isAvailable($node); $parts = explode('/', dirname($node->getPath()), 4); if (isset($parts[3])) { diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index b5c61aaa5f4..b6aeb079add 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -8,6 +8,7 @@ namespace OCA\Files\Controller; use OC\Files\FilenameValidator; +use OC\Files\Filesystem; use OCA\Files\AppInfo\Application; use OCA\Files\Event\LoadAdditionalScriptsEvent; use OCA\Files\Event\LoadSearchPlugins; @@ -36,6 +37,7 @@ use OCP\IL10N; use OCP\IRequest; use OCP\IURLGenerator; use OCP\IUserSession; +use OCP\Util; /** * @package OCA\Files\Controller @@ -69,7 +71,7 @@ class ViewController extends Controller { * @throws \OCP\Files\NotFoundException */ protected function getStorageInfo(string $dir = '/') { - $rootInfo = \OC\Files\Filesystem::getFileInfo('/', false); + $rootInfo = Filesystem::getFileInfo('/', false); return \OC_Helper::getStorageInfo($dir, $rootInfo ?: null); } @@ -138,8 +140,8 @@ class ViewController extends Controller { } // Load the files we need - \OCP\Util::addInitScript('files', 'init'); - \OCP\Util::addScript('files', 'main'); + Util::addInitScript('files', 'init'); + Util::addScript('files', 'main'); $userId = $this->userSession->getUser()->getUID(); diff --git a/apps/files/lib/Helper.php b/apps/files/lib/Helper.php index 6126c1270eb..4ddab45d441 100644 --- a/apps/files/lib/Helper.php +++ b/apps/files/lib/Helper.php @@ -7,8 +7,10 @@ */ namespace OCA\Files; +use OC\Files\Filesystem; use OCP\Files\FileInfo; use OCP\ITagManager; +use OCP\Util; /** * Helper class for manipulating file information @@ -22,9 +24,9 @@ class Helper { public static function buildFileStorageStatistics($dir) { // information about storage capacities $storageInfo = \OC_Helper::getStorageInfo($dir); - $l = \OCP\Util::getL10N('files'); - $maxUploadFileSize = \OCP\Util::maxUploadFilesize($dir, $storageInfo['free']); - $maxHumanFileSize = \OCP\Util::humanFileSize($maxUploadFileSize); + $l = Util::getL10N('files'); + $maxUploadFileSize = Util::maxUploadFilesize($dir, $storageInfo['free']); + $maxHumanFileSize = Util::humanFileSize($maxUploadFileSize); $maxHumanFileSize = $l->t('Upload (max. %s)', [$maxHumanFileSize]); return [ @@ -80,7 +82,7 @@ class Helper { } elseif ($aType !== 'dir' and $bType === 'dir') { return 1; } else { - return \OCP\Util::naturalSortCompare($a->getName(), $b->getName()); + return Util::naturalSortCompare($a->getName(), $b->getName()); } } @@ -181,7 +183,7 @@ class Helper { * @return \OCP\Files\FileInfo[] files */ public static function getFiles($dir, $sortAttribute = 'name', $sortDescending = false, $mimetypeFilter = '') { - $content = \OC\Files\Filesystem::getDirectoryContent($dir, $mimetypeFilter); + $content = Filesystem::getDirectoryContent($dir, $mimetypeFilter); return self::sortFiles($content, $sortAttribute, $sortDescending); } diff --git a/apps/files/lib/Listener/LoadSearchPluginsListener.php b/apps/files/lib/Listener/LoadSearchPluginsListener.php index c9792242b2c..4cc4ca22f83 100644 --- a/apps/files/lib/Listener/LoadSearchPluginsListener.php +++ b/apps/files/lib/Listener/LoadSearchPluginsListener.php @@ -11,6 +11,7 @@ namespace OCA\Files\Listener; use OCA\Files\Event\LoadSearchPlugins; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; +use OCP\Util; /** @template-implements IEventListener<LoadSearchPlugins> */ class LoadSearchPluginsListener implements IEventListener { @@ -19,6 +20,6 @@ class LoadSearchPluginsListener implements IEventListener { return; } - \OCP\Util::addScript('files', 'search'); + Util::addScript('files', 'search'); } } diff --git a/apps/files/lib/Listener/RenderReferenceEventListener.php b/apps/files/lib/Listener/RenderReferenceEventListener.php index fc8b4d08aeb..b7470e5acf5 100644 --- a/apps/files/lib/Listener/RenderReferenceEventListener.php +++ b/apps/files/lib/Listener/RenderReferenceEventListener.php @@ -11,6 +11,7 @@ namespace OCA\Files\Listener; use OCP\Collaboration\Reference\RenderReferenceEvent; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; +use OCP\Util; /** @template-implements IEventListener<RenderReferenceEvent> */ class RenderReferenceEventListener implements IEventListener { @@ -19,6 +20,6 @@ class RenderReferenceEventListener implements IEventListener { return; } - \OCP\Util::addScript('files', 'reference-files'); + Util::addScript('files', 'reference-files'); } } diff --git a/apps/files/lib/Service/OwnershipTransferService.php b/apps/files/lib/Service/OwnershipTransferService.php index 5a57fae5075..2b06d18efcf 100644 --- a/apps/files/lib/Service/OwnershipTransferService.php +++ b/apps/files/lib/Service/OwnershipTransferService.php @@ -13,6 +13,7 @@ use Closure; use OC\Encryption\Manager as EncryptionManager; use OC\Files\Filesystem; use OC\Files\View; +use OCA\Encryption\Util; use OCA\Files\Exception\TransferOwnershipException; use OCP\Encryption\IManager as IEncryptionManager; use OCP\Files\Config\IUserMountCache; @@ -21,9 +22,11 @@ use OCP\Files\IHomeStorage; use OCP\Files\InvalidPathException; use OCP\Files\IRootFolder; use OCP\Files\Mount\IMountManager; +use OCP\Files\NotFoundException; use OCP\IUser; use OCP\IUserManager; use OCP\L10N\IFactory; +use OCP\Server; use OCP\Share\IManager as IShareManager; use OCP\Share\IShare; use Symfony\Component\Console\Helper\ProgressBar; @@ -227,7 +230,7 @@ class OwnershipTransferService { $progress->start(); if ($this->encryptionManager->isEnabled()) { - $masterKeyEnabled = \OCP\Server::get(\OCA\Encryption\Util::class)->isMasterKeyEnabled(); + $masterKeyEnabled = Server::get(Util::class)->isMasterKeyEnabled(); } else { $masterKeyEnabled = false; } @@ -416,7 +419,7 @@ class OwnershipTransferService { ):void { $output->writeln('Restoring shares ...'); $progress = new ProgressBar($output, count($shares)); - $rootFolder = \OCP\Server::get(IRootFolder::class); + $rootFolder = Server::get(IRootFolder::class); foreach ($shares as ['share' => $share, 'suffix' => $suffix]) { try { @@ -453,7 +456,7 @@ class OwnershipTransferService { // Normally the ID is preserved, // but for transferes between different storages the ID might change $newNodeId = $share->getNode()->getId(); - } catch (\OCP\Files\NotFoundException) { + } catch (NotFoundException) { // ID has changed due to transfer between different storages // Try to get the new ID from the target path and suffix of the share $node = $rootFolder->get(Filesystem::normalizePath($targetLocation . '/' . $suffix)); @@ -465,7 +468,7 @@ class OwnershipTransferService { $this->shareManager->updateShare($share); } } - } catch (\OCP\Files\NotFoundException $e) { + } catch (NotFoundException $e) { $output->writeln('<error>Share with id ' . $share->getId() . ' points at deleted file, skipping</error>'); } catch (\Throwable $e) { $output->writeln('<error>Could not restore share with id ' . $share->getId() . ':' . $e->getMessage() . ' : ' . $e->getTraceAsString() . '</error>'); @@ -545,7 +548,7 @@ class OwnershipTransferService { $this->shareManager->moveShare($share, $destinationUid); continue; } - } catch (\OCP\Files\NotFoundException $e) { + } catch (NotFoundException $e) { $output->writeln('<error>Share with id ' . $share->getId() . ' points at deleted file, skipping</error>'); } catch (\Throwable $e) { $output->writeln('<error>Could not restore share with id ' . $share->getId() . ':' . $e->getTraceAsString() . '</error>'); diff --git a/apps/files/lib/Settings/PersonalSettings.php b/apps/files/lib/Settings/PersonalSettings.php index 484e4bde2b8..fe43265bc13 100644 --- a/apps/files/lib/Settings/PersonalSettings.php +++ b/apps/files/lib/Settings/PersonalSettings.php @@ -11,10 +11,11 @@ namespace OCA\Files\Settings; use OCA\Files\AppInfo\Application; use OCP\AppFramework\Http\TemplateResponse; use OCP\Settings\ISettings; +use OCP\Util; class PersonalSettings implements ISettings { public function getForm(): TemplateResponse { - \OCP\Util::addScript(Application::APP_ID, 'settings-personal'); + Util::addScript(Application::APP_ID, 'settings-personal'); return new TemplateResponse(Application::APP_ID, 'settings-personal'); } |