Skip to content

Commit f507a35

Browse files
committed
Fix getting cache entry in copyFromStorage
Use the permissions from the unmasked permissions entry since the masked entry doesn't always have the correct permissions.
1 parent a2a89d6 commit f507a35

2 files changed

Lines changed: 7 additions & 9 deletions

File tree

lib/private/Files/Cache/Cache.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
4343
use OC\Files\Search\SearchComparison;
4444
use OC\Files\Search\SearchQuery;
45-
use OCP\Constants;
4645
use OCP\DB\QueryBuilder\IQueryBuilder;
4746
use OCP\EventDispatcher\IEventDispatcher;
4847
use OCP\Files\Cache\CacheEntryInsertedEvent;
@@ -1017,14 +1016,6 @@ public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, str
10171016
throw new \RuntimeException("Invalid source cache entry on copyFromCache");
10181017
}
10191018
$data = $this->cacheEntryToArray($sourceEntry);
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-
}
1027-
}
10281019
$fileId = $this->put($targetPath, $data);
10291020
if ($fileId <= 0) {
10301021
throw new \RuntimeException("Failed to copy to " . $targetPath . " from cache with source data " . json_encode($data) . " ");

lib/private/Files/ObjectStore/ObjectStoreStorage.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
use OC\Files\Cache\Cache;
3636
use OC\Files\Cache\CacheEntry;
3737
use OC\Files\Storage\PolyFill\CopyDirectory;
38+
use OC\Files\Storage\Wrapper\Jail;
3839
use OCP\Files\Cache\ICacheEntry;
3940
use OCP\Files\FileInfo;
4041
use OCP\Files\NotFoundException;
@@ -539,7 +540,13 @@ public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $t
539540
if ($sourceStorage->instanceOfStorage(ObjectStoreStorage::class)) {
540541
/** @var ObjectStoreStorage $sourceStorage */
541542
if ($sourceStorage->getObjectStore()->getStorageId() === $this->getObjectStore()->getStorageId()) {
543+
/** @var CacheEntry $sourceEntry */
542544
$sourceEntry = $sourceStorage->getCache()->get($sourceInternalPath);
545+
$sourceEntryData = $sourceEntry->getData();
546+
if (is_array($sourceEntryData) && $sourceEntryData['scan_permissions']) {
547+
$sourceEntryData['permissions'] = $sourceEntryData['scan_permissions'];
548+
}
549+
$sourceEntry = new CacheEntry($sourceEntryData);
543550
$this->copyInner($sourceEntry, $targetInternalPath);
544551
return true;
545552
}

0 commit comments

Comments
 (0)