Skip to content

Commit

Permalink
chore: Improve typing in core/Command/Encryption/MigrateKeyStorage.php
Browse files Browse the repository at this point in the history
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
  • Loading branch information
come-nc committed Mar 28, 2024
1 parent e317ebd commit 310c8cb
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions core/Command/Encryption/MigrateKeyStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct(
parent::__construct();
}

protected function configure() {
protected function configure(): void {
parent::configure();
$this
->setName('encryption:migrate-key-storage-format')
Expand All @@ -67,9 +67,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
/**
* Move keys to new key storage root
*
* @param string $root
* @param OutputInterface $output
* @return bool
* @throws \Exception
*/
protected function updateKeys(string $root, OutputInterface $output): bool {
Expand All @@ -92,7 +89,7 @@ protected function updateSystemKeys(string $root): void {
$this->traverseKeys($root . '/files_encryption', null);
}

private function traverseKeys(string $folder, ?string $uid) {
private function traverseKeys(string $folder, ?string $uid): void {
$listing = $this->rootView->getDirectoryContent($folder);

foreach ($listing as $node) {
Expand Down Expand Up @@ -126,14 +123,14 @@ private function traverseKeys(string $folder, ?string $uid) {
}
}

private function traverseFileKeys(string $folder) {
private function traverseFileKeys(string $folder): void {
$listing = $this->rootView->getDirectoryContent($folder);

foreach ($listing as $node) {
if ($node['mimetype'] === 'httpd/unix-directory') {
$this->traverseFileKeys($folder . '/' . $node['name']);
} else {
$endsWith = function ($haystack, $needle) {
$endsWith = function (string $haystack, string $needle): bool {
$length = strlen($needle);
if ($length === 0) {
return true;
Expand Down Expand Up @@ -171,22 +168,17 @@ private function traverseFileKeys(string $folder) {

/**
* setup file system for the given user
*
* @param string $uid
*/
protected function setupUserFS($uid) {
protected function setupUserFS(string $uid): void {
\OC_Util::tearDownFS();
\OC_Util::setupFS($uid);
}


/**
* iterate over each user and move the keys to the new storage
*
* @param string $root
* @param OutputInterface $output
*/
protected function updateUsersKeys(string $root, OutputInterface $output) {
protected function updateUsersKeys(string $root, OutputInterface $output): void {
$progress = new ProgressBar($output);
$progress->start();

Expand All @@ -209,11 +201,9 @@ protected function updateUsersKeys(string $root, OutputInterface $output) {
/**
* move user encryption folder to new root folder
*
* @param string $root
* @param string $user
* @throws \Exception
*/
protected function updateUserKeys(string $root, string $user) {
protected function updateUserKeys(string $root, string $user): void {
if ($this->userManager->userExists($user)) {
$source = $root . '/' . $user . '/files_encryption/OC_DEFAULT_MODULE';
if ($this->rootView->is_dir($source)) {
Expand Down

0 comments on commit 310c8cb

Please sign in to comment.