summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files_encryption/lib/util.php36
-rw-r--r--settings/ajax/decryptall.php12
2 files changed, 34 insertions, 14 deletions
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index 03e2fae4c65..5649472e0b5 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -661,7 +661,7 @@ class Util {
}
}
-
+
/**
* @brief Decrypt all files
* @return bool
@@ -670,6 +670,8 @@ class Util {
$found = $this->findEncFiles($this->userId . '/files');
+ $successful = true;
+
if ($found) {
// Disable proxy to prevent file being encrypted twice
@@ -687,11 +689,28 @@ class Util {
// Open enc file handle for binary reading
$encHandle = fopen('crypt://' . $rawPath, 'rb');
+ if ($encHandle === false) {
+ \OCP\Util::writeLog('Encryption library', 'couldn\'t open "' . $rawPath . '", decryption failed!', \OCP\Util::FATAL);
+ $successful = false;
+ continue;
+ }
+
// Open plain file handle for binary writing, with same filename as original plain file
$plainHandle = $this->view->fopen($rawPath . '.part', 'wb');
+ if ($plainHandle === false) {
+ \OCP\Util::writeLog('Encryption library', 'couldn\'t open "' . $rawPath . '.part", decryption failed!', \OCP\Util::FATAL);
+ $successful = false;
+ continue;
+ }
// Move plain file to a temporary location
$size = stream_copy_to_stream($encHandle, $plainHandle);
+ if ($size === 0) {
+ \OCP\Util::writeLog('Encryption library', 'Zero bytes copied of "' . $rawPath . '", decryption failed!', \OCP\Util::FATAL);
+ $successful = false;
+ continue;
+ }
+
fclose($encHandle);
fclose($plainHandle);
@@ -711,18 +730,15 @@ class Util {
));
}
- $this->view->deleteAll($this->keyfilesPath);
- $this->view->deleteAll($this->shareKeysPath);
+ if ($successful) {
+ $this->view->deleteAll($this->keyfilesPath);
+ $this->view->deleteAll($this->shareKeysPath);
+ }
\OC_FileProxy::$enabled = true;
-
- // If files were found, return true
- return true;
- } else {
-
- // If no files were found, return false
- return false;
}
+
+ return $successful;
}
/**
diff --git a/settings/ajax/decryptall.php b/settings/ajax/decryptall.php
index 7adacb9802a..e53067931e8 100644
--- a/settings/ajax/decryptall.php
+++ b/settings/ajax/decryptall.php
@@ -1,5 +1,5 @@
<?php
-sleep(10);
+
//encryption app needs to be loaded
OC_App::loadApp('files_encryption');
@@ -13,9 +13,13 @@ $util = new \OCA\Encryption\Util($view, \OCP\User::getUser());
$result = $util->initEncryption($params);
if ($result !== false) {
- $util->decryptAll();
- \OCP\JSON::success(array('data' => array('message' => 'Files decrypted successfully')));
+ $successful = $util->decryptAll();
+ if ($successful === true) {
+ \OCP\JSON::success(array('data' => array('message' => 'Files decrypted successfully')));
+ } else {
+ \OCP\JSON::error(array('data' => array('message' => 'Couldn\'t decrypt your files, please check your owncloud.log or ask your administrator')));
+ }
} else {
- \OCP\JSON::error(array('data' => array('message' => 'Couldn\'t decrypt files, check your password and try again')));
+ \OCP\JSON::error(array('data' => array('message' => 'Couldn\'t decrypt your files, check your password and try again')));
}