Skip to content

Commit dcc554c

Browse files
icewind1991salmart-dev
authored andcommitted
fix: give target file all permissions on copy
Signed-off-by: Robin Appelman <robin@icewind.nl> Signed-off-by: Salvatore Martire <4652631+salmart-dev@users.noreply.github.com>
1 parent 751f80c commit dcc554c

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

lib/private/Files/Cache/Cache.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use OC\Files\Search\SearchQuery;
1515
use OC\Files\Storage\Wrapper\Encryption;
1616
use OC\SystemConfig;
17+
use OCP\Constants;
1718
use OCP\DB\QueryBuilder\IQueryBuilder;
1819
use OCP\EventDispatcher\IEventDispatcher;
1920
use OCP\Files\Cache\CacheEntryInsertedEvent;
@@ -1169,6 +1170,12 @@ public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, str
11691170
throw new \RuntimeException('Invalid source cache entry on copyFromCache');
11701171
}
11711172
$data = $this->cacheEntryToArray($sourceEntry);
1173+
// since we are essentially creating a new file, we don't have to obey the source permissions
1174+
if ($sourceEntry->getMimeType() === ICacheEntry::DIRECTORY_MIMETYPE) {
1175+
$data['permissions'] = Constants::PERMISSION_ALL;
1176+
} else {
1177+
$data['permissions'] = Constants::PERMISSION_ALL - Constants::PERMISSION_CREATE;
1178+
}
11721179

11731180
// when moving from an encrypted storage to a non-encrypted storage remove the `encrypted` mark
11741181
if ($sourceCache instanceof Cache && $sourceCache->hasEncryptionWrapper() && !$this->hasEncryptionWrapper()) {

0 commit comments

Comments
 (0)