Skip to content

Commit

Permalink
Merge pull request #29115 from nextcloud/work/carl/correct-permission…
Browse files Browse the repository at this point in the history
…s-when-copying

Fix permissions when copying from ObjectStorage
  • Loading branch information
CarlSchwan authored Oct 28, 2021
2 parents 74cfe73 + bfa60aa commit df4e6ba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/private/Files/Cache/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ public function normalize($path) {
* @param ICache $sourceCache
* @param ICacheEntry $sourceEntry
* @param string $targetPath
* @return int fileid of copied entry
* @return int fileId of copied entry
*/
public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, string $targetPath): int {
if ($sourceEntry->getId() < 0) {
Expand Down
8 changes: 8 additions & 0 deletions lib/private/Files/ObjectStore/ObjectStoreStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,15 @@ public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $t
if ($sourceStorage->instanceOfStorage(ObjectStoreStorage::class)) {
/** @var ObjectStoreStorage $sourceStorage */
if ($sourceStorage->getObjectStore()->getStorageId() === $this->getObjectStore()->getStorageId()) {
/** @var CacheEntry $sourceEntry */
$sourceEntry = $sourceStorage->getCache()->get($sourceInternalPath);
$sourceEntryData = $sourceEntry->getData();
// $sourceEntry['permissions'] here is the permissions from the jailed storage for the current
// user. Instead we use $sourceEntryData['scan_permissions'] that are the permissions from the
// unjailed storage.
if (is_array($sourceEntryData) && array_key_exists('scan_permissions', $sourceEntryData)) {
$sourceEntry['permissions'] = $sourceEntryData['scan_permissions'];
}
$this->copyInner($sourceEntry, $targetInternalPath);
return true;
}
Expand Down

0 comments on commit df4e6ba

Please sign in to comment.