Completed
Push — master ( 55df84...5979f4 )
by Morris
197:16 queued 182:24
created
core/Command/Encryption/EncryptAll.php 1 patch
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -34,102 +34,102 @@
 block discarded – undo
34 34
 
35 35
 class EncryptAll extends Command {
36 36
 
37
-	/** @var IManager */
38
-	protected $encryptionManager;
39
-
40
-	/** @var  IAppManager */
41
-	protected $appManager;
42
-
43
-	/** @var IConfig */
44
-	protected $config;
45
-
46
-	/** @var  QuestionHelper */
47
-	protected $questionHelper;
48
-
49
-	/** @var bool */
50
-	protected $wasTrashbinEnabled;
51
-
52
-	/** @var  bool */
53
-	protected $wasMaintenanceModeEnabled;
54
-
55
-	/**
56
-	 * @param IManager $encryptionManager
57
-	 * @param IAppManager $appManager
58
-	 * @param IConfig $config
59
-	 * @param QuestionHelper $questionHelper
60
-	 */
61
-	public function __construct(
62
-		IManager $encryptionManager,
63
-		IAppManager $appManager,
64
-		IConfig $config,
65
-		QuestionHelper $questionHelper
66
-	) {
67
-		parent::__construct();
68
-		$this->appManager = $appManager;
69
-		$this->encryptionManager = $encryptionManager;
70
-		$this->config = $config;
71
-		$this->questionHelper = $questionHelper;
72
-	}
73
-
74
-	/**
75
-	 * Set maintenance mode and disable the trashbin app
76
-	 */
77
-	protected function forceMaintenanceAndTrashbin() {
78
-		$this->wasTrashbinEnabled = $this->appManager->isEnabledForUser('files_trashbin');
79
-		$this->wasMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false);
80
-		$this->config->setSystemValue('maintenance', true);
81
-		$this->appManager->disableApp('files_trashbin');
82
-	}
83
-
84
-	/**
85
-	 * Reset the maintenance mode and re-enable the trashbin app
86
-	 */
87
-	protected function resetMaintenanceAndTrashbin() {
88
-		$this->config->setSystemValue('maintenance', $this->wasMaintenanceModeEnabled);
89
-		if ($this->wasTrashbinEnabled) {
90
-			$this->appManager->enableApp('files_trashbin');
91
-		}
92
-	}
93
-
94
-	protected function configure() {
95
-		parent::configure();
96
-
97
-		$this->setName('encryption:encrypt-all');
98
-		$this->setDescription('Encrypt all files for all users');
99
-		$this->setHelp(
100
-			'This will encrypt all files for all users. '
101
-			. 'Please make sure that no user access his files during this process!'
102
-		);
103
-	}
104
-
105
-	protected function execute(InputInterface $input, OutputInterface $output) {
106
-
107
-		if ($this->encryptionManager->isEnabled() === false) {
108
-			throw new \Exception('Server side encryption is not enabled');
109
-		}
110
-
111
-		$output->writeln("\n");
112
-		$output->writeln('You are about to encrypt all files stored in your Nextcloud installation.');
113
-		$output->writeln('Depending on the number of available files, and their size, this may take quite some time.');
114
-		$output->writeln('Please ensure that no user accesses their files during this time!');
115
-		$output->writeln('Note: The encryption module you use determines which files get encrypted.');
116
-		$output->writeln('');
117
-		$question = new ConfirmationQuestion('Do you really want to continue? (y/n) ', false);
118
-		if ($this->questionHelper->ask($input, $output, $question)) {
119
-			$this->forceMaintenanceAndTrashbin();
120
-
121
-			try {
122
-				$defaultModule = $this->encryptionManager->getEncryptionModule();
123
-				$defaultModule->encryptAll($input, $output);
124
-			} catch (\Exception $ex) {
125
-				$this->resetMaintenanceAndTrashbin();
126
-				throw $ex;
127
-			}
128
-
129
-			$this->resetMaintenanceAndTrashbin();
130
-		} else {
131
-			$output->writeln('aborted');
132
-		}
133
-	}
37
+    /** @var IManager */
38
+    protected $encryptionManager;
39
+
40
+    /** @var  IAppManager */
41
+    protected $appManager;
42
+
43
+    /** @var IConfig */
44
+    protected $config;
45
+
46
+    /** @var  QuestionHelper */
47
+    protected $questionHelper;
48
+
49
+    /** @var bool */
50
+    protected $wasTrashbinEnabled;
51
+
52
+    /** @var  bool */
53
+    protected $wasMaintenanceModeEnabled;
54
+
55
+    /**
56
+     * @param IManager $encryptionManager
57
+     * @param IAppManager $appManager
58
+     * @param IConfig $config
59
+     * @param QuestionHelper $questionHelper
60
+     */
61
+    public function __construct(
62
+        IManager $encryptionManager,
63
+        IAppManager $appManager,
64
+        IConfig $config,
65
+        QuestionHelper $questionHelper
66
+    ) {
67
+        parent::__construct();
68
+        $this->appManager = $appManager;
69
+        $this->encryptionManager = $encryptionManager;
70
+        $this->config = $config;
71
+        $this->questionHelper = $questionHelper;
72
+    }
73
+
74
+    /**
75
+     * Set maintenance mode and disable the trashbin app
76
+     */
77
+    protected function forceMaintenanceAndTrashbin() {
78
+        $this->wasTrashbinEnabled = $this->appManager->isEnabledForUser('files_trashbin');
79
+        $this->wasMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false);
80
+        $this->config->setSystemValue('maintenance', true);
81
+        $this->appManager->disableApp('files_trashbin');
82
+    }
83
+
84
+    /**
85
+     * Reset the maintenance mode and re-enable the trashbin app
86
+     */
87
+    protected function resetMaintenanceAndTrashbin() {
88
+        $this->config->setSystemValue('maintenance', $this->wasMaintenanceModeEnabled);
89
+        if ($this->wasTrashbinEnabled) {
90
+            $this->appManager->enableApp('files_trashbin');
91
+        }
92
+    }
93
+
94
+    protected function configure() {
95
+        parent::configure();
96
+
97
+        $this->setName('encryption:encrypt-all');
98
+        $this->setDescription('Encrypt all files for all users');
99
+        $this->setHelp(
100
+            'This will encrypt all files for all users. '
101
+            . 'Please make sure that no user access his files during this process!'
102
+        );
103
+    }
104
+
105
+    protected function execute(InputInterface $input, OutputInterface $output) {
106
+
107
+        if ($this->encryptionManager->isEnabled() === false) {
108
+            throw new \Exception('Server side encryption is not enabled');
109
+        }
110
+
111
+        $output->writeln("\n");
112
+        $output->writeln('You are about to encrypt all files stored in your Nextcloud installation.');
113
+        $output->writeln('Depending on the number of available files, and their size, this may take quite some time.');
114
+        $output->writeln('Please ensure that no user accesses their files during this time!');
115
+        $output->writeln('Note: The encryption module you use determines which files get encrypted.');
116
+        $output->writeln('');
117
+        $question = new ConfirmationQuestion('Do you really want to continue? (y/n) ', false);
118
+        if ($this->questionHelper->ask($input, $output, $question)) {
119
+            $this->forceMaintenanceAndTrashbin();
120
+
121
+            try {
122
+                $defaultModule = $this->encryptionManager->getEncryptionModule();
123
+                $defaultModule->encryptAll($input, $output);
124
+            } catch (\Exception $ex) {
125
+                $this->resetMaintenanceAndTrashbin();
126
+                throw $ex;
127
+            }
128
+
129
+            $this->resetMaintenanceAndTrashbin();
130
+        } else {
131
+            $output->writeln('aborted');
132
+        }
133
+    }
134 134
 
135 135
 }
Please login to merge, or discard this patch.