Skip to content

Commit

Permalink
feat: adding new storage method setFileKey
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepDiver1975 committed Dec 15, 2021
1 parent d4fe6d7 commit 92ca08f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
8 changes: 8 additions & 0 deletions lib/private/Encryption/Keys/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,14 @@ public function setUserKey($uid, $keyId, $key, $encryptionModuleId) {
* @inheritdoc
*/
public function setFileKey($path, $keyId, $key, $encryptionModuleId) {
$mount = $this->mountManager->find($path);
if ($mount) {
$result = $mount->getStorage()->setFileKey($mount->getInternalPath($path), $keyId, $key, $encryptionModuleId);
if ($result !== null) {
return $result;
}
}

$keyDir = $this->getFileKeyDir($encryptionModuleId, $path);
return $this->setKey($keyDir . $keyId, $key);
}
Expand Down
6 changes: 5 additions & 1 deletion lib/private/Files/Storage/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,11 @@ public function getEncryptionFileKeyDirectory(string $encryptionModuleId, string
return null;
}

public function getFileKey(string $path, string $keyId, string $encryptionModuleId): ?string {
public function getFileKey(string $internalPath, string $keyId, string $encryptionModuleId): ?string {
return null;
}

public function setFileKey(string $internalPath, string $keyId, $key, string $encryptionModuleId): ?bool {
return null;
}
}
4 changes: 3 additions & 1 deletion lib/private/Files/Storage/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,7 @@ public function changeLock($path, $type, ILockingProvider $provider);

public function getEncryptionFileKeyDirectory(string $encryptionModuleId, string $path): ?string;

public function getFileKey(string $path, string $keyId, string $encryptionModuleId): ?string;
public function getFileKey(string $internalPath, string $keyId, string $encryptionModuleId): ?string;

public function setFileKey(string $internalPath, string $keyId, $key, string $encryptionModuleId): ?bool;
}
8 changes: 6 additions & 2 deletions lib/private/Files/Storage/Wrapper/Wrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,11 @@ public function getEncryptionFileKeyDirectory(string $encryptionModuleId, string
return $this->getWrapperStorage()->getEncryptionFileKeyDirectory($encryptionModuleId, $path);
}

public function getFileKey(string $path, string $keyId, string $encryptionModuleId): ?string {
return $this->getWrapperStorage()->getFileKey($path, $keyId, $encryptionModuleId);
public function getFileKey(string $internalPath, string $keyId, string $encryptionModuleId): ?string {
return $this->getWrapperStorage()->getFileKey($internalPath, $keyId, $encryptionModuleId);
}

public function setFileKey(string $internalPath, string $keyId, $key, string $encryptionModuleId): ?bool {
return $this->getWrapperStorage()->setFileKey($internalPath, $keyId, $key, $encryptionModuleId);
}
}

0 comments on commit 92ca08f

Please sign in to comment.