From c4aef892788ced15812cc31abcf34c085b66ce5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Thu, 27 Jun 2013 14:09:22 +0200 Subject: [PATCH 1/2] introduce pre-disable-app hook and use it for the encryption app to reset migration status if the app was disabled --- apps/files_encryption/appinfo/app.php | 3 +++ apps/files_encryption/hooks/hooks.php | 13 +++++++++++++ apps/files_encryption/lib/helper.php | 9 +++++++++ lib/app.php | 1 + 4 files changed, 26 insertions(+) diff --git a/apps/files_encryption/appinfo/app.php b/apps/files_encryption/appinfo/app.php index d97811bb79..ca3f2554e5 100644 --- a/apps/files_encryption/appinfo/app.php +++ b/apps/files_encryption/appinfo/app.php @@ -22,6 +22,9 @@ if (!OC_Config::getValue('maintenance', false)) { // Filesystem related hooks OCA\Encryption\Helper::registerFilesystemHooks(); + // App manager related hooks + OCA\Encryption\Helper::registerAppHooks(); + stream_wrapper_register('crypt', 'OCA\Encryption\Stream'); // check if we are logged in diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php index e39e068cc5..0915391894 100644 --- a/apps/files_encryption/hooks/hooks.php +++ b/apps/files_encryption/hooks/hooks.php @@ -543,4 +543,17 @@ class Hooks { \OC_FileProxy::$enabled = $proxyStatus; } + + /** + * set migration status back to '0' so that all new files get encrypted + * if the app gets enabled again + * @param array $params contains the app ID + */ + public static function preDisable($params) { + if ($params['app'] === 'files_encryption') { + $query = \OC_DB::prepare('UPDATE `*PREFIX*encryption` SET `migration_status`=0'); + $query->execute(); + } + } + } diff --git a/apps/files_encryption/lib/helper.php b/apps/files_encryption/lib/helper.php index a22c139c50..b2045bfcea 100755 --- a/apps/files_encryption/lib/helper.php +++ b/apps/files_encryption/lib/helper.php @@ -62,6 +62,15 @@ class Helper { \OCP\Util::connectHook('OC_Filesystem', 'post_rename', 'OCA\Encryption\Hooks', 'postRename'); } + /** + * @brief register filesystem related hooks + * + */ + public static function registerAppHooks() { + + \OCP\Util::connectHook('OC_App', 'pre_disable', 'OCA\Encryption\Hooks', 'preDisable'); + } + /** * @brief setup user for files_encryption * diff --git a/lib/app.php b/lib/app.php index f974dd9f59..f9b1c5ca7b 100644 --- a/lib/app.php +++ b/lib/app.php @@ -259,6 +259,7 @@ class OC_App{ */ public static function disable( $app ) { // check if app is a shipped app or not. if not delete + \OC_Hook::emit('OC_App', 'pre_disable', array('app' => $app)); OC_Appconfig::setValue( $app, 'enabled', 'no' ); // check if app is a shipped app or not. if not delete From 2e6ebe1ab4e1ae6d0fb730e833c09ac4dbbb895c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Thu, 27 Jun 2013 14:14:25 +0200 Subject: [PATCH 2/2] fix function documentation --- apps/files_encryption/lib/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files_encryption/lib/helper.php b/apps/files_encryption/lib/helper.php index b2045bfcea..0d30dd8e7b 100755 --- a/apps/files_encryption/lib/helper.php +++ b/apps/files_encryption/lib/helper.php @@ -63,7 +63,7 @@ class Helper { } /** - * @brief register filesystem related hooks + * @brief register app management related hooks * */ public static function registerAppHooks() {