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