fix: extract ZIP drop deployment to build server when configured

This commit is contained in:
Vicens Juan Tomas Monserrat
2026-02-04 10:00:03 +01:00
parent fa201a5a96
commit 44f8590fe8

View File

@@ -16,10 +16,13 @@ export const unzipDrop = async (zipFile: File, application: Application) => {
try {
const { appName } = application;
const { APPLICATIONS_PATH } = paths(!!application.serverId);
// Use buildServerId if set, otherwise fall back to serverId
// This ensures the code is extracted to the server where the build will run
const targetServerId = application.buildServerId || application.serverId;
const { APPLICATIONS_PATH } = paths(!!targetServerId);
const outputPath = join(APPLICATIONS_PATH, appName, "code");
if (application.serverId) {
await recreateDirectoryRemote(outputPath, application.serverId);
if (targetServerId) {
await recreateDirectoryRemote(outputPath, targetServerId);
} else {
await recreateDirectory(outputPath);
}
@@ -45,8 +48,8 @@ export const unzipDrop = async (zipFile: File, application: Application) => {
? rootEntries[0]?.entryName.split("/")[0]
: "";
if (application.serverId) {
sftp = await getSFTPConnection(application.serverId);
if (targetServerId) {
sftp = await getSFTPConnection(targetServerId);
}
for (const entry of zipEntries) {
let filePath = entry.entryName;
@@ -63,13 +66,13 @@ export const unzipDrop = async (zipFile: File, application: Application) => {
const fullPath = path.join(outputPath, filePath).replace(/\\/g, "/");
if (application.serverId) {
if (targetServerId) {
if (!entry.isDirectory) {
if (sftp === null) throw new Error("No SFTP connection available");
try {
const dirPath = path.dirname(fullPath);
await execAsyncRemote(
application.serverId,
targetServerId,
`mkdir -p "${dirPath}"`,
);
await uploadFileToServer(sftp, entry.getData(), fullPath);