summaryrefslogtreecommitdiffstats
path: root/settings/ajax
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2015-01-13 12:45:33 +0100
committerBjoern Schiessle <schiessle@owncloud.com>2015-01-13 12:45:33 +0100
commit89f17ef6fe1b33d6eaa2f4a19e9fb598b219ab26 (patch)
treeebf46b68c5de4e76e9086c7f31f8b773acd77cad /settings/ajax
parentdc86cbd1e275f01840b304751a02ecbe4043c51e (diff)
downloadnextcloud-server-89f17ef6fe1b33d6eaa2f4a19e9fb598b219ab26.tar.gz
nextcloud-server-89f17ef6fe1b33d6eaa2f4a19e9fb598b219ab26.zip
adapt decrypt all and restore/delete key backups to the new folder structure for encryption key introduced with OC8
Diffstat (limited to 'settings/ajax')
-rw-r--r--settings/ajax/deletekeys.php8
-rw-r--r--settings/ajax/restorekeys.php15
2 files changed, 6 insertions, 17 deletions
diff --git a/settings/ajax/deletekeys.php b/settings/ajax/deletekeys.php
index 86a45820af9..7d6c9a27aa0 100644
--- a/settings/ajax/deletekeys.php
+++ b/settings/ajax/deletekeys.php
@@ -4,13 +4,11 @@ OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
$l = \OC::$server->getL10N('settings');
-$user = \OC_User::getUser();
-$view = new \OC\Files\View('/' . $user . '/files_encryption');
-$keyfilesDeleted = $view->deleteAll('keyfiles.backup');
-$sharekeysDeleted = $view->deleteAll('share-keys.backup');
+$util = new \OCA\Files_Encryption\Util(new \OC\Files\View(), \OC_User::getUser());
+$result = $util->deleteBackup('decryptAll');
-if ($keyfilesDeleted && $sharekeysDeleted) {
+if ($result) {
\OCP\JSON::success(array('data' => array('message' => $l->t('Encryption keys deleted permanently'))));
} else {
\OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t permanently delete your encryption keys, please check your owncloud.log or ask your administrator'))));
diff --git a/settings/ajax/restorekeys.php b/settings/ajax/restorekeys.php
index 5c263fadab4..b89a8286db2 100644
--- a/settings/ajax/restorekeys.php
+++ b/settings/ajax/restorekeys.php
@@ -4,21 +4,12 @@ OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
$l = \OC::$server->getL10N('settings');
-$user = \OC_User::getUser();
-$view = new \OC\Files\View('/' . $user . '/files_encryption');
-$keyfilesRestored = $view->rename('keyfiles.backup', 'keyfiles');
-$sharekeysRestored = $view->rename('share-keys.backup' , 'share-keys');
+$util = new \OCA\Files_Encryption\Util(new \OC\Files\View(), \OC_User::getUser());
+$result = $util->restoreBackup('decryptAll');
-if ($keyfilesRestored && $sharekeysRestored) {
+if ($result) {
\OCP\JSON::success(array('data' => array('message' => $l->t('Backups restored successfully'))));
} else {
- // if one of the move operation was succesful we remove the files back to have a consistent state
- if($keyfilesRestored) {
- $view->rename('keyfiles', 'keyfiles.backup');
- }
- if($sharekeysRestored) {
- $view->rename('share-keys' , 'share-keys.backup');
- }
\OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t restore your encryption keys, please check your owncloud.log or ask your administrator'))));
}