时间优化

This commit is contained in:
aixianling
2022-04-01 18:36:09 +08:00
parent d8ba3fbb83
commit ec7adbbe71
3 changed files with 4 additions and 7 deletions

View File

@@ -21,6 +21,7 @@
"author": "kubbo",
"dependencies": {
"archiver": "^5.3.0",
"dayjs": "^1.11.0",
"express": "^4.17.3",
"fs-extra": "^10.0.1",
"helmet": "^5.0.2",

View File

@@ -2,7 +2,6 @@ const dbUtils = require("../../utils/dbUitls");
const archiver = require("archiver")
const fse = require("fs-extra");
const fs = require("fs");
const dir = require("path")
module.exports = {
action: "/node/autodeploy/download",
method: "post",
@@ -21,16 +20,13 @@ module.exports = {
arc.on('error', err => {
response.send({code: 1, err})
})
arc.on('progress', (e) => {
console.log('%s压缩进度...%s/%s', info.id, e.entries.processed, e.entries.total)
})
arc.pipe(output)
arc.directory(path, false)
arc.finalize().then(() => {
console.log('压缩完成!')
setTimeout(() => {
response.download(zipPath)
}, 500)
}, 1000)
})
} else response.send({code: 1, err: "没有打包文件!"})
})

View File

@@ -1,5 +1,6 @@
const db = require("../../utils/dbUitls");
const zip = require("../../tools/zipProject")
const dayjs = require("dayjs")
module.exports = {
action: "/node/autodeploy/getZip",
method: "post",
@@ -14,11 +15,10 @@ module.exports = {
response.send({code: 0})
}, 2000)
zip(info).then(() => {
db.query(`update node_autodeploy set download='${new Date()}',error='' where id='${info.id}'`)
db.query(`update node_autodeploy set download='${dayjs().format("YYYY-MM-DD HH:mm:ss")}',error='' where id='${info.id}'`)
}).catch(err => {
console.log(err)
db.query(`update node_autodeploy set error='${err}' where id='${info.id}'`)
})
} else response.send({code: 1, err: "无法找到git信息"})
}).catch(err => {