|
|
@@ -1781,10 +1781,11 @@ class SiteController extends ActionController
|
|
|
if (!$commitSuccess) {
|
|
|
throw new \RuntimeException('Something went wrong while committing the result');
|
|
|
}
|
|
|
+ $this->rrmdir($backupConfigDir);
|
|
|
}
|
|
|
catch (\Throwable $e) {
|
|
|
// rollback
|
|
|
- rmdir($configRootDir);
|
|
|
+ $this->rrmdir($configRootDir);
|
|
|
rename($backupConfigDir, $configRootDir);
|
|
|
$this->connectionPool->getConnectionByName('Default')->rollback();
|
|
|
throw $e;
|
|
|
@@ -2186,6 +2187,21 @@ class SiteController extends ActionController
|
|
|
return $identifier;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Recursively remove the target directory (! no rollback available)
|
|
|
+ */
|
|
|
+ private function rrmdir(string $dir) {
|
|
|
+ if (!is_dir($dir) || is_link($dir)) return unlink($dir);
|
|
|
+ foreach (scandir($dir) as $file) {
|
|
|
+ if ($file == '.' || $file == '..') continue;
|
|
|
+ if (!$this->rrmdir($dir . DIRECTORY_SEPARATOR . $file)) {
|
|
|
+ chmod($dir . DIRECTORY_SEPARATOR . $file, 0777);
|
|
|
+ if (!$this->rrmdir($dir . DIRECTORY_SEPARATOR . $file)) return false;
|
|
|
+ };
|
|
|
+ }
|
|
|
+ return rmdir($dir);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Create the BE user for the website, then return its uid
|
|
|
* The user shall be already created in the Opentalent DB
|