]> source.dussan.org Git - nextcloud-server.git/commitdiff
introduce pre-disable-app hook and use it for the encryption app to reset migration...
authorBjörn Schießle <schiessle@owncloud.com>
Thu, 27 Jun 2013 12:09:22 +0000 (14:09 +0200)
committerBjörn Schießle <schiessle@owncloud.com>
Tue, 2 Jul 2013 14:28:27 +0000 (16:28 +0200)
apps/files_encryption/appinfo/app.php
apps/files_encryption/hooks/hooks.php
apps/files_encryption/lib/helper.php
lib/app.php

index 80c04bb0cd2256d53fe6a9dc5e3eec252cabb838..aee49b23c3f8795179ecad6f7a15f69e34aff587 100644 (file)
@@ -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
index e39e068cc5d341897c5621a142262c8e8974e767..091539189405be2bc8953d8992953c93cf899b52 100644 (file)
@@ -543,4 +543,17 @@ class Hooks {
 \r
                \OC_FileProxy::$enabled = $proxyStatus;\r
        }\r
+\r
+       /**\r
+        * set migration status back to '0' so that all new files get encrypted\r
+        * if the app gets enabled again\r
+        * @param array $params contains the app ID\r
+        */\r
+       public static function preDisable($params) {\r
+               if ($params['app'] === 'files_encryption') {\r
+                       $query = \OC_DB::prepare('UPDATE `*PREFIX*encryption` SET `migration_status`=0');\r
+                       $query->execute();\r
+               }\r
+       }\r
+\r
 }\r
index a22c139c503cb694f859e5efec633f3f9d8423c5..b2045bfcea830a1868d833f460b10c47f87d659e 100755 (executable)
@@ -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
         *
index 2f20256c8cf43d0989608118c5137d77839523dd..908405fe3a70ca53b571931efad744ff35e2345d 100644 (file)
@@ -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