mirror of
https://github.com/nextcloud/server.git
synced 2026-02-03 20:41:22 -05:00
fix: permissions when copying from readonly storage
Signed-off-by: Claus-Justus Heine <himself@claus-justus-heine.de>
This commit is contained in:
parent
1fd2d4d435
commit
4a3cd26f61
2 changed files with 30 additions and 2 deletions
|
|
@ -1173,8 +1173,21 @@ class Cache implements ICache {
|
|||
throw new \RuntimeException('Failed to copy to ' . $targetPath . ' from cache with source data ' . json_encode($data) . ' ');
|
||||
}
|
||||
if ($sourceEntry->getMimeType() === ICacheEntry::DIRECTORY_MIMETYPE) {
|
||||
if (($sourceEntry instanceof CacheEntry) && isset($sourceEntry['copy_from_storage_permissions'])) {
|
||||
$permissionsToSet = $sourceEntry['copy_from_storage_permissions'];
|
||||
} else {
|
||||
$permissionsToSet = null;
|
||||
}
|
||||
$folderContent = $sourceCache->getFolderContentsById($sourceEntry->getId());
|
||||
foreach ($folderContent as $subEntry) {
|
||||
if ($permissionsToSet !== null) {
|
||||
$perms = $permissionsToSet;
|
||||
if ($subEntry->getMimeType() !== ICacheEntry::DIRECTORY_MIMETYPE) {
|
||||
$perms &= ~\OCP\Constants::PERMISSION_CREATE;
|
||||
}
|
||||
$subEntry['copy_from_storage_permissions'] = $perms;
|
||||
unset($subEntry['scan_permissions']);
|
||||
}
|
||||
$subTargetPath = $targetPath . '/' . $subEntry->getName();
|
||||
$this->copyFromCache($sourceCache, $subEntry, $subTargetPath);
|
||||
}
|
||||
|
|
@ -1196,9 +1209,14 @@ 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'];
|
||||
if ($entry instanceof CacheEntry) {
|
||||
if (isset($entry['copy_from_storage_permissions'])) {
|
||||
$data['permissions'] = $entry['copy_from_storage_permissions'];
|
||||
} elseif (isset($entry['scan_permissions'])) {
|
||||
$data['permissions'] = $entry['scan_permissions'];
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -193,8 +193,18 @@ class Updater implements IUpdater {
|
|||
if (!$parentInCache) {
|
||||
$parentData = $this->scanner->scan($parent, Scanner::SCAN_SHALLOW, -1, false);
|
||||
$parentInCache = $parentData !== null;
|
||||
} else {
|
||||
$parentData = $this->cache->get($parent);
|
||||
}
|
||||
if ($parentInCache) {
|
||||
if ($sourceInfo instanceof CacheEntry) {
|
||||
$permissionsToSet = $parentData->getPermissions();
|
||||
if ($sourceInfo->getMimeType() !== ICacheEntry::DIRECTORY_MIMETYPE) {
|
||||
$permissionsToSet &= ~\OCP\Constants::PERMISSION_CREATE;
|
||||
}
|
||||
$sourceInfo['copy_from_storage_permissions'] = $permissionsToSet;
|
||||
unset($sourceInfo['scan_permissions']);
|
||||
}
|
||||
$this->cache->copyFromCache($sourceCache, $sourceInfo, $target);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue