mirror of
https://github.com/nextcloud/server.git
synced 2026-06-10 09:13:19 -04:00
Merge pull request #49657 from nextcloud/backport/48769/stable30
[stable30] Fix incorrect permissions when copying shared files
This commit is contained in:
commit
7bf1126b1f
2 changed files with 35 additions and 1 deletions
|
|
@ -10,6 +10,7 @@ use OC\Files\View;
|
|||
use OCA\Files_Sharing\SharedStorage;
|
||||
use OCA\Files_Trashbin\AppInfo\Application;
|
||||
use OCP\AppFramework\Bootstrap\IBootContext;
|
||||
use OCP\Constants;
|
||||
use OCP\Files\NotFoundException;
|
||||
use OCP\Share\IShare;
|
||||
|
||||
|
|
@ -579,4 +580,30 @@ class SharedStorageTest extends TestCase {
|
|||
$this->assertInstanceOf(\OC\Files\Storage\FailedStorage::class, $storage->getSourceStorage());
|
||||
$this->assertInstanceOf(\OC\Files\Cache\FailedCache::class, $storage->getCache());
|
||||
}
|
||||
|
||||
public function testCopyPermissions(): void {
|
||||
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
|
||||
|
||||
$share = $this->share(
|
||||
IShare::TYPE_USER,
|
||||
$this->filename,
|
||||
self::TEST_FILES_SHARING_API_USER1,
|
||||
self::TEST_FILES_SHARING_API_USER2,
|
||||
Constants::PERMISSION_ALL - Constants::PERMISSION_CREATE - Constants::PERMISSION_DELETE
|
||||
);
|
||||
|
||||
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
|
||||
$view = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
|
||||
$this->assertTrue($view->file_exists($this->filename));
|
||||
|
||||
$this->assertTrue($view->copy($this->filename, '/target.txt'));
|
||||
|
||||
$this->assertTrue($view->file_exists('/target.txt'));
|
||||
|
||||
$info = $view->getFileInfo('/target.txt');
|
||||
$this->assertEquals(Constants::PERMISSION_ALL - Constants::PERMISSION_CREATE, $info->getPermissions());
|
||||
|
||||
$this->view->unlink($this->filename);
|
||||
$this->shareManager->deleteShare($share);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,6 +168,9 @@ class Cache implements ICache {
|
|||
if ($data['storage_mtime'] == 0) {
|
||||
$data['storage_mtime'] = $data['mtime'];
|
||||
}
|
||||
if (isset($data['f_permissions'])) {
|
||||
$data['scan_permissions'] = $data['f_permissions'];
|
||||
}
|
||||
$data['permissions'] = (int)$data['permissions'];
|
||||
if (isset($data['creation_time'])) {
|
||||
$data['creation_time'] = (int)$data['creation_time'];
|
||||
|
|
@ -1183,7 +1186,7 @@ class Cache implements ICache {
|
|||
}
|
||||
|
||||
private function cacheEntryToArray(ICacheEntry $entry): array {
|
||||
return [
|
||||
$data = [
|
||||
'size' => $entry->getSize(),
|
||||
'mtime' => $entry->getMTime(),
|
||||
'storage_mtime' => $entry->getStorageMTime(),
|
||||
|
|
@ -1196,6 +1199,10 @@ class Cache implements ICache {
|
|||
'upload_time' => $entry->getUploadTime(),
|
||||
'metadata_etag' => $entry->getMetadataEtag(),
|
||||
];
|
||||
if ($entry instanceof CacheEntry && isset($entry['scan_permissions'])) {
|
||||
$data['permissions'] = $entry['scan_permissions'];
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getQueryFilterForStorage(): ISearchOperator {
|
||||
|
|
|
|||
Loading…
Reference in a new issue