Skip to content

Commit 373b63e

Browse files
authored
Merge pull request #29476 from nextcloud/backport/29115/stable21
[stable21] Fix permissions when copying from ObjectStorage
2 parents e4e3510 + 00a9b0c commit 373b63e

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

lib/private/Files/Cache/Cache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ public function normalize($path) {
10971097
* @param ICache $sourceCache
10981098
* @param ICacheEntry $sourceEntry
10991099
* @param string $targetPath
1100-
* @return int fileid of copied entry
1100+
* @return int fileId of copied entry
11011101
*/
11021102
public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, string $targetPath): int {
11031103
if ($sourceEntry->getId() < 0) {

lib/private/Files/ObjectStore/ObjectStoreStorage.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,15 @@ public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $t
540540
if ($sourceStorage->instanceOfStorage(ObjectStoreStorage::class)) {
541541
/** @var ObjectStoreStorage $sourceStorage */
542542
if ($sourceStorage->getObjectStore()->getStorageId() === $this->getObjectStore()->getStorageId()) {
543+
/** @var CacheEntry $sourceEntry */
543544
$sourceEntry = $sourceStorage->getCache()->get($sourceInternalPath);
545+
$sourceEntryData = $sourceEntry->getData();
546+
// $sourceEntry['permissions'] here is the permissions from the jailed storage for the current
547+
// user. Instead we use $sourceEntryData['scan_permissions'] that are the permissions from the
548+
// unjailed storage.
549+
if (is_array($sourceEntryData) && array_key_exists('scan_permissions', $sourceEntryData)) {
550+
$sourceEntry['permissions'] = $sourceEntryData['scan_permissions'];
551+
}
544552
$this->copyInner($sourceEntry, $targetInternalPath);
545553
return true;
546554
}

0 commit comments

Comments
 (0)