优化打包下载

This commit is contained in:
aixianling
2022-06-10 11:48:19 +08:00
parent b677a3fe9f
commit 95663704d1

View File

@@ -1,7 +1,6 @@
const dbUtils = require("../../utils/dbUitls");
const archiver = require("archiver")
const fse = require("fs-extra");
const fs = require("fs");
const execute = require("../../tools/exec");
module.exports = {
action: "/node/autodeploy/download",
method: "post",
@@ -15,14 +14,7 @@ module.exports = {
fse.pathExists(path, (err, exists) => {
console.log(`${path}=========>${exists}`)
if (exists) {
let output = fs.createWriteStream(zipPath),
arc = archiver('zip')
arc.on('error', err => {
response.send({code: 1, err})
})
arc.pipe(output)
arc.directory(path, false)
arc.finalize().then(() => {
execute(`zip -r ${zipPath} ${path}`).then(() => {
console.log('压缩完成!')
setTimeout(() => {
response.download(zipPath)