mirror of
https://github.com/andwati/dokploy.git
synced 2026-10-30 16:52:16 +00:00
fix: correct application not found error message and improve error handling in removePreviewDeployment function
This commit is contained in:
@@ -70,7 +70,7 @@ export const findApplicationByPreview = async (applicationId: string) => {
|
|||||||
if (!application) {
|
if (!application) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "NOT_FOUND",
|
code: "NOT_FOUND",
|
||||||
message: "Applicationnot found",
|
message: "Application not found",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return application;
|
return application;
|
||||||
@@ -78,35 +78,41 @@ export const findApplicationByPreview = async (applicationId: string) => {
|
|||||||
|
|
||||||
export const removePreviewDeployment = async (previewDeploymentId: string) => {
|
export const removePreviewDeployment = async (previewDeploymentId: string) => {
|
||||||
try {
|
try {
|
||||||
const application = await findApplicationByPreview(previewDeploymentId);
|
|
||||||
const previewDeployment =
|
const previewDeployment =
|
||||||
await findPreviewDeploymentById(previewDeploymentId);
|
await findPreviewDeploymentById(previewDeploymentId);
|
||||||
|
const application = await findApplicationById(
|
||||||
const deployment = await db
|
previewDeployment.applicationId,
|
||||||
.delete(previewDeployments)
|
);
|
||||||
.where(eq(previewDeployments.previewDeploymentId, previewDeploymentId))
|
|
||||||
.returning();
|
|
||||||
|
|
||||||
application.appName = previewDeployment.appName;
|
application.appName = previewDeployment.appName;
|
||||||
const cleanupOperations = [
|
const cleanupOperations = [
|
||||||
|
async () =>
|
||||||
|
await removeService(application?.appName, application?.serverId),
|
||||||
async () =>
|
async () =>
|
||||||
await removeDeploymentsByPreviewDeploymentId(
|
await removeDeploymentsByPreviewDeploymentId(
|
||||||
previewDeployment,
|
previewDeployment,
|
||||||
application.serverId,
|
application?.serverId,
|
||||||
),
|
),
|
||||||
async () =>
|
async () =>
|
||||||
await removeDirectoryCode(application.appName, application.serverId),
|
await removeDirectoryCode(application?.appName, application?.serverId),
|
||||||
async () =>
|
async () =>
|
||||||
await removeTraefikConfig(application.appName, application.serverId),
|
await removeTraefikConfig(application?.appName, application?.serverId),
|
||||||
async () =>
|
async () =>
|
||||||
await removeService(application?.appName, application.serverId),
|
await db
|
||||||
|
.delete(previewDeployments)
|
||||||
|
.where(
|
||||||
|
eq(previewDeployments.previewDeploymentId, previewDeploymentId),
|
||||||
|
)
|
||||||
|
.returning(),
|
||||||
];
|
];
|
||||||
for (const operation of cleanupOperations) {
|
for (const operation of cleanupOperations) {
|
||||||
try {
|
try {
|
||||||
await operation();
|
await operation();
|
||||||
} catch {}
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return deployment[0];
|
return previewDeployment;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const message =
|
const message =
|
||||||
error instanceof Error
|
error instanceof Error
|
||||||
|
|||||||
Reference in New Issue
Block a user