mirror of
https://github.com/tiennm99/coolify.git
synced 2026-04-17 19:21:36 +00:00
fix: restore original base_directory on compose validation failure
The Application::loadComposeFile method's finally block always saves the model, which was persisting invalid base_directory values when validation failed. Changes: - Add restoreBaseDirectory and restoreDockerComposeLocation parameters to loadComposeFile() in both Application model and General component - The finally block now restores BOTH base_directory and docker_compose_location to the provided original values before saving - When called from submit(), pass the original DB values so they are restored on failure instead of the new invalid values This ensures invalid paths are never persisted to the database. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1511,9 +1511,11 @@ class Application extends BaseModel
|
||||
}
|
||||
}
|
||||
|
||||
public function loadComposeFile($isInit = false)
|
||||
public function loadComposeFile($isInit = false, ?string $restoreBaseDirectory = null, ?string $restoreDockerComposeLocation = null)
|
||||
{
|
||||
$initialDockerComposeLocation = $this->docker_compose_location;
|
||||
// Use provided restore values or capture current values as fallback
|
||||
$initialDockerComposeLocation = $restoreDockerComposeLocation ?? $this->docker_compose_location;
|
||||
$initialBaseDirectory = $restoreBaseDirectory ?? $this->base_directory;
|
||||
if ($isInit && $this->docker_compose_raw) {
|
||||
return;
|
||||
}
|
||||
@@ -1580,6 +1582,7 @@ class Application extends BaseModel
|
||||
throw new \RuntimeException($e->getMessage());
|
||||
} finally {
|
||||
$this->docker_compose_location = $initialDockerComposeLocation;
|
||||
$this->base_directory = $initialBaseDirectory;
|
||||
$this->save();
|
||||
$commands = collect([
|
||||
"rm -rf /tmp/{$uuid}",
|
||||
|
||||
Reference in New Issue
Block a user