Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a0c0826
refactor(files_sharing): apply DRY for user and node ID in MountProvider
salmart-dev Oct 30, 2025
784faa4
fix(files_sharing): remove unnecessary array_values in MountProvider
salmart-dev Oct 30, 2025
05c2491
refactor(files_sharing): reduce complexity in MountProvider::buildSup…
salmart-dev Oct 30, 2025
f66d375
refactor(files_sharing): apply DRY in MountProvider
salmart-dev Oct 31, 2025
ba2df3f
refactor(files_sharing): extract getMountsForUser logic
salmart-dev Nov 3, 2025
0e9c390
refactor(files_sharing): avoid magic numbers in external/MountProvider
salmart-dev Nov 3, 2025
85d8df5
chore: fix psalm baseline
salmart-dev Nov 20, 2025
9e911c7
fix: add INodeByPath to Directory [wip]
salmart-dev Aug 15, 2025
a66bf50
fixup! fix: add INodeByPath to Directory [wip]
salmart-dev Aug 15, 2025
447b39e
fixup! fix: add INodeByPath to Directory [wip]
salmart-dev Aug 19, 2025
88d0df8
fixup! fix: add INodeByPath to Directory [wip]
salmart-dev Aug 20, 2025
778f87a
fixup! fix: add INodeByPath to Directory [wip]
salmart-dev Aug 20, 2025
18d9d06
fixup! fixup! fix: add INodeByPath to Directory [wip]
salmart-dev Aug 21, 2025
c92bfe4
fixup! fix: add INodeByPath to Directory [wip]
salmart-dev Sep 10, 2025
a1be9cd
fix: restore files_accesscontrol functionality within getNodeForPath
salmart-dev Nov 11, 2025
831e780
fix: do not fetch child-mount information when recursing upwards [ski…
salmart-dev Nov 14, 2025
05768e2
docs: update comments
salmart-dev Nov 24, 2025
b697547
refactor: simplify code
salmart-dev Sep 4, 2025
0d48c8c
feat: add IPartialMountProvider to support authoritative mounts
salmart-dev Sep 4, 2025
7761111
feat: add parent_id column in oc_mounts
salmart-dev Sep 9, 2025
2477163
feat: implement support for authoritative mount providers [skip ci]
salmart-dev Sep 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 63 additions & 2 deletions apps/dav/lib/Connector/Sabre/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@
use Sabre\DAV\Exception\ServiceUnavailable;
use Sabre\DAV\IFile;
use Sabre\DAV\INode;

class Directory extends Node implements \Sabre\DAV\ICollection, \Sabre\DAV\IQuota, \Sabre\DAV\IMoveTarget, \Sabre\DAV\ICopyTarget {
use Sabre\DAV\INodeByPath;

class Directory extends Node implements
\Sabre\DAV\ICollection,
\Sabre\DAV\IQuota,
\Sabre\DAV\IMoveTarget,
\Sabre\DAV\ICopyTarget,
INodeByPath {
/**
* Cached directory content
* @var FileInfo[]
Expand Down Expand Up @@ -490,4 +496,59 @@ public function copyInto($targetName, $sourcePath, INode $sourceNode) {
public function getNode(): Folder {
return $this->node;
}

public function getNodeForPath($path) {
return $this->getNodeForPathInternal($path);
}

private function getNodeForPathInternal($path, bool $includeChildren = true) {
$nodeIsRoot = $this->path === '/';
$path = ltrim($path, '/');
$fullPath = $nodeIsRoot ? $this->path . $path : $this->path . '/' . $path;

try {
[$destinationDir, $destinationName] = \Sabre\Uri\split($fullPath);
$this->fileView->verifyPath($destinationDir, $destinationName, true);
$info = $this->fileView->getFileInfo($fullPath, $includeChildren);
} catch (StorageNotAvailableException $e) {
throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage(), 0, $e);
} catch (InvalidPathException $ex) {
throw new InvalidPath($ex->getMessage(), false, $ex);
} catch (ForbiddenException $e) {
throw new \Sabre\DAV\Exception\Forbidden($e->getMessage(), $e->getCode(), $e);
}

if (!$info) {
throw new \Sabre\DAV\Exception\NotFound('File with name ' . $fullPath
. ' could not be located');
}

if (!$info->isReadable()) {
if (Server::get(IAppManager::class)->isEnabledForAnyone('files_accesscontrol')) {
throw new Forbidden('No read permissions. This might be caused by files_accesscontrol, check your configured rules');
}

throw new Forbidden('No read permissions');
}

if ($info->getMimeType() === FileInfo::MIMETYPE_FOLDER) {
$node = new \OCA\DAV\Connector\Sabre\Directory($this->fileView, $info, $this->tree, $this->shareManager);
} else {
// In case reading a directory was allowed but it turns out the node was a not a directory, reject it now.
if (!$this->info->isReadable()) {
throw new NotFound();
}

$node = new File($this->fileView, $info, $this->shareManager);
}
$this->tree?->cacheNode($node);

if ($destinationDir !== '') {
// recurse upwards until the root (for backwards-compatibility)
// no need to get child information
$this->getNodeForPathInternal($destinationDir, false);
}

return $node;
}
}
2 changes: 1 addition & 1 deletion apps/dav/lib/Connector/Sabre/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager;

abstract class Node implements \Sabre\DAV\INode {
abstract class Node extends \Sabre\DAV\Node implements \Sabre\DAV\INode {
/**
* The path to the current node
*
Expand Down
3 changes: 2 additions & 1 deletion apps/files_sharing/lib/External/MountProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use OCP\IDBConnection;
use OCP\IUser;
use OCP\Server;
use OCP\Share\IShare;

class MountProvider implements IMountProvider {
public const STORAGE = '\OCA\Files_Sharing\External\Storage';
Expand Down Expand Up @@ -54,7 +55,7 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
$qb->select('remote', 'share_token', 'password', 'mountpoint', 'owner')
->from('share_external')
->where($qb->expr()->eq('user', $qb->createNamedParameter($user->getUID())))
->andWhere($qb->expr()->eq('accepted', $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT)));
->andWhere($qb->expr()->eq('accepted', $qb->createNamedParameter(IShare::STATUS_ACCEPTED, IQueryBuilder::PARAM_INT)));
$result = $qb->executeQuery();
$mounts = [];
while ($row = $result->fetchAssociative()) {
Expand Down
Loading