From fc1865449d30f78e55e2830555a92bf4e8c1dfcd Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Thu, 22 Jan 2015 16:10:45 +0100 Subject: adding console command to migrate encryption keys - refs #13450 --- apps/files_encryption/lib/migration.php | 49 +++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 21 deletions(-) (limited to 'apps/files_encryption/lib') diff --git a/apps/files_encryption/lib/migration.php b/apps/files_encryption/lib/migration.php index 1bab1dfe4a5..38bedbb5824 100644 --- a/apps/files_encryption/lib/migration.php +++ b/apps/files_encryption/lib/migration.php @@ -40,6 +40,15 @@ class Migration { } public function reorganizeFolderStructure() { + $this->reorganizeSystemFolderStructure(); + + $users = \OCP\User::getUsers(); + foreach ($users as $user) { + $this->reorganizeFolderStructureForUser($user); + } + } + + public function reorganizeSystemFolderStructure() { $this->createPathForKeys('/files_encryption'); @@ -60,27 +69,27 @@ class Migration { $this->view->deleteAll('/owncloud_private_key'); $this->view->deleteAll('/files_encryption/share-keys'); $this->view->deleteAll('/files_encryption/keyfiles'); + } - $users = \OCP\User::getUsers(); - foreach ($users as $user) { - // backup all keys - if ($this->backupUserKeys($user)) { - // create new 'key' folder - $this->view->mkdir($user . '/files_encryption/keys'); - // rename users private key - $this->renameUsersPrivateKey($user); - // rename file keys - $path = $user . '/files_encryption/keyfiles'; - $this->renameFileKeys($user, $path); - $trashPath = $user . '/files_trashbin/keyfiles'; - if (\OC_App::isEnabled('files_trashbin') && $this->view->is_dir($trashPath)) { - $this->renameFileKeys($user, $trashPath, true); - $this->view->deleteAll($trashPath); - $this->view->deleteAll($user . '/files_trashbin/share-keys'); - } - // delete old folders - $this->deleteOldKeys($user); + + public function reorganizeFolderStructureForUser($user) { + // backup all keys + if ($this->backupUserKeys($user)) { + // create new 'key' folder + $this->view->mkdir($user . '/files_encryption/keys'); + // rename users private key + $this->renameUsersPrivateKey($user); + // rename file keys + $path = $user . '/files_encryption/keyfiles'; + $this->renameFileKeys($user, $path); + $trashPath = $user . '/files_trashbin/keyfiles'; + if (\OC_App::isEnabled('files_trashbin') && $this->view->is_dir($trashPath)) { + $this->renameFileKeys($user, $trashPath, true); + $this->view->deleteAll($trashPath); + $this->view->deleteAll($user . '/files_trashbin/share-keys'); } + // delete old folders + $this->deleteOldKeys($user); } } @@ -277,6 +286,4 @@ class Migration { } } } - - } -- cgit v1.2.3