Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .github/workflows/files-external-smb-kerberos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:
with:
persist-credentials: false
repository: nextcloud/user_saml
ref: stable-6
path: apps/user_saml

- name: Install user_saml
Expand Down
13 changes: 12 additions & 1 deletion apps/dav/lib/Upload/ChunkingV2Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use OCP\Lock\ILockingProvider;
use Sabre\DAV\Exception\BadRequest;
use Sabre\DAV\Exception\InsufficientStorage;
use Sabre\DAV\Exception\MethodNotAllowed;
use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\Exception\PreconditionFailed;
use Sabre\DAV\ICollection;
Expand Down Expand Up @@ -67,14 +68,24 @@
* @inheritdoc
*/
public function initialize(Server $server) {
$server->on('afterMethod:MKCOL', [$this, 'afterMkcol']);
$server->on('beforeMethod:GET', $this->beforeGet(...));
$server->on('beforeMethod:PUT', [$this, 'beforePut']);
$server->on('beforeMethod:DELETE', [$this, 'beforeDelete']);
$server->on('beforeMove', [$this, 'beforeMove'], 90);
$server->on('afterMethod:MKCOL', [$this, 'afterMkcol']);

$this->server = $server;
}

protected function beforeGet(RequestInterface $request) {

Check notice

Code scanning / Psalm

MissingReturnType Note

Method OCA\DAV\Upload\ChunkingV2Plugin::beforeGet does not have a return type, expecting true
$sourceNode = $this->server->tree->getNodeForPath($request->getPath());
if (($sourceNode instanceof FutureFile) || ($sourceNode instanceof UploadFile)) {
throw new MethodNotAllowed('Reading intermediate uploads is not allowed');
}

return true;
}

/**
* @param string $path
* @param bool $createIfNotExists
Expand All @@ -83,7 +94,7 @@
private function getUploadFile(string $path, bool $createIfNotExists = false) {
try {
$actualFile = $this->server->tree->getNodeForPath($path);
// Only directly upload to the target file if it is on the same storage

Check notice

Code scanning / Psalm

MissingReturnType Note

Method OCA\DAV\Upload\ChunkingV2Plugin::beforeGet does not have a return type, expecting true
// There may be further potential to optimize here by also uploading
// to other storages directly. This would require to also carefully pick
// the storage/path used in getStorage()
Expand Down
1 change: 1 addition & 0 deletions apps/dav/lib/Upload/RootCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function __construct(
private IUserSession $userSession,
) {
parent::__construct($principalBackend, $principalPrefix);
$this->disableListing = true;
}

/**
Expand Down
5 changes: 2 additions & 3 deletions apps/dav/lib/Upload/UploadHome.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use OCP\Files\NotFoundException;
use OCP\IUserSession;
use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\Exception\MethodNotAllowed;
use Sabre\DAV\ICollection;

class UploadHome implements ICollection {
Expand Down Expand Up @@ -43,9 +44,7 @@ public function getChild($name): UploadFolder {
}

public function getChildren(): array {
return array_map(function ($node) {
return new UploadFolder($node, $this->cleanupService, $this->getStorage());
}, $this->impl()->getChildren());
throw new MethodNotAllowed('Listing members of this collection is disabled');
}

public function childExists($name): bool {
Expand Down
Loading