diff options
author | Robin Appelman <robin@icewind.nl> | 2024-01-17 17:47:01 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2024-01-17 18:10:03 +0100 |
commit | 2205e34831a176149cbdbd29c2d7040b2be148d6 (patch) | |
tree | 070de640b0978f8387833afd4e70f4b9d14d8591 /lib/private/Encryption/Util.php | |
parent | 11ed33a4e0615c4cee5e36c516b4001a64e7c5b4 (diff) | |
download | nextcloud-server-file-info-key-location-27.tar.gz nextcloud-server-file-info-key-location-27.zip |
add key location to info:file outputfile-info-key-location-27
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Encryption/Util.php')
-rw-r--r-- | lib/private/Encryption/Util.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/private/Encryption/Util.php b/lib/private/Encryption/Util.php index 6ae0006e955..186444af783 100644 --- a/lib/private/Encryption/Util.php +++ b/lib/private/Encryption/Util.php @@ -360,4 +360,25 @@ class Util { public function getKeyStorageRoot(): string { return $this->config->getAppValue('core', 'encryption_key_storage_root', ''); } + + /** + * get path to key folder for a given file + * + * @param string $encryptionModuleId + * @param string $path path to the file, relative to data/ + * @return string + */ + public function getFileKeyDir(string $encryptionModuleId, string $path): string { + [$owner, $filename] = $this->getUidAndFilename($path); + $root = $this->getKeyStorageRoot(); + + // in case of system-wide mount points the keys are stored directly in the data directory + if ($this->isSystemWideMountPoint($filename, $owner)) { + $keyPath = $root . '/' . '/files_encryption/keys' . $filename . '/'; + } else { + $keyPath = $root . '/' . $owner . '/files_encryption/keys' . $filename . '/'; + } + + return Filesystem::normalizePath($keyPath . $encryptionModuleId . '/', false); + } } |