aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-01-22 16:10:45 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-01-22 16:10:45 +0100
commitfc1865449d30f78e55e2830555a92bf4e8c1dfcd (patch)
treef6b94ef2253fb71ae93677dfc47fe42e4b0ccb20 /apps/files_encryption/lib
parentb5b491d1bb12a869ddae7878e8aa441109419a00 (diff)
downloadnextcloud-server-fc1865449d30f78e55e2830555a92bf4e8c1dfcd.tar.gz
nextcloud-server-fc1865449d30f78e55e2830555a92bf4e8c1dfcd.zip
adding console command to migrate encryption keys - refs #13450
Diffstat (limited to 'apps/files_encryption/lib')
-rw-r--r--apps/files_encryption/lib/migration.php49
1 files changed, 28 insertions, 21 deletions
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 {
}
}
}
-
-
}