Fix delete function deployment
Prior to this, deleting a VCS deployment would fail because the deployment path for VCS deployments are empty. Because an error gets thrown, the delete function would stop and not delete the build files. This change updates the worker to only delete the storage files if the path is set.
This commit is contained in:
parent
6770b9920a
commit
c5e059c118
1 changed files with 36 additions and 9 deletions
|
@ -679,12 +679,25 @@ class DeletesV1 extends Worker
|
|||
/**
|
||||
* Delete deployment files
|
||||
*/
|
||||
Console::info("Deleting deployment files for deployment " . $deploymentId);
|
||||
$storageFunctions = $this->getFunctionsDevice($projectId);
|
||||
if ($storageFunctions->delete($document->getAttribute('path', ''), true)) {
|
||||
Console::success('Deleted deployment files: ' . $document->getAttribute('path', ''));
|
||||
$deploymentPath = $document->getAttribute('path', '');
|
||||
if (empty($deploymentPath)) {
|
||||
Console::info("No deployment files for deployment " . $deploymentId);
|
||||
} else {
|
||||
Console::error('Failed to delete deployment files: ' . $document->getAttribute('path', ''));
|
||||
Console::info("Deleting deployment files for deployment " . $deploymentId);
|
||||
$storageFunctions = $this->getFunctionsDevice($projectId);
|
||||
try {
|
||||
if ($storageFunctions->delete($deploymentPath, true)) {
|
||||
Console::success('Deleted deployment files: ' . $deploymentPath);
|
||||
} else {
|
||||
Console::error('Failed to delete deployment files: ' . $deploymentPath);
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
Console::error('Failed to delete deployment files: ' . $deploymentPath);
|
||||
Console::error('[Error] Type: ' . get_class($th));
|
||||
Console::error('[Error] Message: ' . $th->getMessage());
|
||||
Console::error('[Error] File: ' . $th->getFile());
|
||||
Console::error('[Error] Line: ' . $th->getLine());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -695,10 +708,24 @@ class DeletesV1 extends Worker
|
|||
$this->deleteByGroup('builds', [
|
||||
Query::equal('deploymentInternalId', [$deploymentInternalId])
|
||||
], $dbForProject, function (Document $document) use ($storageBuilds) {
|
||||
if ($storageBuilds->delete($document->getAttribute('path', ''), true)) {
|
||||
Console::success('Deleted build files: ' . $document->getAttribute('path', ''));
|
||||
} else {
|
||||
Console::error('Failed to delete build files: ' . $document->getAttribute('path', ''));
|
||||
$buildPath = $document->getAttribute('path', '');
|
||||
if (empty($buildPath)) {
|
||||
Console::info("No build files for build " . $document->getId());
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if ($storageBuilds->delete($buildPath, true)) {
|
||||
Console::success('Deleted build files: ' . $buildPath);
|
||||
} else {
|
||||
Console::error('Failed to delete build files: ' . $buildPath);
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
Console::error('Failed to delete deployment files: ' . $buildPath);
|
||||
Console::error('[Error] Type: ' . get_class($th));
|
||||
Console::error('[Error] Message: ' . $th->getMessage());
|
||||
Console::error('[Error] File: ' . $th->getFile());
|
||||
Console::error('[Error] Line: ' . $th->getLine());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue