🐛 Fix corrupt zip and remove project download on server

This commit is contained in:
brunosimon
2017-12-25 17:49:53 +01:00
parent 3d93205750
commit 2620b00ffe
23 changed files with 148 additions and 60 deletions
+5 -5
View File
@@ -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