mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 00:33:41 -05:00
Merge pull request #252 from overleaf/jpa-flag-empty-outout-pdf
[CompileController] emit status=failure for an empty output.pdf file
This commit is contained in:
commit
7e88b4f746
2 changed files with 48 additions and 23 deletions
|
@ -88,7 +88,7 @@ module.exports = CompileController = {
|
||||||
let file
|
let file
|
||||||
status = 'failure'
|
status = 'failure'
|
||||||
for (file of Array.from(outputFiles)) {
|
for (file of Array.from(outputFiles)) {
|
||||||
if (file.path === 'output.pdf') {
|
if (file.path === 'output.pdf' && file.size > 0) {
|
||||||
status = 'success'
|
status = 'success'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ module.exports = CompileController = {
|
||||||
stats,
|
stats,
|
||||||
timings,
|
timings,
|
||||||
outputFiles: outputFiles.map((file) => {
|
outputFiles: outputFiles.map((file) => {
|
||||||
const record = {
|
return {
|
||||||
url:
|
url:
|
||||||
`${Settings.apis.clsi.url}/project/${request.project_id}` +
|
`${Settings.apis.clsi.url}/project/${request.project_id}` +
|
||||||
(request.user_id != null
|
(request.user_id != null
|
||||||
|
@ -131,18 +131,8 @@ module.exports = CompileController = {
|
||||||
: '') +
|
: '') +
|
||||||
(file.build != null ? `/build/${file.build}` : '') +
|
(file.build != null ? `/build/${file.build}` : '') +
|
||||||
`/output/${file.path}`,
|
`/output/${file.path}`,
|
||||||
path: file.path,
|
...file
|
||||||
type: file.type,
|
|
||||||
build: file.build,
|
|
||||||
contentId: file.contentId
|
|
||||||
}
|
}
|
||||||
if (file.ranges != null) {
|
|
||||||
record.ranges = file.ranges
|
|
||||||
}
|
|
||||||
if (file.size != null) {
|
|
||||||
record.size = file.size
|
|
||||||
}
|
|
||||||
return record
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -99,6 +99,7 @@ describe('CompileController', function () {
|
||||||
{
|
{
|
||||||
path: 'output.pdf',
|
path: 'output.pdf',
|
||||||
type: 'pdf',
|
type: 'pdf',
|
||||||
|
size: 1337,
|
||||||
build: 1234
|
build: 1234
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -157,11 +158,7 @@ describe('CompileController', function () {
|
||||||
outputFiles: this.output_files.map((file) => {
|
outputFiles: this.output_files.map((file) => {
|
||||||
return {
|
return {
|
||||||
url: `${this.Settings.apis.clsi.url}/project/${this.project_id}/build/${file.build}/output/${file.path}`,
|
url: `${this.Settings.apis.clsi.url}/project/${this.project_id}/build/${file.build}/output/${file.path}`,
|
||||||
path: file.path,
|
...file
|
||||||
type: file.type,
|
|
||||||
build: file.build,
|
|
||||||
// gets dropped by JSON.stringify
|
|
||||||
contentId: undefined
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -202,11 +199,49 @@ describe('CompileController', function () {
|
||||||
outputFiles: this.output_files.map((file) => {
|
outputFiles: this.output_files.map((file) => {
|
||||||
return {
|
return {
|
||||||
url: `${this.Settings.apis.clsi.url}/project/${this.project_id}/build/${file.build}/output/${file.path}`,
|
url: `${this.Settings.apis.clsi.url}/project/${this.project_id}/build/${file.build}/output/${file.path}`,
|
||||||
path: file.path,
|
...file
|
||||||
type: file.type,
|
}
|
||||||
build: file.build,
|
})
|
||||||
// gets dropped by JSON.stringify
|
}
|
||||||
contentId: undefined
|
})
|
||||||
|
.should.equal(true)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('with an empty output.pdf', function () {
|
||||||
|
beforeEach(function () {
|
||||||
|
this.output_files = [
|
||||||
|
{
|
||||||
|
path: 'output.pdf',
|
||||||
|
type: 'pdf',
|
||||||
|
size: 0,
|
||||||
|
build: 1234
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'output.log',
|
||||||
|
type: 'log',
|
||||||
|
build: 1234
|
||||||
|
}
|
||||||
|
]
|
||||||
|
this.CompileManager.doCompileWithLock = sinon
|
||||||
|
.stub()
|
||||||
|
.yields(null, this.output_files, this.stats, this.timings)
|
||||||
|
this.CompileController.compile(this.req, this.res)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should return the JSON response with status failure', function () {
|
||||||
|
this.res.status.calledWith(200).should.equal(true)
|
||||||
|
this.res.send
|
||||||
|
.calledWith({
|
||||||
|
compile: {
|
||||||
|
status: 'failure',
|
||||||
|
error: null,
|
||||||
|
stats: this.stats,
|
||||||
|
timings: this.timings,
|
||||||
|
outputFiles: this.output_files.map((file) => {
|
||||||
|
return {
|
||||||
|
url: `${this.Settings.apis.clsi.url}/project/${this.project_id}/build/${file.build}/output/${file.path}`,
|
||||||
|
...file
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue