mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
updated archive module to latest version
This commit is contained in:
parent
8795a8a921
commit
a0fb170878
3 changed files with 11 additions and 6 deletions
|
@ -8,6 +8,8 @@ module.exports = ProjectZipStreamManager =
|
|||
createZipStreamForProject: (project_id, callback = (error, stream) ->) ->
|
||||
archive = archiver("zip")
|
||||
# return stream immediately before we start adding things to it
|
||||
archive.on "error", (err)->
|
||||
logger.err err:err, project_id:project_id, "something went wrong building archive of project"
|
||||
callback(null, archive)
|
||||
@addAllDocsToArchive project_id, archive, (error) =>
|
||||
if error?
|
||||
|
@ -27,7 +29,8 @@ module.exports = ProjectZipStreamManager =
|
|||
path = path.slice(1) if path[0] == "/"
|
||||
jobs.push (callback) ->
|
||||
logger.log project_id: project_id, "Adding doc"
|
||||
archive.append doc.lines.join("\n"), name: path, callback
|
||||
archive.append doc.lines.join("\n"), name: path
|
||||
callback()
|
||||
async.series jobs, callback
|
||||
|
||||
addAllFilesToArchive: (project_id, archive, callback = (error) ->) ->
|
||||
|
@ -42,5 +45,6 @@ module.exports = ProjectZipStreamManager =
|
|||
logger.err err:error, project_id:project_id, file_id:file._id, "something went wrong adding file to zip archive"
|
||||
return callback(err)
|
||||
path = path.slice(1) if path[0] == "/"
|
||||
archive.append stream, name: path, callback
|
||||
archive.append stream, name: path
|
||||
callback()
|
||||
async.series jobs, callback
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
"node-uuid": "1.4.1",
|
||||
"nodemailer": "0.6.1",
|
||||
"bcrypt": "0.7.5",
|
||||
"archiver": "0.5.1",
|
||||
"archiver": "0.9.0",
|
||||
"mocha": "1.17.1",
|
||||
"redback": "0.4.0",
|
||||
"sanitizer": "0.1.1"
|
||||
|
|
|
@ -9,7 +9,8 @@ describe "ProjectZipStreamManager", ->
|
|||
beforeEach ->
|
||||
@project_id = "project-id-123"
|
||||
@callback = sinon.stub()
|
||||
@archive = { }
|
||||
@archive =
|
||||
on:->
|
||||
@ProjectZipStreamManager = SandboxedModule.require modulePath, requires:
|
||||
"archiver": @archiver = sinon.stub().returns @archive
|
||||
"logger-sharelatex": @logger = {error: sinon.stub(), log: sinon.stub()}
|
||||
|
@ -87,7 +88,7 @@ describe "ProjectZipStreamManager", ->
|
|||
"/chapters/chapter1.tex":
|
||||
lines: ["chapter1", "content"]
|
||||
@ProjectEntityHandler.getAllDocs = sinon.stub().callsArgWith(1, null, @docs)
|
||||
@archive.append = sinon.stub().callsArg(2)
|
||||
@archive.append = sinon.stub()
|
||||
@ProjectZipStreamManager.addAllDocsToArchive @project_id, @archive, (error) =>
|
||||
@callback(error)
|
||||
done()
|
||||
|
@ -114,7 +115,7 @@ describe "ProjectZipStreamManager", ->
|
|||
"file-id-1" : "stream-mock-1"
|
||||
"file-id-2" : "stream-mock-2"
|
||||
@ProjectEntityHandler.getAllFiles = sinon.stub().callsArgWith(1, null, @files)
|
||||
@archive.append = sinon.stub().callsArg(2)
|
||||
@archive.append = sinon.stub()
|
||||
@FileStoreHandler.getFileStream = (project_id, file_id, {}, callback) =>
|
||||
callback null, @streams[file_id]
|
||||
sinon.spy @FileStoreHandler, "getFileStream"
|
||||
|
|
Loading…
Reference in a new issue