Commit 6337b633 authored by Roman Ondráček's avatar Roman Ondráček

Config: add cache directory permissions workaround

Signed-off-by: Roman Ondráček's avatarRoman Ondráček <ondracek.roman@centrum.cz>
parent 3b9a1619
Pipeline #2323 passed with stages
in 15 minutes and 15 seconds
......@@ -81,7 +81,11 @@ class SchedulerManager {
$this->genericConfigManager = $genericManager;
$this->serviceManager = $serviceManager;
$this->timeManager = $timeManager;
$path = $mainManager->getCacheDir() . '/scheduler/';
$cacheDir = $mainManager->getCacheDir();
if (!is_readable($cacheDir) || !is_writable($cacheDir)) {
$commandManager->run('chmod 777 ' . $cacheDir, true);
}
$path = $cacheDir . '/scheduler/';
$this->fileManager = new JsonFileManager($path, $commandManager);
$this->schemaManager = $schemaManager;
}
......
......@@ -21,6 +21,7 @@ declare(strict_types = 1);
namespace App\ConfigModule\Models;
use App\ConfigModule\Exceptions\InvalidConfigurationFormatException;
use App\CoreModule\Models\CommandManager;
use App\CoreModule\Models\ZipArchiveManager;
use App\ServiceModule\Exceptions\NotSupportedInitSystemException;
use App\ServiceModule\Models\ServiceManager;
......@@ -64,9 +65,14 @@ class SchedulerMigrationManager {
* @param MainManager $mainManager Main configuration manager
* @param ServiceManager $serviceManager Service manager
* @param SchedulerSchemaManager $schemaManager Scheduler JSON schema manager
* @param CommandManager $commandManager Command
*/
public function __construct(MainManager $mainManager, ServiceManager $serviceManager, SchedulerSchemaManager $schemaManager) {
$this->configDirectory = $mainManager->getCacheDir() . '/scheduler/';
public function __construct(MainManager $mainManager, ServiceManager $serviceManager, SchedulerSchemaManager $schemaManager, CommandManager $commandManager) {
$cacheDir = $mainManager->getCacheDir();
if (!is_readable($cacheDir) || !is_writable($cacheDir)) {
$commandManager->run('chmod 777 ' . $cacheDir, true);
}
$this->configDirectory = $cacheDir . '/scheduler/';
$this->serviceManager = $serviceManager;
$this->schemaManager = $schemaManager;
}
......
......@@ -44,7 +44,11 @@ class SchedulerSchemaManager extends JsonSchemaManager {
* @param ApiSchemaManager $apiSchemaManager JSON API JSON schema manager
*/
public function __construct(MainManager $mainManager, CommandManager $commandManager, ApiSchemaManager $apiSchemaManager) {
$configDir = $mainManager->getCacheDir() . '/scheduler/schema/';
$cacheDir = $mainManager->getCacheDir();
if (!is_readable($cacheDir) || !is_writable($cacheDir)) {
$commandManager->run('chmod 777 ' . $cacheDir, true);
}
$configDir = $cacheDir . '/scheduler/schema/';
parent::__construct($configDir, $commandManager);
$this->apiSchemaManager = $apiSchemaManager;
}
......
......@@ -79,7 +79,11 @@ class FileManager {
* @return bool Is file exists?
*/
public function exists(string $fileName): bool {
return file_exists($this->directory . '/' . $fileName);
$path = $this->directory . '/' . $fileName;
if (!is_readable($this->directory) || !is_readable($path)) {
$this->fixPermissions($fileName);
}
return file_exists($path);
}
/**
......
......@@ -140,7 +140,8 @@ class SchedulerMigrationManagerTest extends TestCase {
$serviceManager->shouldReceive('restart');
$schemaManager = Mockery::mock(SchedulerSchemaManager::class);
$schemaManager->shouldReceive('validate')->andReturn(true);
$this->manager = new SchedulerMigrationManager($mainConfigManager, $serviceManager, $schemaManager);
$commandManager = Mockery::mock(CommandManager::class);
$this->manager = new SchedulerMigrationManager($mainConfigManager, $serviceManager, $schemaManager, $commandManager);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment