Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fixed moving of encrypted and versioned files between shared folders
Signed-off-by: Kenny <k.niehage@syseleven.de>
  • Loading branch information
weizenspreu authored and MorrisJobke committed Sep 17, 2020
commit 3c167b7da68ff43c5a1100ec304fca7d4a9cea41
2 changes: 1 addition & 1 deletion lib/private/Files/Storage/Local.php
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ public function getSourcePath($path) {
throw new ForbiddenException('Invalid path', false);
}

$fullPath = $this->datadir . $path;
$fullPath = Filesystem::normalizePath($this->datadir . $path);
$currentPath = $path;
if ($this->allowSymlinks || $currentPath === '') {
return $fullPath;
Expand Down
16 changes: 15 additions & 1 deletion lib/private/Files/Storage/Wrapper/Encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,16 @@ private function updateEncryptedVersion(Storage\IStorage $sourceStorage, $source
*/
private function copyBetweenStorage(Storage\IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime, $isRename) {

// store encryptedVersion
$encrypted = false;
$encryptedVersion = 0;
if (isset($sourceStorage->getCache()->get($sourceInternalPath)['encrypted'])) {
$encrypted = $sourceStorage->getCache()->get($sourceInternalPath)['encrypted'];
}
if (isset($sourceStorage->getCache()->get($sourceInternalPath)['encryptedVersion'])) {
$encryptedVersion = $sourceStorage->getCache()->get($sourceInternalPath)['encryptedVersion'];
}

// for versions we have nothing to do, because versions should always use the
// key from the original file. Just create a 1:1 copy and done
if ($this->isVersion($targetInternalPath) ||
Expand Down Expand Up @@ -774,6 +784,10 @@ private function copyBetweenStorage(Storage\IStorage $sourceStorage, $sourceInte
$this->getCache()->remove($targetInternalPath);
}
}

// restore encryptedVersion
$sourceStorage->getCache()->put($sourceInternalPath, ['encrypted' => $encrypted, 'encryptedVersion' => $encryptedVersion]);

return (bool)$result;
}

Expand Down Expand Up @@ -1020,7 +1034,7 @@ protected function shouldEncrypt($path) {
}

try {
$encryptionModule = $this->getEncryptionModule($fullPath);
$encryptionModule = $this->getEncryptionModule($path);
} catch (ModuleDoesNotExistsException $e) {
return false;
}
Expand Down