diff --git a/config/configuration.sample.yml b/config/configuration.sample.yml index 9bbea0d4bc..a912e61876 100644 --- a/config/configuration.sample.yml +++ b/config/configuration.sample.yml @@ -111,7 +111,7 @@ main: download: null lazaret: null caption: null - tmp_files: null + worker_tmp_files: null border-manager: enabled: true extension-mapping: diff --git a/lib/Alchemy/Phrasea/Command/Setup/Install.php b/lib/Alchemy/Phrasea/Command/Setup/Install.php index 8e211a9284..24eb8b64a2 100644 --- a/lib/Alchemy/Phrasea/Command/Setup/Install.php +++ b/lib/Alchemy/Phrasea/Command/Setup/Install.php @@ -55,6 +55,11 @@ class Install extends Command ->addOption('es-host', null, InputOption::VALUE_OPTIONAL, 'ElasticSearch server HTTP host', 'localhost') ->addOption('es-port', null, InputOption::VALUE_OPTIONAL, 'ElasticSearch server HTTP port', 9200) ->addOption('es-index', null, InputOption::VALUE_OPTIONAL, 'ElasticSearch index name', null) + ->addOption('download-path', null, InputOption::VALUE_OPTIONAL, 'Path to download repository', '/var/alchemy/Phraseanet/tmp/download') + ->addOption('lazaret-path', null, InputOption::VALUE_OPTIONAL, 'Path to lazaret repository', '/var/alchemy/Phraseanet/tmp/lazaret') + ->addOption('caption-path', null, InputOption::VALUE_OPTIONAL, 'Path to caption repository', '/var/alchemy/Phraseanet/tmp/caption') + ->addOption('scheduler-locks-path', null, InputOption::VALUE_OPTIONAL, 'Path to scheduler-locks repository', '/var/alchemy/Phraseanet/tmp/locks') + ->addOption('worker-tmp-files', null, InputOption::VALUE_OPTIONAL, 'Path to worker-tmp-files repository', '/var/alchemy/Phraseanet/tmp') ->addOption('yes', 'y', InputOption::VALUE_NONE, 'Answer yes to all questions'); return $this; @@ -151,6 +156,7 @@ class Install extends Command $this->container['phraseanet.installer']->install($email, $password, $abConn, $serverName, $dataPath, $dbConn, $templateName, $this->detectBinaries()); $this->container['conf']->set(['main', 'search-engine', 'options'], $esOptions->toArray()); + $this->defineStorageTmpPath($input); if (null !== $this->getApplication()) { $command = $this->getApplication()->find('crossdomain:generate'); @@ -387,6 +393,53 @@ class Install extends Command return $index; } + private function defineStorageTmpPath(InputInterface $input) + { + $downloadPath = $input->getOption('download-path'); + + if (!is_dir($downloadPath)) { + mkdir($downloadPath, 0755, true); + } + + $lazaretPath = $input->getOption('lazaret-path'); + + if (!is_dir($lazaretPath)) { + mkdir($lazaretPath, 0755, true); + } + + $captionPath = $input->getOption('caption-path'); + + if (!is_dir($captionPath)) { + mkdir($captionPath, 0755, true); + } + + $workerTmpFiles = $input->getOption('worker-tmp-files'); + + if (!is_dir($workerTmpFiles)) { + mkdir($workerTmpFiles, 0755, true); + } + + + $schedulerLocksPath = $input->getOption('scheduler-locks-path'); + + if (!is_dir($schedulerLocksPath)) { + mkdir($schedulerLocksPath, 0755, true); + } + + if (($schedulerLocksPath = realpath($schedulerLocksPath)) === FALSE) { + throw new \InvalidArgumentException(sprintf('Path %s does not exist.', $schedulerLocksPath)); + } + + $config = $this->container['configuration.store']->initialize()->getConfig(); + + $config['main']['storage']['download'] = realpath($downloadPath); + $config['main']['storage']['lazaret'] = realpath($lazaretPath); + $config['main']['storage']['caption'] = realpath($captionPath); + $config['main']['storage']['worker_tmp_files'] = realpath($workerTmpFiles); + + $this->container['configuration.store']->setConfig($config); + } + private function detectBinaries() { return [ diff --git a/lib/Alchemy/Phrasea/Controller/Prod/UploadController.php b/lib/Alchemy/Phrasea/Controller/Prod/UploadController.php index 27d18d5473..15cadafa52 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/UploadController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/UploadController.php @@ -181,8 +181,8 @@ class UploadController extends Controller $uploadedFilename = $file->getRealPath(); $renamedFilename = null; - if(!empty($this->app['conf']->get(['main', 'storage', 'tmp_files']))) { - $tmpStorage = \p4string::addEndSlash($this->app['conf']->get(['main', 'storage', 'tmp_files'])).'upload/'; + if(!empty($this->app['conf']->get(['main', 'storage', 'worker_tmp_files']))) { + $tmpStorage = \p4string::addEndSlash($this->app['conf']->get(['main', 'storage', 'worker_tmp_files'])).'upload/'; if(!is_dir($tmpStorage)){ $this->getFilesystem()->mkdir($tmpStorage); diff --git a/lib/Alchemy/Phrasea/Media/SubdefGenerator.php b/lib/Alchemy/Phrasea/Media/SubdefGenerator.php index 9612e3bc19..b6ebba31f3 100644 --- a/lib/Alchemy/Phrasea/Media/SubdefGenerator.php +++ b/lib/Alchemy/Phrasea/Media/SubdefGenerator.php @@ -57,7 +57,7 @@ class SubdefGenerator $this->filesystem = $filesystem; $this->logger = $logger; $this->mediavorus = $mediavorus; - $this->tmpDirectory = $this->app['conf']->get(['main', 'storage', 'tmp_files']);; + $this->tmpDirectory = $this->app['conf']->get(['main', 'storage', 'worker_tmp_files']);; } public function generateSubdefs(\record_adapter $record, array $wanted_subdefs = null) diff --git a/lib/Alchemy/Phrasea/Setup/Installer.php b/lib/Alchemy/Phrasea/Setup/Installer.php index 9c750d6cc7..d9e6fd404a 100644 --- a/lib/Alchemy/Phrasea/Setup/Installer.php +++ b/lib/Alchemy/Phrasea/Setup/Installer.php @@ -211,9 +211,6 @@ class Installer $config['main']['storage']['cache'] = realpath(__DIR__ . '/../../../../cache'); $config['main']['storage']['log'] = realpath(__DIR__ . '/../../../../logs'); - $config['main']['storage']['download'] = realpath(__DIR__ . '/../../../../tmp/download'); - $config['main']['storage']['lazaret'] = realpath(__DIR__ . '/../../../../tmp/lazaret'); - $config['main']['storage']['caption'] = realpath(__DIR__ . '/../../../../tmp/caption'); $config['registry'] = $this->app['registry.manipulator']->getRegistryData(); diff --git a/lib/conf.d/configuration.yml b/lib/conf.d/configuration.yml index f237b8318f..bcb496eb31 100644 --- a/lib/conf.d/configuration.yml +++ b/lib/conf.d/configuration.yml @@ -111,7 +111,7 @@ main: download: null lazaret: null caption: null - tmp_files: null + worker_tmp_files: null trusted-proxies: [] debugger: