mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge branch 'master' of https://github.com/sharelatex/web-sharelatex
This commit is contained in:
commit
65859468de
2 changed files with 24 additions and 1 deletions
|
@ -3,7 +3,11 @@ logger = require "logger-sharelatex"
|
||||||
metrics = require "../../infrastructure/Metrics"
|
metrics = require "../../infrastructure/Metrics"
|
||||||
|
|
||||||
module.exports = ArchiveManager =
|
module.exports = ArchiveManager =
|
||||||
extractZipArchive: (source, destination, callback = (err) ->) ->
|
extractZipArchive: (source, destination, _callback = (err) ->) ->
|
||||||
|
callback = (args...) ->
|
||||||
|
_callback(args...)
|
||||||
|
_callback = () ->
|
||||||
|
|
||||||
timer = new metrics.Timer("unzipDirectory")
|
timer = new metrics.Timer("unzipDirectory")
|
||||||
logger.log source: source, destination: destination, "unzipping file"
|
logger.log source: source, destination: destination, "unzipping file"
|
||||||
|
|
||||||
|
@ -18,6 +22,12 @@ module.exports = ArchiveManager =
|
||||||
error ||= ""
|
error ||= ""
|
||||||
error += chunk
|
error += chunk
|
||||||
|
|
||||||
|
unzip.on "error", (err) ->
|
||||||
|
logger.error {err, source, destination}, "unzip failed"
|
||||||
|
if err.code == "ENOENT"
|
||||||
|
logger.error "unzip command not found. Please check the unzip command is installed"
|
||||||
|
callback(err)
|
||||||
|
|
||||||
unzip.on "exit", () ->
|
unzip.on "exit", () ->
|
||||||
timer.done()
|
timer.done()
|
||||||
if error?
|
if error?
|
||||||
|
|
|
@ -57,3 +57,16 @@ describe "ArchiveManager", ->
|
||||||
it "should log out the error", ->
|
it "should log out the error", ->
|
||||||
@logger.error.called.should.equal true
|
@logger.error.called.should.equal true
|
||||||
|
|
||||||
|
describe "with an error on the process", ->
|
||||||
|
beforeEach (done) ->
|
||||||
|
@ArchiveManager.extractZipArchive @source, @destination, (error) =>
|
||||||
|
@callback(error)
|
||||||
|
done()
|
||||||
|
@process.emit "error", new Error("Something went wrong")
|
||||||
|
|
||||||
|
it "should return the callback with an error", ->
|
||||||
|
@callback.calledWithExactly(new Error("Something went wrong")).should.equal true
|
||||||
|
|
||||||
|
it "should log out the error", ->
|
||||||
|
@logger.error.called.should.equal true
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue