From a0fb1708783c681bc629a03e5597682abd15b839 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Mon, 28 Apr 2014 16:27:15 +0100 Subject: [PATCH] updated archive module to latest version --- .../Features/Downloads/ProjectZipStreamManager.coffee | 8 ++++++-- services/web/package.json | 2 +- .../coffee/Downloads/ProjectZipStreamManagerTests.coffee | 7 ++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/services/web/app/coffee/Features/Downloads/ProjectZipStreamManager.coffee b/services/web/app/coffee/Features/Downloads/ProjectZipStreamManager.coffee index 03ad2b864a..579fdc7b41 100644 --- a/services/web/app/coffee/Features/Downloads/ProjectZipStreamManager.coffee +++ b/services/web/app/coffee/Features/Downloads/ProjectZipStreamManager.coffee @@ -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 diff --git a/services/web/package.json b/services/web/package.json index 522375555a..dddc730660 100644 --- a/services/web/package.json +++ b/services/web/package.json @@ -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" diff --git a/services/web/test/UnitTests/coffee/Downloads/ProjectZipStreamManagerTests.coffee b/services/web/test/UnitTests/coffee/Downloads/ProjectZipStreamManagerTests.coffee index f7889c7c5e..61c6c40936 100644 --- a/services/web/test/UnitTests/coffee/Downloads/ProjectZipStreamManagerTests.coffee +++ b/services/web/test/UnitTests/coffee/Downloads/ProjectZipStreamManagerTests.coffee @@ -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"