diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2015-04-07 18:05:54 +0200 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2015-04-16 14:15:04 +0200 |
commit | e3d77c4b0181e2219f30f720ac7077b334210f5d (patch) | |
tree | 8d2042de13e0ff8036b92c2040e64c5774e2e6be /lib/private/encryption/manager.php | |
parent | 1a894bd0d8ab034f35dbb3b723dd195e7f66aab4 (diff) | |
download | nextcloud-server-e3d77c4b0181e2219f30f720ac7077b334210f5d.tar.gz nextcloud-server-e3d77c4b0181e2219f30f720ac7077b334210f5d.zip |
add migration script from old encryption to new one
Diffstat (limited to 'lib/private/encryption/manager.php')
-rw-r--r-- | lib/private/encryption/manager.php | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/lib/private/encryption/manager.php b/lib/private/encryption/manager.php index 74cad0a75bb..45c98baede3 100644 --- a/lib/private/encryption/manager.php +++ b/lib/private/encryption/manager.php @@ -22,24 +22,34 @@ namespace OC\Encryption; +use OC\Files\Storage\Shared; use OC\Files\Storage\Wrapper\Encryption; +use OC\Files\View; use OCP\Encryption\IEncryptionModule; +use OCP\Encryption\IManager; use OCP\Files\Mount\IMountPoint; +use OCP\IConfig; +use OCP\ILogger; -class Manager implements \OCP\Encryption\IManager { +class Manager implements IManager { /** @var array */ protected $encryptionModules; - /** @var \OCP\IConfig */ + /** @var IConfig */ protected $config; + /** @var ILogger */ + protected $logger; + /** - * @param \OCP\IConfig $config + * @param IConfig $config + * @param ILogger $logger */ - public function __construct(\OCP\IConfig $config) { + public function __construct(IConfig $config, ILogger $logger) { $this->encryptionModules = array(); $this->config = $config; + $this->logger = $logger; } /** @@ -59,6 +69,24 @@ class Manager implements \OCP\Encryption\IManager { } /** + * check if new encryption is ready + * + * @return boolean + */ + public function isReady() { + // check if we are still in transit between the old and the new encryption + $oldEncryption = $this->config->getAppValue('files_encryption', 'installed_version'); + if (!empty($oldEncryption)) { + $warning = 'Installation is in transit between the old Encryption (ownCloud <= 8.0) + and the new encryption. Please enable the "ownCloud Default Encryption Module" + and run \'occ encryption:migrate\''; + $this->logger->warning($warning); + return false; + } + return true; + } + + /** * Registers an encryption module * * @param IEncryptionModule $module @@ -185,10 +213,10 @@ class Manager implements \OCP\Encryption\IManager { 'mountPoint' => $mountPoint, 'mount' => $mount]; - if (!($storage instanceof \OC\Files\Storage\Shared)) { + if (!($storage instanceof Shared)) { $manager = \OC::$server->getEncryptionManager(); - $util = new \OC\Encryption\Util( - new \OC\Files\View(), \OC::$server->getUserManager(), \OC::$server->getConfig()); + $util = new Util( + new View(), \OC::$server->getUserManager(), \OC::$server->getConfig()); $user = \OC::$server->getUserSession()->getUser(); $logger = \OC::$server->getLogger(); $uid = $user ? $user->getUID() : null; |