Merge pull request #3870 from owncloud/reset_migration_status

introduce pre-disable-app hook and first usage in files_encryption
This commit is contained in:
Björn Schießle 2013-07-02 07:26:48 -07:00
commit 4d4484fac1
4 changed files with 26 additions and 0 deletions

View 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

View File

@ -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();
}
}
}

View File

@ -62,6 +62,15 @@ class Helper {
\OCP\Util::connectHook('OC_Filesystem', 'post_rename', 'OCA\Encryption\Hooks', 'postRename');
}
/**
* @brief register app management related hooks
*
*/
public static function registerAppHooks() {
\OCP\Util::connectHook('OC_App', 'pre_disable', 'OCA\Encryption\Hooks', 'preDisable');
}
/**
* @brief setup user for files_encryption
*

View 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