Skip to content

Commit df4e6ba

Browse files
authored
Merge pull request #29115 from nextcloud/work/carl/correct-permissions-when-copying
Fix permissions when copying from ObjectStorage
2 parents 74cfe73 + bfa60aa commit df4e6ba

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
@@ -1009,7 +1009,7 @@ public function normalize($path) {
10091009
* @param ICache $sourceCache
10101010
* @param ICacheEntry $sourceEntry
10111011
* @param string $targetPath
1012-
* @return int fileid of copied entry
1012+
* @return int fileId of copied entry
10131013
*/
10141014
public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, string $targetPath): int {
10151015
if ($sourceEntry->getId() < 0) {

lib/private/Files/ObjectStore/ObjectStoreStorage.php

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

0 commit comments

Comments
 (0)