🐛 Fix corrupt zip and remove project download on server
This commit is contained in:
+5
-5
@@ -2,7 +2,7 @@
|
||||
const slug = require('slug')
|
||||
const Files = require('./files.js')
|
||||
const Chat = require('./chat.js')
|
||||
const AdmZip = require('adm-zip')
|
||||
const JSZip = require('jszip')
|
||||
const glob = require('glob')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
@@ -72,8 +72,8 @@ class Project
|
||||
// Search files with glob
|
||||
const files = glob.sync(this.path + '/**', { dot: true })
|
||||
|
||||
// Create a zip file
|
||||
const zip = new AdmZip()
|
||||
// // Create a zip file
|
||||
const zip = new JSZip()
|
||||
|
||||
// Add files to zip
|
||||
for(const _file of files)
|
||||
@@ -85,12 +85,12 @@ class Project
|
||||
{
|
||||
const basename = path.basename(_file)
|
||||
const relativePath = _file.replace(basename, '').replace(this.path, '')
|
||||
zip.addLocalFile(_file, relativePath)
|
||||
zip.file(`${relativePath}${basename}`, fs.readFileSync(_file))
|
||||
}
|
||||
}
|
||||
|
||||
// Create and return zip buffer
|
||||
this.zipBuffer = zip.toBuffer()
|
||||
this.zipBuffer = zip.generateNodeStream({ type: 'nodebuffer', streamFiles: true })
|
||||
this.zipNeedsUpdate = false
|
||||
|
||||
// Debug
|
||||
|
||||
Reference in New Issue
Block a user