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
16 changes: 11 additions & 5 deletions apps/dav/appinfo/v2/publicremote.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
use OC\Files\Filesystem;
use OC\Files\Storage\Wrapper\DirPermissionsMask;
use OC\Files\Storage\Wrapper\PermissionsMask;
use OC\Files\View;
use OCA\DAV\Connector\Sabre\PublicAuth;
use OCA\DAV\Connector\Sabre\ServerFactory;
Expand All @@ -21,6 +22,7 @@
use OCP\BeforeSabrePubliclyLoadedEvent;
use OCP\Constants;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\IHomeStorage;
use OCP\Files\IRootFolder;
use OCP\Files\Mount\IMountManager;
use OCP\ICacheFactory;
Expand Down Expand Up @@ -116,11 +118,15 @@
$mask |= Constants::PERMISSION_READ | Constants::PERMISSION_DELETE;
}

return new DirPermissionsMask([
'storage' => $storage,
'mask' => $mask,
'path' => 'files',
]);
if ($storage instanceof IHomeStorage) {
return new DirPermissionsMask([
'storage' => $storage,
'mask' => $mask,
'path' => 'files',
]);
} else {
return new PermissionsMask(['storage' => $storage, 'mask' => $mask]);
}
});

/** @psalm-suppress MissingClosureParamType */
Expand Down
17 changes: 17 additions & 0 deletions build/integration/features/bootstrap/WebDav.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,23 @@ public function downloadedContentShouldStartWith($start) {
}
}

/**
* @When Uploading public file :filename with content :content
*/
public function uploadingPublicFile(string $filename, string $content) {
$token = $this->lastShareData->data->token;
$fullUrl = substr($this->baseUrl, 0, -4) . "public.php/dav/files/$token/$filename";

$client = new GClient();
try {
$this->response = $client->request('PUT', $fullUrl, [
'body' => $content
]);
} catch (\GuzzleHttp\Exception\ClientException $e) {
$this->response = $e->getResponse();
}
}

/**
* @Then /^as "([^"]*)" gets properties of (file|folder|entry) "([^"]*)" with$/
* @param string $user
Expand Down
23 changes: 22 additions & 1 deletion build/integration/sharing_features/sharing-v1.feature
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,28 @@ Feature: sharing
And Share fields of last share match with
| expiration | +3 days |

Scenario: getting all shares of a user using that user
Scenario: Writing to a read-only link share of an external storage
Given user "user0" exists
Then As an "user0"
When creating a share with
| path | local_storage |
| shareType | 3 |
And the OCS status code should be "100"
And the HTTP status code should be "200"
Then Uploading public file "foo.txt" with content "bar"
And the HTTP status code should be "403"

Scenario: Writing to a read-write link share of an external storage
Given user "user0" exists
Then As an "user0"
When creating a share with
| path | local_storage |
| shareType | 3 |
| permissions | 7 |
Then Uploading public file "foo.txt" with content "bar"
And the HTTP status code should be "201"

Scenario: getting all shares of a user using that user
Given user "user0" exists
And user "user1" exists
When User "user1" deletes file "/textfile0.txt"
Expand Down
4 changes: 2 additions & 2 deletions lib/private/Files/Storage/Wrapper/DirPermissionsMask.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
namespace OC\Files\Storage\Wrapper;

use OC\Files\Cache\Wrapper\CacheDirPermissionsMask;
use OC\Files\Storage\Storage;
use OCP\Files\Cache\ICache;
use OCP\Files\Storage\IStorage;

/**
* While PermissionMask can mask a whole storage this can
Expand All @@ -30,7 +30,7 @@ class DirPermissionsMask extends PermissionsMask {
private readonly int $pathLength;

/**
* @param array{storage: Storage, mask: int, path: string, ...} $parameters
* @param array{storage: IStorage, mask: int, path: string, ...} $parameters
* @psalm-suppress MoreSpecificImplementedParamType
*
* $storage: The storage the permissions mask should be applied on
Expand Down
Loading