chore(encryption): Remove unused attribute $uid in KeyManager::getFileKey

It’s a private API in the application, no need to keep an unused
 attribute.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/55060/head
Côme Chilliet 2025-09-08 16:21:31 +07:00 committed by Andy Scherzinger
parent b28aa8bda2
commit 51f8379140
6 changed files with 8 additions and 9 deletions

@ -85,7 +85,7 @@ class DropLegacyFileKey extends Command {
$output->writeln('<error>' . $path . ' does not have a proper header</error>');
} else {
try {
$legacyFileKey = $this->keyManager->getFileKey($path, null, true);
$legacyFileKey = $this->keyManager->getFileKey($path, true);
if ($legacyFileKey === '') {
$output->writeln('Got an empty legacy filekey for ' . $path . ', continuing', OutputInterface::VERBOSITY_VERBOSE);
continue;

@ -127,7 +127,7 @@ class Encryption implements IEncryptionModule {
/* If useLegacyFileKey is not specified in header, auto-detect, to be safe */
$useLegacyFileKey = (($header['useLegacyFileKey'] ?? '') == 'false' ? false : null);
$this->fileKey = $this->keyManager->getFileKey($this->path, null, $useLegacyFileKey, $this->session->decryptAllModeActivated());
$this->fileKey = $this->keyManager->getFileKey($this->path, $useLegacyFileKey, $this->session->decryptAllModeActivated());
// always use the version from the original file, also part files
// need to have a correct version number if they get moved over to the
@ -335,7 +335,7 @@ class Encryption implements IEncryptionModule {
return false;
}
$fileKey = $this->keyManager->getFileKey($path, null, null);
$fileKey = $this->keyManager->getFileKey($path, null);
if (!empty($fileKey)) {
$publicKeys = [];
@ -438,7 +438,7 @@ class Encryption implements IEncryptionModule {
* @throws DecryptionFailedException
*/
public function isReadable($path, $uid) {
$fileKey = $this->keyManager->getFileKey($path, $uid, null);
$fileKey = $this->keyManager->getFileKey($path, null);
if (empty($fileKey)) {
$owner = $this->util->getOwner($path);
if ($owner !== $uid) {

@ -349,10 +349,9 @@ class KeyManager {
}
/**
* @param ?string $uid deprecated
* @param ?bool $useLegacyFileKey null means try both
*/
public function getFileKey(string $path, ?string $uid, ?bool $useLegacyFileKey, bool $useDecryptAll = false): string {
public function getFileKey(string $path, ?bool $useLegacyFileKey, bool $useDecryptAll = false): string {
$publicAccess = ($this->keyUid === null);
$encryptedFileKey = '';
if ($useLegacyFileKey ?? true) {

@ -159,7 +159,7 @@ class Recovery {
if ($item['type'] === 'dir') {
$this->addRecoveryKeys($filePath . '/');
} else {
$fileKey = $this->keyManager->getFileKey($filePath, $this->user->getUID(), null);
$fileKey = $this->keyManager->getFileKey($filePath, null);
if (!empty($fileKey)) {
$accessList = $this->file->getAccessList($filePath);
$publicKeys = [];

@ -232,7 +232,7 @@ class EncryptionTest extends TestCase {
->willReturn(true);
$this->keyManagerMock->expects($this->once())
->method('getFileKey')
->with($path, null, null, true)
->with($path, null, true)
->willReturn($fileKey);
$this->instance->begin($path, 'user', 'r', [], []);

@ -417,7 +417,7 @@ class KeyManagerTest extends TestCase {
}
$this->assertSame($expected,
$this->instance->getFileKey($path, null, null)
$this->instance->getFileKey($path, null)
);
}