From 18d28844695e7956ee9a003aa3eebce024c85e5b Mon Sep 17 00:00:00 2001 From: irwanda Date: Sun, 7 Jun 2026 08:57:20 +0700 Subject: [PATCH] refactor: remove manual log deletion from clearOldDeployments --- apps/dokploy/server/api/routers/application.ts | 2 +- apps/dokploy/server/api/routers/compose.ts | 2 +- packages/server/src/services/deployment.ts | 16 +--------------- 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/apps/dokploy/server/api/routers/application.ts b/apps/dokploy/server/api/routers/application.ts index 52f209df5..6d79fada0 100644 --- a/apps/dokploy/server/api/routers/application.ts +++ b/apps/dokploy/server/api/routers/application.ts @@ -754,7 +754,7 @@ export const applicationRouter = createTRPCRouter({ deployment: ["create"], }); const application = await findApplicationById(input.applicationId); - await clearOldDeployments(application.applicationId, "application", application.serverId); + await clearOldDeployments(application.applicationId, "application"); await audit(ctx, { action: "delete", resourceType: "application", diff --git a/apps/dokploy/server/api/routers/compose.ts b/apps/dokploy/server/api/routers/compose.ts index f76542b1d..fc34fb4be 100644 --- a/apps/dokploy/server/api/routers/compose.ts +++ b/apps/dokploy/server/api/routers/compose.ts @@ -298,7 +298,7 @@ export const composeRouter = createTRPCRouter({ deployment: ["create"], }); const compose = await findComposeById(input.composeId); - await clearOldDeployments(compose.composeId, "compose", compose.serverId); + await clearOldDeployments(compose.composeId, "compose"); await audit(ctx, { action: "update", resourceType: "compose", diff --git a/packages/server/src/services/deployment.ts b/packages/server/src/services/deployment.ts index 5c544dd0f..362d329dd 100644 --- a/packages/server/src/services/deployment.ts +++ b/packages/server/src/services/deployment.ts @@ -1036,8 +1036,7 @@ export const findAllDeploymentsByServerId = async (serverId: string) => { export const clearOldDeployments = async ( id: string, - type: "application" | "compose", - serverId: string | null, + type: "application" | "compose" ) => { const deploymentsList = await db.query.deployments.findMany({ where: eq(deployments[`${type}Id`], id), @@ -1055,21 +1054,12 @@ export const clearOldDeployments = async ( (d) => d.deploymentId !== currentDeployment.deploymentId, ); - const remoteLogCommands: string[] = []; - for (const oldDeployment of deploymentsToDelete) { try { if (oldDeployment.rollbackId) { await removeRollbackById(oldDeployment.rollbackId); } - const logPath = path.join(oldDeployment.logPath); - const hasLogPath = logPath && logPath !== "."; - - if (serverId) { - if (hasLogPath) remoteLogCommands.push(`rm -f "${logPath}"`); - } - await removeDeployment(oldDeployment.deploymentId); } catch (err) { console.error( @@ -1078,8 +1068,4 @@ export const clearOldDeployments = async ( ); } } - - if (serverId && remoteLogCommands.length > 0) { - await execAsyncRemote(serverId, remoteLogCommands.join(";")); - } };