Skip to content
Draft
Changes from all commits
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
27 changes: 27 additions & 0 deletions lib/private/Encryption/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,16 @@
return $result;
}

public function isCollectiveMountPoint(string $path, string $uid) {
$mount = Filesystem::getMountManager()->find('/' . $uid . $path);
if (!$mount) {

Check failure on line 251 in lib/private/Encryption/Util.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

TypeDoesNotContainType

lib/private/Encryption/Util.php:251:8: TypeDoesNotContainType: Type OCP\Files\Mount\IMountPoint for $mount is never falsy (see https://psalm.dev/056)

Check failure on line 251 in lib/private/Encryption/Util.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

TypeDoesNotContainType

lib/private/Encryption/Util.php:251:7: TypeDoesNotContainType: Operand of type false is always falsy (see https://psalm.dev/056)
return false;
}

// We use class name to avoid hard dependency on collectives app
return strpos(get_class($mount), 'CollectiveMountPoint') !== false;
}

/**
* check if the file is stored on a system wide mount point
* @param string $path relative to /data/user with leading '/'
Expand Down Expand Up @@ -357,6 +367,23 @@
$root = $this->getKeyStorageRoot();

// in case of system-wide mount points the keys are stored directly in the data directory
if ($this->isCollectiveMountPoint($filename, $owner)) {
$fileId === null;

Check failure on line 371 in lib/private/Encryption/Util.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

UndefinedVariable

lib/private/Encryption/Util.php:371:4: UndefinedVariable: Cannot find referenced variable $fileId (see https://psalm.dev/024)
try {
$fileInfo = $this->rootView->getFileInfo($path);
if ($fileInfo) {
$fileId = $fileInfo['fileid'] ?? null;
}
} catch (\Exception) {
// continue
}

if ($fileId !== null) {
$keyPath = $root . '/files_encryption/keys_by_fileId/' . $fileId . '/';
return Filesystem::normalizePath($keyPath . $encryptionModuleId . '/', false);
}
}

if ($this->isSystemWideMountPoint($filename, $owner)) {
$keyPath = $root . '/' . '/files_encryption/keys' . $filename . '/';
} else {
Expand Down
Loading