Skip to content

Commit 17b5d9a

Browse files
committed
Use permissions from parent
Signed-off-by: Carl Schwan <[email protected]>
1 parent 7b17feb commit 17b5d9a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/private/Files/Cache/Cache.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,10 +1017,13 @@ public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, str
10171017
throw new \RuntimeException("Invalid source cache entry on copyFromCache");
10181018
}
10191019
$data = $this->cacheEntryToArray($sourceEntry);
1020-
if ($sourceEntry->getMimeType() === ICacheEntry::DIRECTORY_MIMETYPE) {
1021-
$data['permissions'] = Constants::PERMISSION_ALL;
1022-
} else {
1023-
$data['permissions'] = Constants::PERMISSION_ALL - Constants::PERMISSION_CREATE;
1020+
$targetParentEntry = $this->get(dirname($targetPath));
1021+
if ($targetParentEntry !== false && $targetParentEntry !== null) {
1022+
if ($sourceEntry->getMimeType() === ICacheEntry::DIRECTORY_MIMETYPE) {
1023+
$data['permissions'] = $targetParentEntry->getPermissions();
1024+
} else {
1025+
$data['permissions'] = $targetParentEntry->getPermissions() - Constants::PERMISSION_CREATE;
1026+
}
10241027
}
10251028
$fileId = $this->put($targetPath, $data);
10261029
if ($fileId <= 0) {

0 commit comments

Comments
 (0)