/** * @param View $view * @param Util $util */ public function __construct(View $view, Util $util) { $this->view = $view; $this->util = $util; $this->encryption_base_dir = '/files_encryption'; $this->keys_base_dir = $this->encryption_base_dir . '/keys'; $this->root_dir = $this->util->getKeyStorageRoot(); }
protected function execute(InputInterface $input, OutputInterface $output) { $oldRoot = $this->util->getKeyStorageRoot(); $newRoot = $input->getArgument('newRoot'); if ($newRoot === null) { $question = new ConfirmationQuestion('No storage root given, do you want to reset the key storage root to the default location? (y/n) ', false); if (!$this->questionHelper->ask($input, $output, $question)) { return; } $newRoot = ''; } $oldRootDescription = $oldRoot !== '' ? $oldRoot : 'default storage location'; $newRootDescription = $newRoot !== '' ? $newRoot : 'default storage location'; $output->writeln("Change key storage root from <info>{$oldRootDescription}</info> to <info>{$newRootDescription}</info>"); $success = $this->moveAllKeys($oldRoot, $newRoot, $output); if ($success) { $this->util->setKeyStorageRoot($newRoot); $output->writeln(''); $output->writeln("Key storage root successfully changed to <info>{$newRootDescription}</info>"); } }
/** * check if key storage is ready * * @return bool */ protected function isKeyStorageReady() { $rootDir = $this->util->getKeyStorageRoot(); // the default root is always valid if ($rootDir === '') { return true; } // check if key storage is mounted correctly if ($this->rootView->file_exists($rootDir . '/' . Storage::KEY_STORAGE_MARKER)) { return true; } return false; }
protected function execute(InputInterface $input, OutputInterface $output) { $currentRoot = $this->util->getKeyStorageRoot(); $rootDescription = $currentRoot !== '' ? $currentRoot : 'default storage location (data/)'; $output->writeln("Current key storage root: <info>{$rootDescription}</info>"); }