summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBjörn Schießle <bjoern@schiessle.org>2013-08-18 09:51:48 -0700
committerBjörn Schießle <bjoern@schiessle.org>2013-08-18 09:51:48 -0700
commit9be836814cb4165ea54a086a0f97526d783bcd37 (patch)
treead57d30194571edcf0f51cd83178b8ac2f03c0aa /lib
parentc620c5840ab8ca45531c7639e086bafbd87d7365 (diff)
parentd544a371bfb84f36a3b789d19d44d6694de21c48 (diff)
downloadnextcloud-server-9be836814cb4165ea54a086a0f97526d783bcd37.tar.gz
nextcloud-server-9be836814cb4165ea54a086a0f97526d783bcd37.zip
Merge pull request #4239 from owncloud/decrypt_files_again
Enable user to decrypt files again after encryption app was disabled
Diffstat (limited to 'lib')
-rw-r--r--lib/connector/sabre/file.php12
-rw-r--r--lib/public/util.php8
-rwxr-xr-xlib/util.php17
3 files changed, 36 insertions, 1 deletions
diff --git a/lib/connector/sabre/file.php b/lib/connector/sabre/file.php
index 06ab73e3e4d..61bdcd5e0ae 100644
--- a/lib/connector/sabre/file.php
+++ b/lib/connector/sabre/file.php
@@ -50,6 +50,11 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
throw new \Sabre_DAV_Exception_Forbidden();
}
+ // throw an exception if encryption was disabled but the files are still encrypted
+ if (\OC_Util::encryptedFiles()) {
+ throw new \Sabre_DAV_Exception_ServiceUnavailable();
+ }
+
// mark file as partial while uploading (ignored by the scanner)
$partpath = $this->path . '.part';
@@ -89,7 +94,12 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
*/
public function get() {
- return \OC\Files\Filesystem::fopen($this->path, 'rb');
+ //throw execption if encryption is disabled but files are still encrypted
+ if (\OC_Util::encryptedFiles()) {
+ throw new \Sabre_DAV_Exception_ServiceUnavailable();
+ } else {
+ return \OC\Files\Filesystem::fopen($this->path, 'rb');
+ }
}
diff --git a/lib/public/util.php b/lib/public/util.php
index 693805946ea..b33f07b55e6 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -123,6 +123,14 @@ class Util {
}
/**
+ * @brief check if some encrypted files are stored
+ * @return bool
+ */
+ public static function encryptedFiles() {
+ return \OC_Util::encryptedFiles();
+ }
+
+ /**
* @brief Creates an absolute url
* @param string $app app
* @param string $file file
diff --git a/lib/util.php b/lib/util.php
index 25632ac1ea2..d1752ecba0a 100755
--- a/lib/util.php
+++ b/lib/util.php
@@ -320,6 +320,23 @@ class OC_Util {
}
/**
+ * @brief check if there are still some encrypted files stored
+ * @return boolean
+ */
+ public static function encryptedFiles() {
+ //check if encryption was enabled in the past
+ $encryptedFiles = false;
+ if (OC_App::isEnabled('files_encryption') === false) {
+ $view = new OC\Files\View('/' . OCP\User::getUser());
+ if ($view->file_exists('/files_encryption/keyfiles')) {
+ $encryptedFiles = true;
+ }
+ }
+
+ return $encryptedFiles;
+ }
+
+ /**
* Check for correct file permissions of data directory
* @return array arrays with error messages and hints
*/