Skip to content

Commit

Permalink
Fix getting cache entry in copyFromStorage
Browse files Browse the repository at this point in the history
Use the permissions from the unmasked permissions entry since the
masked entry doesn't always have the correct permissions.
  • Loading branch information
CarlSchwan committed Oct 8, 2021
1 parent a2a89d6 commit 4edbb8a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
9 changes: 0 additions & 9 deletions lib/private/Files/Cache/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use OC\Files\Search\SearchComparison;
use OC\Files\Search\SearchQuery;
use OCP\Constants;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Cache\CacheEntryInsertedEvent;
Expand Down Expand Up @@ -1017,14 +1016,6 @@ public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, str
throw new \RuntimeException("Invalid source cache entry on copyFromCache");
}
$data = $this->cacheEntryToArray($sourceEntry);
$targetParentEntry = $this->get(dirname($targetPath));
if ($targetParentEntry !== false && $targetParentEntry !== null) {
if ($sourceEntry->getMimeType() === ICacheEntry::DIRECTORY_MIMETYPE) {
$data['permissions'] = $targetParentEntry->getPermissions();
} else {
$data['permissions'] = $targetParentEntry->getPermissions() & ~Constants::PERMISSION_CREATE;
}
}
$fileId = $this->put($targetPath, $data);
if ($fileId <= 0) {
throw new \RuntimeException("Failed to copy to " . $targetPath . " from cache with source data " . json_encode($data) . " ");
Expand Down
6 changes: 6 additions & 0 deletions lib/private/Files/ObjectStore/ObjectStoreStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,13 @@ 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();
if (is_array($sourceEntryData) && array_key_exists('scan_permissions', $sourceEntryData)) {
$sourceEntryData['permissions'] = $sourceEntryData['scan_permissions'];
}
$sourceEntry = new CacheEntry($sourceEntryData);
$this->copyInner($sourceEntry, $targetInternalPath);
return true;
}
Expand Down

0 comments on commit 4edbb8a

Please sign in to comment.