Setting up the encryption wrapper in a setup hook - temporarily fixes the wrapping order

This commit is contained in:
Thomas Müller 2015-03-31 13:25:11 +02:00
parent 3458b5ab4c
commit 4db75e3407
2 changed files with 20 additions and 18 deletions

View File

@ -703,24 +703,8 @@ class OC {
private static function registerEncryptionWrapper() { private static function registerEncryptionWrapper() {
$enabled = self::$server->getEncryptionManager()->isEnabled(); $enabled = self::$server->getEncryptionManager()->isEnabled();
if ($enabled) { if ($enabled) {
\OC\Files\Filesystem::addStorageWrapper('oc_encryption', function ($mountPoint, $storage, \OCP\Files\Mount\IMountPoint $mount) { \OCP\Util::connectHook('OC_Filesystem', 'setup', 'OC\Encryption\Manager', 'setupStorage');
$parameters = [
'storage' => $storage,
'mountPoint' => $mountPoint,
'mount' => $mount];
$manager = \OC::$server->getEncryptionManager();
$util = new \OC\Encryption\Util(
new \OC\Files\View(),
\OC::$server->getUserManager(),
\OC::$server->getConfig());
$user = \OC::$server->getUserSession()->getUser();
$logger = \OC::$server->getLogger();
$uid = $user ? $user->getUID() : null;
return new \OC\Files\Storage\Wrapper\Encryption($parameters, $manager, $util, $logger, $uid);
});
} }
} }
private static function registerEncryptionHooks() { private static function registerEncryptionHooks() {

View File

@ -23,7 +23,9 @@
namespace OC\Encryption; namespace OC\Encryption;
use OC\Files\Storage\Wrapper\Encryption;
use OCP\Encryption\IEncryptionModule; use OCP\Encryption\IEncryptionModule;
use OCP\Files\Mount\IMountPoint;
class Manager implements \OCP\Encryption\IManager { class Manager implements \OCP\Encryption\IManager {
@ -181,5 +183,21 @@ class Manager implements \OCP\Encryption\IManager {
} }
} }
public static function setupStorage() {
\OC\Files\Filesystem::addStorageWrapper('oc_encryption', function ($mountPoint, $storage, IMountPoint $mount) {
$parameters = [
'storage' => $storage,
'mountPoint' => $mountPoint,
'mount' => $mount];
$manager = \OC::$server->getEncryptionManager();
$util = new \OC\Encryption\Util(
new \OC\Files\View(),
\OC::$server->getUserManager(),
\OC::$server->getConfig());
$user = \OC::$server->getUserSession()->getUser();
$logger = \OC::$server->getLogger();
$uid = $user ? $user->getUID() : null;
return new Encryption($parameters, $manager, $util, $logger, $uid);
});
}
} }