Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed moving of master key encrypted and versioned files between shared folders #16696

Open
wants to merge 1 commit into
base: master
from
Open
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

fixed moving of encrypted and versioned files between shared folders

Signed-off-by: Kenny <k.niehage@syseleven.de>
  • Loading branch information
yahesh committed Aug 8, 2019
commit 3b1f3fc86ca389ae54ef903d93e239594514f203
@@ -286,7 +286,7 @@ public function fopen($path, $mode) {
}
}
$info = array(
'target' => $this->getMountPoint() . $path,
'target' => $this->getMountPoint() . '/' . $path,
'source' => $source,
'mode' => $mode,
);
@@ -307,9 +307,9 @@ public function rename($path1, $path2) {
$this->init();
$isPartFile = pathinfo($path1, PATHINFO_EXTENSION) === 'part';
$targetExists = $this->file_exists($path2);
$sameFodler = dirname($path1) === dirname($path2);
$sameFolder = dirname($path1) === dirname($path2);

if ($targetExists || ($sameFodler && !$isPartFile)) {
if ($targetExists || ($sameFolder && !$isPartFile)) {
if (!$this->isUpdatable('')) {
return false;
}
@@ -99,8 +99,8 @@ public function unlink($path) {
} catch (GenericEncryptionException $e) {
// in case of a encryption exception we delete the file right away
$this->logger->info(
"Can't move file" . $path .
"to the trash bin, therefore it was deleted right away");
"Can't move file " . $path .
" to the trash bin, therefore it was deleted right away");

return $this->storage->unlink($path);
}
@@ -383,7 +383,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;
@@ -251,7 +251,7 @@ public function unlink($path) {

$encryptionModule = $this->getEncryptionModule($path);
if ($encryptionModule) {
$this->keyStorage->deleteAllFileKeys($this->getFullPath($path));
$this->keyStorage->deleteAllFileKeys($fullPath);
}

return $this->storage->unlink($path);
@@ -700,6 +700,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) ||
@@ -770,8 +780,11 @@ private function copyBetweenStorage(Storage\IStorage $sourceStorage, $sourceInte
$this->getCache()->remove($targetInternalPath);
}
}
return (bool)$result;

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

return (bool)$result;
}

/**
@@ -1016,7 +1029,7 @@ protected function shouldEncrypt($path) {
}

try {
$encryptionModule = $this->getEncryptionModule($fullPath);
$encryptionModule = $this->getEncryptionModule($path);
} catch (ModuleDoesNotExistsException $e) {
return false;
}
@@ -55,7 +55,7 @@ public function __construct(IDBConnection $connection,
public function run($argument) {
$previews = $this->appDataFactory->get('preview');

$previewFodlerId = $previews->getId();
$previewFolderId = $previews->getId();

$qb = $this->connection->getQueryBuilder();
$qb->select('a.name')
@@ -66,7 +66,7 @@ public function run($argument) {
->where(
$qb->expr()->isNull('b.fileid')
)->andWhere(
$qb->expr()->eq('a.parent', $qb->createNamedParameter($previewFodlerId))
$qb->expr()->eq('a.parent', $qb->createNamedParameter($previewFolderId))
);

if (!$this->isCLI) {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.