mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
Merge pull request #2602 from overleaf/hb-too-many-files-errors
Too many files errors for new files modal GitOrigin-RevId: a9e2db2e4d8624de4e062161781067ee0c68c4e0
This commit is contained in:
committed by
Copybot
parent
bb3394885c
commit
ab80c72565
@@ -150,10 +150,10 @@ module.exports = EditorHttpController = {
|
||||
'editor',
|
||||
userId,
|
||||
function(error, doc) {
|
||||
if (error && error.message === 'project_has_to_many_files') {
|
||||
if (error && error.message === 'project_has_too_many_files') {
|
||||
return res
|
||||
.status(400)
|
||||
.json(req.i18n.translate('project_has_to_many_files'))
|
||||
.json(req.i18n.translate('project_has_too_many_files'))
|
||||
} else if (error) {
|
||||
return next(error)
|
||||
} else {
|
||||
@@ -176,10 +176,10 @@ module.exports = EditorHttpController = {
|
||||
name,
|
||||
'editor',
|
||||
function(error, doc) {
|
||||
if (error && error.message === 'project_has_to_many_files') {
|
||||
if (error && error.message === 'project_has_too_many_files') {
|
||||
return res
|
||||
.status(400)
|
||||
.json(req.i18n.translate('project_has_to_many_files'))
|
||||
.json(req.i18n.translate('project_has_too_many_files'))
|
||||
} else if (error && error.message === 'invalid element name') {
|
||||
return res.status(400).json(req.i18n.translate('invalid_file_name'))
|
||||
} else if (error) {
|
||||
|
||||
@@ -174,6 +174,8 @@ module.exports = LinkedFilesController = {
|
||||
return res.status(502).send('The remote service produced an error')
|
||||
} else if (error instanceof FileCannotRefreshError) {
|
||||
return res.status(400).send('This file cannot be refreshed')
|
||||
} else if (error.message === 'project_has_too_many_files') {
|
||||
return res.status(400).send('too many files')
|
||||
} else {
|
||||
return next(error)
|
||||
}
|
||||
|
||||
@@ -485,7 +485,7 @@ async function _putElement(project, folderId, element, type) {
|
||||
'project too big, stopping insertions'
|
||||
)
|
||||
CooldownManager.putProjectOnCooldown(project._id)
|
||||
throw new Error('project_has_to_many_files')
|
||||
throw new Error('project_has_too_many_files')
|
||||
}
|
||||
|
||||
const { element: folder, path } = await ProjectLocator.promises.findElement({
|
||||
|
||||
@@ -113,7 +113,14 @@ module.exports = ProjectUploadController = {
|
||||
},
|
||||
'error uploading file'
|
||||
)
|
||||
return res.send({ success: false })
|
||||
if (error.message === 'project_has_too_many_files') {
|
||||
return res.send({
|
||||
success: false,
|
||||
error: req.i18n.translate('project_has_too_many_files')
|
||||
})
|
||||
} else {
|
||||
return res.send({ success: false })
|
||||
}
|
||||
} else {
|
||||
return res.send({
|
||||
success: true,
|
||||
|
||||
@@ -153,6 +153,7 @@ script(type='text/ng-template', id='newFileModalTemplate')
|
||||
div.alert.alert-danger.row-spaced-small(ng-if="error")
|
||||
div(ng-switch="error")
|
||||
span(ng-switch-when="already exists") #{translate("file_already_exists")}
|
||||
span(ng-switch-when="too many files") #{translate("project_has_too_many_files")}
|
||||
span(ng-switch-default) Error, something went wrong!
|
||||
div(ng-if="type == 'url'", ng-controller="UrlLinkedFileModalController")
|
||||
form(novalidate, name="newLinkedFileForm")
|
||||
@@ -183,6 +184,7 @@ script(type='text/ng-template', id='newFileModalTemplate')
|
||||
div.alert.alert-danger.row-spaced-small(ng-if="error")
|
||||
div(ng-switch="error")
|
||||
span(ng-switch-when="already exists") #{translate("file_already_exists")}
|
||||
span(ng-switch-when="too many files") #{translate("project_has_too_many_files")}
|
||||
span(ng-switch-default) {{error}}
|
||||
|
||||
!= moduleIncludes("newFileModal:panel", locals)
|
||||
|
||||
@@ -388,14 +388,14 @@ describe('EditorHttpController', function() {
|
||||
|
||||
it('handle too many files', function() {
|
||||
this.EditorController.addDoc.yields(
|
||||
new Error('project_has_to_many_files')
|
||||
new Error('project_has_too_many_files')
|
||||
)
|
||||
let res = {
|
||||
status: status => {
|
||||
status.should.equal(400)
|
||||
return {
|
||||
json: json => {
|
||||
json.should.equal('project_has_to_many_files')
|
||||
json.should.equal('project_has_too_many_files')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -448,14 +448,14 @@ describe('EditorHttpController', function() {
|
||||
|
||||
it('handle too many files', function() {
|
||||
this.EditorController.addFolder.yields(
|
||||
new Error('project_has_to_many_files')
|
||||
new Error('project_has_too_many_files')
|
||||
)
|
||||
let res = {
|
||||
status: status => {
|
||||
status.should.equal(400)
|
||||
return {
|
||||
json: json => {
|
||||
json.should.equal('project_has_to_many_files')
|
||||
json.should.equal('project_has_too_many_files')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ describe('ProjectUploadController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when FileSystemImportManager.addEntity returns an error', function() {
|
||||
describe('when FileSystemImportManager.addEntity returns a generic error', function() {
|
||||
beforeEach(function() {
|
||||
this.FileSystemImportManager.addEntity = sinon
|
||||
.stub()
|
||||
@@ -240,6 +240,22 @@ describe('ProjectUploadController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when FileSystemImportManager.addEntity returns a too many files error', function() {
|
||||
beforeEach(function() {
|
||||
this.FileSystemImportManager.addEntity = sinon
|
||||
.stub()
|
||||
.callsArgWith(6, new Error('project_has_too_many_files'))
|
||||
return this.ProjectUploadController.uploadFile(this.req, this.res)
|
||||
})
|
||||
|
||||
it('should return an unsuccessful response to the FileUploader client', function() {
|
||||
return expect(this.res.body).to.deep.equal({
|
||||
success: false,
|
||||
error: 'project_has_too_many_files'
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('with a bad request', function() {
|
||||
beforeEach(function() {
|
||||
this.req.file.originalname = ''
|
||||
|
||||
Reference in New Issue
Block a user