aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/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_sharing/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_sharing/lib')
-rw-r--r--apps/files_sharing/lib/AppInfo/Application.php4
-rw-r--r--apps/files_sharing/lib/Cache.php2
-rw-r--r--apps/files_sharing/lib/Controller/DeletedShareAPIController.php3
-rw-r--r--apps/files_sharing/lib/Controller/RemoteController.php3
-rw-r--r--apps/files_sharing/lib/Controller/ShareAPIController.php33
-rw-r--r--apps/files_sharing/lib/Controller/ShareController.php26
-rw-r--r--apps/files_sharing/lib/Controller/ShareesAPIController.php5
-rw-r--r--apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php15
-rw-r--r--apps/files_sharing/lib/External/Cache.php2
-rw-r--r--apps/files_sharing/lib/External/Manager.php5
-rw-r--r--apps/files_sharing/lib/External/Scanner.php2
-rw-r--r--apps/files_sharing/lib/External/Storage.php6
-rw-r--r--apps/files_sharing/lib/Helper.php7
-rw-r--r--apps/files_sharing/lib/Hooks.php5
-rw-r--r--apps/files_sharing/lib/MountProvider.php4
-rw-r--r--apps/files_sharing/lib/Scanner.php2
-rw-r--r--apps/files_sharing/lib/ShareBackend/File.php32
-rw-r--r--apps/files_sharing/lib/ShareBackend/Folder.php4
-rw-r--r--apps/files_sharing/lib/SharedMount.php21
-rw-r--r--apps/files_sharing/lib/SharedStorage.php29
-rw-r--r--apps/files_sharing/lib/Updater.php9
-rw-r--r--apps/files_sharing/lib/ViewOnly.php2
22 files changed, 126 insertions, 95 deletions
diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php
index e95723a7b11..6c0d5ca0781 100644
--- a/apps/files_sharing/lib/AppInfo/Application.php
+++ b/apps/files_sharing/lib/AppInfo/Application.php
@@ -120,9 +120,9 @@ class Application extends App implements IBootstrap {
public function registerEventsScripts(IEventDispatcher $dispatcher): void {
$dispatcher->addListener(ResourcesLoadAdditionalScriptsEvent::class, function (): void {
- \OCP\Util::addScript('files_sharing', 'collaboration');
+ Util::addScript('files_sharing', 'collaboration');
});
- $dispatcher->addListener(\OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent::class, function (): void {
+ $dispatcher->addListener(BeforeTemplateRenderedEvent::class, function (): void {
/**
* Always add main sharing script
*/
diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php
index 94427f7a979..ac44ae7c6cc 100644
--- a/apps/files_sharing/lib/Cache.php
+++ b/apps/files_sharing/lib/Cache.php
@@ -122,7 +122,7 @@ class Cache extends CacheJail {
parent::remove($file);
}
- public function moveFromCache(\OCP\Files\Cache\ICache $sourceCache, $sourcePath, $targetPath) {
+ public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) {
$this->rootUnchanged = false;
return parent::moveFromCache($sourceCache, $sourcePath, $targetPath);
}
diff --git a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php
index b61f9995c02..ce30cf373ec 100644
--- a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php
@@ -17,6 +17,7 @@ use OCP\AppFramework\OCS\OCSException;
use OCP\AppFramework\OCS\OCSNotFoundException;
use OCP\AppFramework\OCSController;
use OCP\AppFramework\QueryException;
+use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\IGroupManager;
@@ -105,7 +106,7 @@ class DeletedShareAPIController extends OCSController {
}
$result['path'] = $userFolder->getRelativePath($node->getPath());
- if ($node instanceof \OCP\Files\Folder) {
+ if ($node instanceof Folder) {
$result['item_type'] = 'folder';
} else {
$result['item_type'] = 'file';
diff --git a/apps/files_sharing/lib/Controller/RemoteController.php b/apps/files_sharing/lib/Controller/RemoteController.php
index fd3bdf15613..cdac35e0d9c 100644
--- a/apps/files_sharing/lib/Controller/RemoteController.php
+++ b/apps/files_sharing/lib/Controller/RemoteController.php
@@ -6,6 +6,7 @@
*/
namespace OCA\Files_Sharing\Controller;
+use OC\Files\View;
use OCA\Files_Sharing\External\Manager;
use OCA\Files_Sharing\ResponseDefinitions;
use OCP\AppFramework\Http;
@@ -96,7 +97,7 @@ class RemoteController extends OCSController {
* @return array enriched share info with data from the filecache
*/
private static function extendShareInfo($share) {
- $view = new \OC\Files\View('/' . \OC_User::getUser() . '/files/');
+ $view = new View('/' . \OC_User::getUser() . '/files/');
$info = $view->getFileInfo($share['mountpoint']);
if ($info === false) {
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index cf835874677..4cff9987242 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -12,11 +12,13 @@ namespace OCA\Files_Sharing\Controller;
use Exception;
use OC\Files\FileInfo;
use OC\Files\Storage\Wrapper\Wrapper;
+use OCA\Circles\Api\v1\Circles;
use OCA\Files\Helper;
use OCA\Files_Sharing\Exceptions\SharingRightsException;
use OCA\Files_Sharing\External\Storage;
use OCA\Files_Sharing\ResponseDefinitions;
use OCA\Files_Sharing\SharedStorage;
+use OCA\GlobalSiteSelector\Service\SlaveService;
use OCP\App\IAppManager;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
@@ -29,6 +31,7 @@ use OCP\AppFramework\OCS\OCSNotFoundException;
use OCP\AppFramework\OCSController;
use OCP\AppFramework\QueryException;
use OCP\Constants;
+use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\InvalidPathException;
use OCP\Files\IRootFolder;
@@ -410,7 +413,7 @@ class ShareAPIController extends OCSController {
}
try {
- $slaveService = Server::get(\OCA\GlobalSiteSelector\Service\SlaveService::class);
+ $slaveService = Server::get(SlaveService::class);
} catch (\Throwable $e) {
$this->logger->error(
$e->getMessage(),
@@ -619,7 +622,7 @@ class ShareAPIController extends OCSController {
$permissions |= Constants::PERMISSION_READ;
}
- if ($node instanceof \OCP\Files\File) {
+ if ($node instanceof File) {
// Single file shares should never have delete or create permissions
$permissions &= ~Constants::PERMISSION_DELETE;
$permissions &= ~Constants::PERMISSION_CREATE;
@@ -695,7 +698,7 @@ class ShareAPIController extends OCSController {
}
// Public upload can only be set for folders
- if ($node instanceof \OCP\Files\File) {
+ if ($node instanceof File) {
throw new OCSNotFoundException($this->l->t('Public upload is only possible for publicly shared folders'));
}
@@ -766,7 +769,7 @@ class ShareAPIController extends OCSController {
throw new OCSNotFoundException($this->l->t('You cannot share to a Team if the app is not enabled'));
}
- $circle = \OCA\Circles\Api\v1\Circles::detailsCircle($shareWith);
+ $circle = Circles::detailsCircle($shareWith);
// Valid team is required to share
if ($circle === null) {
@@ -864,7 +867,7 @@ class ShareAPIController extends OCSController {
* @throws NotFoundException
*/
private function getSharesInDir(Node $folder): array {
- if (!($folder instanceof \OCP\Files\Folder)) {
+ if (!($folder instanceof Folder)) {
throw new OCSBadRequestException($this->l->t('Not a directory'));
}
@@ -1066,7 +1069,7 @@ class ShareAPIController extends OCSController {
try {
$node = $userFolder->get($path);
$this->lock($node);
- } catch (\OCP\Files\NotFoundException $e) {
+ } catch (NotFoundException $e) {
throw new OCSNotFoundException($this->l->t('Wrong path, file/folder does not exist'));
} catch (LockedException $e) {
throw new OCSNotFoundException($this->l->t('Could not lock path'));
@@ -1287,7 +1290,7 @@ class ShareAPIController extends OCSController {
throw new OCSForbiddenException($this->l->t('Public upload disabled by the administrator'));
}
- if (!($share->getNode() instanceof \OCP\Files\Folder)) {
+ if (!($share->getNode() instanceof Folder)) {
throw new OCSBadRequestException($this->l->t('Public upload is only possible for publicly shared folders'));
}
@@ -1458,7 +1461,7 @@ class ShareAPIController extends OCSController {
*
* @suppress PhanUndeclaredClassMethod
*/
- protected function canAccessShare(\OCP\Share\IShare $share, bool $checkGroups = true): bool {
+ protected function canAccessShare(IShare $share, bool $checkGroups = true): bool {
// A file with permissions 0 can't be accessed by us. So Don't show it
if ($share->getPermissions() === 0) {
return false;
@@ -1531,7 +1534,7 @@ class ShareAPIController extends OCSController {
* @param \OCP\Share\IShare $share the share to check
* @return boolean
*/
- protected function canEditShare(\OCP\Share\IShare $share): bool {
+ protected function canEditShare(IShare $share): bool {
// A file with permissions 0 can't be accessed by us. So Don't show it
if ($share->getPermissions() === 0) {
return false;
@@ -1558,7 +1561,7 @@ class ShareAPIController extends OCSController {
* @param \OCP\Share\IShare $share the share to check
* @return boolean
*/
- protected function canDeleteShare(\OCP\Share\IShare $share): bool {
+ protected function canDeleteShare(IShare $share): bool {
// A file with permissions 0 can't be accessed by us. So Don't show it
if ($share->getPermissions() === 0) {
return false;
@@ -1595,7 +1598,7 @@ class ShareAPIController extends OCSController {
*
* @suppress PhanUndeclaredClassMethod
*/
- protected function canDeleteShareFromSelf(\OCP\Share\IShare $share): bool {
+ protected function canDeleteShareFromSelf(IShare $share): bool {
if ($share->getShareType() !== IShare::TYPE_GROUP &&
$share->getShareType() !== IShare::TYPE_ROOM &&
$share->getShareType() !== IShare::TYPE_DECK &&
@@ -1746,7 +1749,7 @@ class ShareAPIController extends OCSController {
* @param \OCP\Files\Node $node
* @throws LockedException
*/
- private function lock(\OCP\Files\Node $node) {
+ private function lock(Node $node) {
$node->lock(ILockingProvider::LOCK_SHARED);
$this->lockedNode = $node;
}
@@ -1923,7 +1926,7 @@ class ShareAPIController extends OCSController {
return true;
}
- if ((\OCP\Constants::PERMISSION_SHARE & $share->getPermissions()) === 0) {
+ if ((Constants::PERMISSION_SHARE & $share->getPermissions()) === 0) {
return false;
}
@@ -1946,7 +1949,7 @@ class ShareAPIController extends OCSController {
$sharedWith = substr($share->getSharedWith(), $shareWithStart, $shareWithLength);
}
try {
- $member = \OCA\Circles\Api\v1\Circles::getMember($sharedWith, $userId, 1);
+ $member = Circles::getMember($sharedWith, $userId, 1);
if ($member->getLevel() >= 4) {
return true;
}
@@ -2065,7 +2068,7 @@ class ShareAPIController extends OCSController {
} else {
throw new \RuntimeException('Should not happen, instanceOfStorage but not a wrapper');
}
- /** @var \OCA\Files_Sharing\SharedStorage $storage */
+ /** @var SharedStorage $storage */
$inheritedAttributes = $storage->getShare()->getAttributes();
if ($inheritedAttributes !== null && $inheritedAttributes->getAttribute('permissions', 'download') === false) {
$share->setHideDownload(true);
diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php
index e2b607f8eb2..5b2a2af4992 100644
--- a/apps/files_sharing/lib/Controller/ShareController.php
+++ b/apps/files_sharing/lib/Controller/ShareController.php
@@ -17,13 +17,17 @@ use OCP\AppFramework\AuthPublicShareController;
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
use OCP\AppFramework\Http\Attribute\OpenAPI;
use OCP\AppFramework\Http\Attribute\PublicPage;
+use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\NotFoundResponse;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\TemplateResponse;
+use OCP\Constants;
use OCP\Defaults;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
+use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\IConfig;
use OCP\IL10N;
@@ -46,7 +50,7 @@ use OCP\Share\IShare;
*/
#[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
class ShareController extends AuthPublicShareController {
- protected ?Share\IShare $share = null;
+ protected ?IShare $share = null;
public const SHARE_ACCESS = 'access';
public const SHARE_AUTH = 'auth';
@@ -217,7 +221,7 @@ class ShareController extends AuthPublicShareController {
$itemType = $itemSource = $uidOwner = '';
$token = $share;
$exception = null;
- if ($share instanceof \OCP\Share\IShare) {
+ if ($share instanceof IShare) {
try {
$token = $share->getToken();
$uidOwner = $share->getSharedBy();
@@ -261,7 +265,7 @@ class ShareController extends AuthPublicShareController {
* @param Share\IShare $share
* @return bool
*/
- private function validateShare(\OCP\Share\IShare $share) {
+ private function validateShare(IShare $share) {
// If the owner is disabled no access to the link is granted
$owner = $this->userManager->get($share->getShareOwner());
if ($owner === null || !$owner->isEnabled()) {
@@ -314,7 +318,7 @@ class ShareController extends AuthPublicShareController {
// We can't get the path of a file share
try {
- if ($shareNode instanceof \OCP\Files\File && $path !== '') {
+ if ($shareNode instanceof File && $path !== '') {
$this->emitAccessShareHook($share, 404, 'Share not found');
$this->emitShareAccessEvent($share, self::SHARE_ACCESS, 404, 'Share not found');
throw new NotFoundException($this->l10n->t('This share does not exist or is no longer available'));
@@ -349,8 +353,8 @@ class ShareController extends AuthPublicShareController {
$share = $this->shareManager->getShareByToken($token);
- if (!($share->getPermissions() & \OCP\Constants::PERMISSION_READ)) {
- return new \OCP\AppFramework\Http\DataResponse('Share has no read permission');
+ if (!($share->getPermissions() & Constants::PERMISSION_READ)) {
+ return new DataResponse('Share has no read permission');
}
if (!$this->validateShare($share)) {
@@ -358,7 +362,7 @@ class ShareController extends AuthPublicShareController {
}
// Single file share
- if ($share->getNode() instanceof \OCP\Files\File) {
+ if ($share->getNode() instanceof File) {
// Single file download
$this->singleFileDownloaded($share, $share->getNode());
}
@@ -378,7 +382,7 @@ class ShareController extends AuthPublicShareController {
}
}
- if ($node instanceof \OCP\Files\Folder) {
+ if ($node instanceof Folder) {
if ($files === null || $files === '') {
// The folder is downloaded
$this->singleFileDownloaded($share, $share->getNode());
@@ -415,7 +419,7 @@ class ShareController extends AuthPublicShareController {
* @param Share\IShare $share
* @throws NotFoundException when trying to download a folder of a "hide download" share
*/
- protected function singleFileDownloaded(Share\IShare $share, \OCP\Files\Node $node) {
+ protected function singleFileDownloaded(IShare $share, Node $node) {
if ($share->getHideDownload() && $node instanceof Folder) {
throw new NotFoundException('Downloading a folder');
}
@@ -435,14 +439,14 @@ class ShareController extends AuthPublicShareController {
$parameters = [$userPath];
if ($share->getShareType() === IShare::TYPE_EMAIL) {
- if ($node instanceof \OCP\Files\File) {
+ if ($node instanceof File) {
$subject = Downloads::SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED;
} else {
$subject = Downloads::SUBJECT_SHARED_FOLDER_BY_EMAIL_DOWNLOADED;
}
$parameters[] = $share->getSharedWith();
} else {
- if ($node instanceof \OCP\Files\File) {
+ if ($node instanceof File) {
$subject = Downloads::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED;
$parameters[] = $remoteAddressHash;
} else {
diff --git a/apps/files_sharing/lib/Controller/ShareesAPIController.php b/apps/files_sharing/lib/Controller/ShareesAPIController.php
index f177cb9d1ee..606a3d11de6 100644
--- a/apps/files_sharing/lib/Controller/ShareesAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareesAPIController.php
@@ -10,6 +10,7 @@ namespace OCA\Files_Sharing\Controller;
use Generator;
use OC\Collaboration\Collaborators\SearchResult;
+use OC\Share\Share;
use OCA\Files_Sharing\ResponseDefinitions;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
@@ -362,7 +363,7 @@ class ShareesAPIController extends OCSController {
protected function isRemoteSharingAllowed(string $itemType): bool {
try {
// FIXME: static foo makes unit testing unnecessarily difficult
- $backend = \OC\Share\Share::getBackend($itemType);
+ $backend = Share::getBackend($itemType);
return $backend->isShareTypeAllowed(IShare::TYPE_REMOTE);
} catch (\Exception $e) {
return false;
@@ -372,7 +373,7 @@ class ShareesAPIController extends OCSController {
protected function isRemoteGroupSharingAllowed(string $itemType): bool {
try {
// FIXME: static foo makes unit testing unnecessarily difficult
- $backend = \OC\Share\Share::getBackend($itemType);
+ $backend = Share::getBackend($itemType);
return $backend->isShareTypeAllowed(IShare::TYPE_REMOTE_GROUP);
} catch (\Exception $e) {
return false;
diff --git a/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php b/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php
index bea48f28dee..dad1f332458 100644
--- a/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php
+++ b/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php
@@ -20,6 +20,7 @@ use OCP\AppFramework\Http\Template\PublicTemplateResponse;
use OCP\AppFramework\Http\Template\SimpleMenuAction;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;
+use OCP\Constants;
use OCP\Defaults;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\File;
@@ -78,8 +79,8 @@ class DefaultPublicShareTemplateProvider implements IPublicShareTemplateProvider
if ($shareNode instanceof File) {
$view = 'public-file-share';
$this->initialState->provideInitialState('fileId', $shareNode->getId());
- } elseif (($share->getPermissions() & \OCP\Constants::PERMISSION_CREATE)
- && !($share->getPermissions() & \OCP\Constants::PERMISSION_READ)
+ } elseif (($share->getPermissions() & Constants::PERMISSION_CREATE)
+ && !($share->getPermissions() & Constants::PERMISSION_READ)
) {
// share is a folder with create but no read permissions -> file drop only
$view = 'public-file-drop';
@@ -97,10 +98,10 @@ class DefaultPublicShareTemplateProvider implements IPublicShareTemplateProvider
$this->initialState->provideInitialState('view', $view);
// Load scripts and styles for UI
- \OCP\Util::addInitScript('files', 'init');
- \OCP\Util::addInitScript(Application::APP_ID, 'init');
- \OCP\Util::addInitScript(Application::APP_ID, 'init-public');
- \OCP\Util::addScript('files', 'main');
+ Util::addInitScript('files', 'init');
+ Util::addInitScript(Application::APP_ID, 'init');
+ Util::addInitScript(Application::APP_ID, 'init-public');
+ Util::addScript('files', 'main');
// Add file-request script if needed
$attributes = $share->getAttributes();
@@ -171,7 +172,7 @@ class DefaultPublicShareTemplateProvider implements IPublicShareTemplateProvider
if ($shareNode->getMimePart() === 'image') {
// If this is a file and especially an image directly point to the image preview
$directLink = $this->urlGenerator->linkToRouteAbsolute('files_sharing.publicpreview.directLink', ['token' => $token]);
- } elseif (($share->getPermissions() & \OCP\Constants::PERMISSION_READ) && !$share->getHideDownload()) {
+ } elseif (($share->getPermissions() & Constants::PERMISSION_READ) && !$share->getHideDownload()) {
// Can read and no download restriction, so just download it
$directLink = $downloadUrl ?? $shareUrl;
}
diff --git a/apps/files_sharing/lib/External/Cache.php b/apps/files_sharing/lib/External/Cache.php
index 7fad71b9084..deef16c0f1a 100644
--- a/apps/files_sharing/lib/External/Cache.php
+++ b/apps/files_sharing/lib/External/Cache.php
@@ -16,7 +16,7 @@ class Cache extends \OC\Files\Cache\Cache {
private $storage;
/**
- * @param \OCA\Files_Sharing\External\Storage $storage
+ * @param Storage $storage
* @param ICloudId $cloudId
*/
public function __construct($storage, ICloudId $cloudId) {
diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php
index 86c9ae830e4..58e24a96338 100644
--- a/apps/files_sharing/lib/External/Manager.php
+++ b/apps/files_sharing/lib/External/Manager.php
@@ -16,6 +16,7 @@ use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\ICloudFederationFactory;
use OCP\Federation\ICloudFederationProviderManager;
use OCP\Files;
+use OCP\Files\Events\InvalidateMountCacheEvent;
use OCP\Files\NotFoundException;
use OCP\Files\Storage\IStorageFactory;
use OCP\Http\Client\IClientService;
@@ -347,7 +348,7 @@ class Manager {
$this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'accept');
$event = new FederatedShareAddedEvent($share['remote']);
$this->eventDispatcher->dispatchTyped($event);
- $this->eventDispatcher->dispatchTyped(new Files\Events\InvalidateMountCacheEvent($this->userManager->get($this->uid)));
+ $this->eventDispatcher->dispatchTyped(new InvalidateMountCacheEvent($this->userManager->get($this->uid)));
$result = true;
}
}
@@ -567,7 +568,7 @@ class Manager {
');
$result = (bool)$query->execute([$target, $targetHash, $sourceHash, $this->uid]);
- $this->eventDispatcher->dispatchTyped(new Files\Events\InvalidateMountCacheEvent($this->userManager->get($this->uid)));
+ $this->eventDispatcher->dispatchTyped(new InvalidateMountCacheEvent($this->userManager->get($this->uid)));
return $result;
}
diff --git a/apps/files_sharing/lib/External/Scanner.php b/apps/files_sharing/lib/External/Scanner.php
index 63757d44f46..d3b54e0f0f6 100644
--- a/apps/files_sharing/lib/External/Scanner.php
+++ b/apps/files_sharing/lib/External/Scanner.php
@@ -12,7 +12,7 @@ use OCP\Files\StorageInvalidException;
use OCP\Files\StorageNotAvailableException;
class Scanner extends \OC\Files\Cache\Scanner {
- /** @var \OCA\Files_Sharing\External\Storage */
+ /** @var Storage */
protected $storage;
public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) {
diff --git a/apps/files_sharing/lib/External/Storage.php b/apps/files_sharing/lib/External/Storage.php
index 39e907cffff..629e5c2c268 100644
--- a/apps/files_sharing/lib/External/Storage.php
+++ b/apps/files_sharing/lib/External/Storage.php
@@ -13,6 +13,7 @@ use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use OC\Files\Storage\DAV;
use OC\ForbiddenException;
+use OC\Share\Share;
use OCA\Files_Sharing\External\Manager as ExternalShareManager;
use OCA\Files_Sharing\ISharedStorage;
use OCP\AppFramework\Http;
@@ -35,6 +36,7 @@ use OCP\OCM\Exceptions\OCMArgumentException;
use OCP\OCM\Exceptions\OCMProviderException;
use OCP\OCM\IOCMDiscoveryService;
use OCP\Server;
+use OCP\Util;
use Psr\Log\LoggerInterface;
class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage, IReliableEtagStorage {
@@ -144,7 +146,7 @@ class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage,
if (!isset($this->scanner)) {
$this->scanner = new Scanner($storage);
}
- /** @var \OCA\Files_Sharing\External\Scanner */
+ /** @var Scanner */
return $this->scanner;
}
@@ -328,7 +330,7 @@ class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage,
}
public function isSharable(string $path): bool {
- if (\OCP\Util::isSharingDisabledForUser() || !\OC\Share\Share::isResharingAllowed()) {
+ if (Util::isSharingDisabledForUser() || !Share::isResharingAllowed()) {
return false;
}
return (bool)($this->getPermissions($path) & Constants::PERMISSION_SHARE);
diff --git a/apps/files_sharing/lib/Helper.php b/apps/files_sharing/lib/Helper.php
index 8efcb7cae7b..538e37fa88e 100644
--- a/apps/files_sharing/lib/Helper.php
+++ b/apps/files_sharing/lib/Helper.php
@@ -9,13 +9,14 @@ namespace OCA\Files_Sharing;
use OC\Files\Filesystem;
use OC\Files\View;
use OCA\Files_Sharing\AppInfo\Application;
+use OCP\Util;
class Helper {
public static function registerHooks() {
- \OCP\Util::connectHook('OC_Filesystem', 'post_rename', '\OCA\Files_Sharing\Updater', 'renameHook');
- \OCP\Util::connectHook('OC_Filesystem', 'post_delete', '\OCA\Files_Sharing\Hooks', 'unshareChildren');
+ Util::connectHook('OC_Filesystem', 'post_rename', '\OCA\Files_Sharing\Updater', 'renameHook');
+ Util::connectHook('OC_Filesystem', 'post_delete', '\OCA\Files_Sharing\Hooks', 'unshareChildren');
- \OCP\Util::connectHook('OC_User', 'post_deleteUser', '\OCA\Files_Sharing\Hooks', 'deleteUser');
+ Util::connectHook('OC_User', 'post_deleteUser', '\OCA\Files_Sharing\Hooks', 'deleteUser');
}
/**
diff --git a/apps/files_sharing/lib/Hooks.php b/apps/files_sharing/lib/Hooks.php
index a6ab3f16f29..6a297f1e875 100644
--- a/apps/files_sharing/lib/Hooks.php
+++ b/apps/files_sharing/lib/Hooks.php
@@ -7,6 +7,7 @@
namespace OCA\Files_Sharing;
use OC\Files\Filesystem;
+use OC\Files\View;
class Hooks {
public static function deleteUser($params) {
@@ -17,10 +18,10 @@ class Hooks {
public static function unshareChildren($params) {
$path = Filesystem::getView()->getAbsolutePath($params['path']);
- $view = new \OC\Files\View('/');
+ $view = new View('/');
// find share mount points within $path and unmount them
- $mountManager = \OC\Files\Filesystem::getMountManager();
+ $mountManager = Filesystem::getMountManager();
$mountedShares = $mountManager->findIn($path);
foreach ($mountedShares as $mount) {
if ($mount->getStorage()->instanceOfStorage(ISharedStorage::class)) {
diff --git a/apps/files_sharing/lib/MountProvider.php b/apps/files_sharing/lib/MountProvider.php
index 5313f40ff6b..06e3ed1e147 100644
--- a/apps/files_sharing/lib/MountProvider.php
+++ b/apps/files_sharing/lib/MountProvider.php
@@ -51,7 +51,7 @@ class MountProvider implements IMountProvider {
// filter out excluded shares and group shares that includes self
- $shares = array_filter($shares, function (\OCP\Share\IShare $share) use ($user) {
+ $shares = array_filter($shares, function (IShare $share) use ($user) {
return $share->getPermissions() > 0 && $share->getShareOwner() !== $user->getUID();
});
@@ -165,7 +165,7 @@ class MountProvider implements IMountProvider {
* @param \OCP\IUser $user user
* @return array Tuple of [superShare, groupedShares]
*/
- private function buildSuperShares(array $allShares, \OCP\IUser $user) {
+ private function buildSuperShares(array $allShares, IUser $user) {
$result = [];
$groupedShares = $this->groupShares($allShares);
diff --git a/apps/files_sharing/lib/Scanner.php b/apps/files_sharing/lib/Scanner.php
index 1ff1046bce7..ec0959088ce 100644
--- a/apps/files_sharing/lib/Scanner.php
+++ b/apps/files_sharing/lib/Scanner.php
@@ -14,7 +14,7 @@ use OC\Files\ObjectStore\ObjectStoreScanner;
*/
class Scanner extends \OC\Files\Cache\Scanner {
/**
- * @var \OCA\Files_Sharing\SharedStorage $storage
+ * @var SharedStorage $storage
*/
protected $storage;
diff --git a/apps/files_sharing/lib/ShareBackend/File.php b/apps/files_sharing/lib/ShareBackend/File.php
index 4d93232b638..0b7ec58aef3 100644
--- a/apps/files_sharing/lib/ShareBackend/File.php
+++ b/apps/files_sharing/lib/ShareBackend/File.php
@@ -6,11 +6,17 @@
*/
namespace OCA\Files_Sharing\ShareBackend;
+use OC\Files\Filesystem;
+use OC\Files\View;
use OCA\FederatedFileSharing\FederatedShareProvider;
+use OCA\Files_Sharing\Helper;
+use OCP\Files\NotFoundException;
+use OCP\Server;
use OCP\Share\IShare;
+use OCP\Share_Backend_File_Dependent;
use Psr\Log\LoggerInterface;
-class File implements \OCP\Share_Backend_File_Dependent {
+class File implements Share_Backend_File_Dependent {
public const FORMAT_SHARED_STORAGE = 0;
public const FORMAT_GET_FOLDER_CONTENTS = 1;
public const FORMAT_FILE_APP_ROOT = 2;
@@ -34,13 +40,13 @@ class File implements \OCP\Share_Backend_File_Dependent {
public function isValidSource($itemSource, $uidOwner) {
try {
- $path = \OC\Files\Filesystem::getPath($itemSource);
+ $path = Filesystem::getPath($itemSource);
// FIXME: attributes should not be set here,
// keeping this pattern for now to avoid unexpected
// regressions
- $this->path = \OC\Files\Filesystem::normalizePath(basename($path));
+ $this->path = Filesystem::normalizePath(basename($path));
return true;
- } catch (\OCP\Files\NotFoundException $e) {
+ } catch (NotFoundException $e) {
return false;
}
}
@@ -52,9 +58,9 @@ class File implements \OCP\Share_Backend_File_Dependent {
return $path;
} else {
try {
- $path = \OC\Files\Filesystem::getPath($itemSource);
+ $path = Filesystem::getPath($itemSource);
return $path;
- } catch (\OCP\Files\NotFoundException $e) {
+ } catch (NotFoundException $e) {
return false;
}
}
@@ -68,11 +74,11 @@ class File implements \OCP\Share_Backend_File_Dependent {
* @return string
*/
public function generateTarget($itemSource, $shareWith) {
- $shareFolder = \OCA\Files_Sharing\Helper::getShareFolder();
- $target = \OC\Files\Filesystem::normalizePath($shareFolder . '/' . basename($itemSource));
+ $shareFolder = Helper::getShareFolder();
+ $target = Filesystem::normalizePath($shareFolder . '/' . basename($itemSource));
- \OC\Files\Filesystem::initMountPoints($shareWith);
- $view = new \OC\Files\View('/' . $shareWith . '/files');
+ Filesystem::initMountPoints($shareWith);
+ $view = new View('/' . $shareWith . '/files');
if (!$view->is_dir($shareFolder)) {
$dir = '';
@@ -85,7 +91,7 @@ class File implements \OCP\Share_Backend_File_Dependent {
}
}
- return \OCA\Files_Sharing\Helper::generateUniqueTarget($target, $view);
+ return Helper::generateUniqueTarget($target, $view);
}
public function formatItems($items, $format, $parameters = null) {
@@ -116,7 +122,7 @@ class File implements \OCP\Share_Backend_File_Dependent {
$file['uid_owner'] = $item['uid_owner'];
$file['displayname_owner'] = $item['displayname_owner'];
- $storage = \OC\Files\Filesystem::getStorage('/');
+ $storage = Filesystem::getStorage('/');
$cache = $storage->getCache();
$file['size'] = $item['size'];
$files[] = $file;
@@ -199,7 +205,7 @@ class File implements \OCP\Share_Backend_File_Dependent {
if (isset($fileOwner)) {
$source['fileOwner'] = $fileOwner;
} else {
- \OCP\Server::get(LoggerInterface::class)->error('No owner found for reshare', ['app' => 'files_sharing']);
+ Server::get(LoggerInterface::class)->error('No owner found for reshare', ['app' => 'files_sharing']);
}
return $source;
diff --git a/apps/files_sharing/lib/ShareBackend/Folder.php b/apps/files_sharing/lib/ShareBackend/Folder.php
index f64d44faefc..fefdd7f667c 100644
--- a/apps/files_sharing/lib/ShareBackend/Folder.php
+++ b/apps/files_sharing/lib/ShareBackend/Folder.php
@@ -6,7 +6,9 @@
*/
namespace OCA\Files_Sharing\ShareBackend;
-class Folder extends File implements \OCP\Share_Backend_Collection {
+use OCP\Share_Backend_Collection;
+
+class Folder extends File implements Share_Backend_Collection {
public function getChildren($itemSource) {
$children = [];
$parents = [$itemSource];
diff --git a/apps/files_sharing/lib/SharedMount.php b/apps/files_sharing/lib/SharedMount.php
index ddd6af3845d..420de6889bf 100644
--- a/apps/files_sharing/lib/SharedMount.php
+++ b/apps/files_sharing/lib/SharedMount.php
@@ -11,13 +11,16 @@ use OC\Files\Filesystem;
use OC\Files\Mount\MountPoint;
use OC\Files\Mount\MoveableMount;
use OC\Files\View;
+use OCA\Files_Sharing\Exceptions\BrokenPath;
use OCP\Cache\CappedMemoryCache;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Events\InvalidateMountCacheEvent;
use OCP\Files\Storage\IStorageFactory;
use OCP\ICache;
use OCP\IUser;
+use OCP\Server;
use OCP\Share\Events\VerifyMountPointEvent;
+use OCP\Share\IShare;
use Psr\Log\LoggerInterface;
/**
@@ -25,7 +28,7 @@ use Psr\Log\LoggerInterface;
*/
class SharedMount extends MountPoint implements MoveableMount, ISharedMountPoint {
/**
- * @var \OCA\Files_Sharing\SharedStorage $storage
+ * @var SharedStorage $storage
*/
protected $storage = null;
@@ -79,7 +82,7 @@ class SharedMount extends MountPoint implements MoveableMount, ISharedMountPoint
* @return string
*/
private function verifyMountPoint(
- \OCP\Share\IShare $share,
+ IShare $share,
array $mountpoints,
CappedMemoryCache $folderExistCache,
) {
@@ -108,7 +111,7 @@ class SharedMount extends MountPoint implements MoveableMount, ISharedMountPoint
}
$newMountPoint = $this->generateUniqueTarget(
- \OC\Files\Filesystem::normalizePath($parent . '/' . $mountPoint),
+ Filesystem::normalizePath($parent . '/' . $mountPoint),
$this->recipientView,
$mountpoints
);
@@ -169,7 +172,7 @@ class SharedMount extends MountPoint implements MoveableMount, ISharedMountPoint
*
* @param string $path the absolute path
* @return string e.g. turns '/admin/files/test.txt' into '/test.txt'
- * @throws \OCA\Files_Sharing\Exceptions\BrokenPath
+ * @throws BrokenPath
*/
protected function stripUserFilesPath($path) {
$trimmed = ltrim($path, '/');
@@ -177,8 +180,8 @@ class SharedMount extends MountPoint implements MoveableMount, ISharedMountPoint
// it is not a file relative to data/user/files
if (count($split) < 3 || $split[1] !== 'files') {
- \OCP\Server::get(LoggerInterface::class)->error('Can not strip userid and "files/" from path: ' . $path, ['app' => 'files_sharing']);
- throw new \OCA\Files_Sharing\Exceptions\BrokenPath('Path does not start with /user/files', 10);
+ Server::get(LoggerInterface::class)->error('Can not strip userid and "files/" from path: ' . $path, ['app' => 'files_sharing']);
+ throw new BrokenPath('Path does not start with /user/files', 10);
}
// skip 'user' and 'files'
@@ -205,7 +208,7 @@ class SharedMount extends MountPoint implements MoveableMount, ISharedMountPoint
$this->setMountPoint($target);
$this->storage->setMountPoint($relTargetPath);
} catch (\Exception $e) {
- \OCP\Server::get(LoggerInterface::class)->error(
+ Server::get(LoggerInterface::class)->error(
'Could not rename mount point for shared folder "' . $this->getMountPoint() . '" to "' . $target . '"',
[
'app' => 'files_sharing',
@@ -223,8 +226,8 @@ class SharedMount extends MountPoint implements MoveableMount, ISharedMountPoint
* @return bool
*/
public function removeMount() {
- $mountManager = \OC\Files\Filesystem::getMountManager();
- /** @var \OCA\Files_Sharing\SharedStorage $storage */
+ $mountManager = Filesystem::getMountManager();
+ /** @var SharedStorage $storage */
$storage = $this->getStorage();
$result = $storage->unshareStorage();
$mountManager->removeMount($this->mountPoint);
diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php
index 63c5fa9017d..630eae0634e 100644
--- a/apps/files_sharing/lib/SharedStorage.php
+++ b/apps/files_sharing/lib/SharedStorage.php
@@ -14,8 +14,10 @@ use OC\Files\Storage\Common;
use OC\Files\Storage\FailedStorage;
use OC\Files\Storage\Home;
use OC\Files\Storage\Storage;
+use OC\Files\Storage\Wrapper\Jail;
use OC\Files\Storage\Wrapper\PermissionsMask;
use OC\Files\Storage\Wrapper\Wrapper;
+use OC\Share\Share;
use OC\User\NoUserException;
use OCA\Files_External\Config\ConfigAdapter;
use OCA\Files_Sharing\ISharedStorage as LegacyISharedStorage;
@@ -35,12 +37,13 @@ use OCP\Files\Storage\ISharedStorage;
use OCP\Files\Storage\IStorage;
use OCP\Lock\ILockingProvider;
use OCP\Share\IShare;
+use OCP\Util;
use Psr\Log\LoggerInterface;
/**
* Convert target path to source path and pass the function call to the correct storage provider
*/
-class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements LegacyISharedStorage, ISharedStorage, IDisableEncryptionStorage {
+class SharedStorage extends Jail implements LegacyISharedStorage, ISharedStorage, IDisableEncryptionStorage {
/** @var \OCP\Share\IShare */
private $superShare;
@@ -242,18 +245,18 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements LegacyISha
// part files and the mount point always have delete permissions
if ($path === '' || pathinfo($path, PATHINFO_EXTENSION) === 'part') {
- $permissions |= \OCP\Constants::PERMISSION_DELETE;
+ $permissions |= Constants::PERMISSION_DELETE;
}
if ($this->sharingDisabledForUser) {
- $permissions &= ~\OCP\Constants::PERMISSION_SHARE;
+ $permissions &= ~Constants::PERMISSION_SHARE;
}
return $permissions;
}
public function isCreatable(string $path): bool {
- return (bool)($this->getPermissions($path) & \OCP\Constants::PERMISSION_CREATE);
+ return (bool)($this->getPermissions($path) & Constants::PERMISSION_CREATE);
}
public function isReadable(string $path): bool {
@@ -270,18 +273,18 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements LegacyISha
}
public function isUpdatable(string $path): bool {
- return (bool)($this->getPermissions($path) & \OCP\Constants::PERMISSION_UPDATE);
+ return (bool)($this->getPermissions($path) & Constants::PERMISSION_UPDATE);
}
public function isDeletable(string $path): bool {
- return (bool)($this->getPermissions($path) & \OCP\Constants::PERMISSION_DELETE);
+ return (bool)($this->getPermissions($path) & Constants::PERMISSION_DELETE);
}
public function isSharable(string $path): bool {
- if (\OCP\Util::isSharingDisabledForUser() || !\OC\Share\Share::isResharingAllowed()) {
+ if (Util::isSharingDisabledForUser() || !Share::isResharingAllowed()) {
return false;
}
- return (bool)($this->getPermissions($path) & \OCP\Constants::PERMISSION_SHARE);
+ return (bool)($this->getPermissions($path) & Constants::PERMISSION_SHARE);
}
public function fopen(string $path, string $mode) {
@@ -332,7 +335,7 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements LegacyISha
'source' => $source,
'mode' => $mode,
];
- \OCP\Util::emitHook('\OC\Files\Storage\Shared', 'fopen', $info);
+ Util::emitHook('\OC\Files\Storage\Shared', 'fopen', $info);
return $this->nonMaskedStorage->fopen($this->getUnjailedPath($path), $mode);
}
@@ -406,7 +409,7 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements LegacyISha
return new FailedCache();
}
- $this->cache = new \OCA\Files_Sharing\Cache(
+ $this->cache = new Cache(
$storage,
$sourceRoot,
\OC::$server->get(CacheDependencies::class),
@@ -419,7 +422,7 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements LegacyISha
if (!$storage) {
$storage = $this;
}
- return new \OCA\Files_Sharing\Scanner($storage);
+ return new Scanner($storage);
}
public function getOwner(string $path): string|false {
@@ -529,7 +532,7 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements LegacyISha
'target' => $this->getMountPoint() . '/' . $path,
'source' => $this->getUnjailedPath($path),
];
- \OCP\Util::emitHook('\OC\Files\Storage\Shared', 'file_get_contents', $info);
+ Util::emitHook('\OC\Files\Storage\Shared', 'file_get_contents', $info);
return parent::file_get_contents($path);
}
@@ -538,7 +541,7 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements LegacyISha
'target' => $this->getMountPoint() . '/' . $path,
'source' => $this->getUnjailedPath($path),
];
- \OCP\Util::emitHook('\OC\Files\Storage\Shared', 'file_put_contents', $info);
+ Util::emitHook('\OC\Files\Storage\Shared', 'file_put_contents', $info);
return parent::file_put_contents($path, $data);
}
diff --git a/apps/files_sharing/lib/Updater.php b/apps/files_sharing/lib/Updater.php
index 3a3813287b9..82075fb9ba5 100644
--- a/apps/files_sharing/lib/Updater.php
+++ b/apps/files_sharing/lib/Updater.php
@@ -7,6 +7,7 @@
namespace OCA\Files_Sharing;
use OC\Files\Cache\FileAccess;
+use OC\Files\Filesystem;
use OC\Files\Mount\MountPoint;
use OCP\Constants;
use OCP\Files\Folder;
@@ -96,7 +97,7 @@ class Updater {
continue;
}
- if ($dstMount instanceof \OCA\Files_Sharing\SharedMount) {
+ if ($dstMount instanceof SharedMount) {
if (!($dstMount->getShare()->getPermissions() & Constants::PERMISSION_SHARE)) {
$shareManager->deleteShare($share);
continue;
@@ -121,10 +122,10 @@ class Updater {
* @param string $newPath new path relative to data/user/files
*/
private static function renameChildren($oldPath, $newPath) {
- $absNewPath = \OC\Files\Filesystem::normalizePath('/' . \OC_User::getUser() . '/files/' . $newPath);
- $absOldPath = \OC\Files\Filesystem::normalizePath('/' . \OC_User::getUser() . '/files/' . $oldPath);
+ $absNewPath = Filesystem::normalizePath('/' . \OC_User::getUser() . '/files/' . $newPath);
+ $absOldPath = Filesystem::normalizePath('/' . \OC_User::getUser() . '/files/' . $oldPath);
- $mountManager = \OC\Files\Filesystem::getMountManager();
+ $mountManager = Filesystem::getMountManager();
$mountedShares = $mountManager->findIn('/' . \OC_User::getUser() . '/files/' . $oldPath);
foreach ($mountedShares as $mount) {
/** @var MountPoint $mount */
diff --git a/apps/files_sharing/lib/ViewOnly.php b/apps/files_sharing/lib/ViewOnly.php
index 7b52d79f4d0..2a837b627af 100644
--- a/apps/files_sharing/lib/ViewOnly.php
+++ b/apps/files_sharing/lib/ViewOnly.php
@@ -88,7 +88,7 @@ class ViewOnly {
}
// Extract extra permissions
- /** @var \OCA\Files_Sharing\SharedStorage $storage */
+ /** @var SharedStorage $storage */
$share = $storage->getShare();
$canDownload = true;