优化打包下载
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user