mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
fix: omit macos files and create folders every time
This commit is contained in:
@@ -555,9 +555,9 @@ export const applicationRouter = createTRPCRouter({
|
||||
});
|
||||
}
|
||||
|
||||
updateApplication(input.applicationId as string, {
|
||||
await updateApplication(input.applicationId as string, {
|
||||
sourceType: "drop",
|
||||
dropBuildPath: input.dropBuildPath,
|
||||
dropBuildPath: input.dropBuildPath || "",
|
||||
});
|
||||
|
||||
await unzipDrop(zipFile, app);
|
||||
|
||||
@@ -27,7 +27,9 @@ export const unzipDrop = async (zipFile: File, application: Application) => {
|
||||
const buffer = Buffer.from(arrayBuffer);
|
||||
|
||||
const zip = new AdmZip(buffer);
|
||||
const zipEntries = zip.getEntries();
|
||||
const zipEntries = zip
|
||||
.getEntries()
|
||||
.filter((entry) => !entry.entryName.startsWith("__MACOSX"));
|
||||
|
||||
const rootEntries = zipEntries.filter(
|
||||
(entry) =>
|
||||
@@ -59,14 +61,22 @@ export const unzipDrop = async (zipFile: File, application: Application) => {
|
||||
|
||||
if (!filePath) continue;
|
||||
|
||||
const fullPath = path.join(outputPath, filePath);
|
||||
const fullPath = path.join(outputPath, filePath).replace(/\\/g, "/");
|
||||
|
||||
if (application.serverId) {
|
||||
if (entry.isDirectory) {
|
||||
await execAsyncRemote(application.serverId, `mkdir -p ${fullPath}`);
|
||||
} else {
|
||||
if (!entry.isDirectory) {
|
||||
if (sftp === null) throw new Error("No SFTP connection available");
|
||||
await uploadFileToServer(sftp, entry.getData(), fullPath);
|
||||
try {
|
||||
const dirPath = path.dirname(fullPath);
|
||||
await execAsyncRemote(
|
||||
application.serverId,
|
||||
`mkdir -p "${dirPath}"`,
|
||||
);
|
||||
await uploadFileToServer(sftp, entry.getData(), fullPath);
|
||||
} catch (err) {
|
||||
console.error(`Error uploading file ${fullPath}:`, err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (entry.isDirectory) {
|
||||
@@ -103,7 +113,6 @@ const getSFTPConnection = async (serverId: string): Promise<SFTPWrapper> => {
|
||||
port: server.port,
|
||||
username: server.username,
|
||||
privateKey: server.sshKey?.privateKey,
|
||||
timeout: 99999,
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -115,7 +124,10 @@ const uploadFileToServer = (
|
||||
): Promise<void> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
sftp.writeFile(remotePath, data, (err) => {
|
||||
if (err) return reject(err);
|
||||
if (err) {
|
||||
console.error(`SFTP write error for ${remotePath}:`, err);
|
||||
return reject(err);
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user