Merge pull request #3026 from overleaf/bg-fix-size-limit-check

fix clsi size limit check

GitOrigin-RevId: 1d26ddbe367e8873c57d35056d5b8cbddf614656
This commit is contained in:
Eric Mc Sween 2020-07-20 09:21:59 -04:00 committed by Copybot
parent 88b5a4534c
commit 60bdd4641a
2 changed files with 4 additions and 6 deletions

View file

@ -66,7 +66,7 @@ module.exports = ClsiFormatChecker = {
let sizedResources = resources.map(function(resource) {
const result = { path: resource.path }
if (resource.content != null) {
result.size = resource.content.replace(/\n/g).length
result.size = resource.content.replace(/\n/g, '').length
result.kbSize = Math.ceil(result.size / 1000)
} else {
result.size = 0

View file

@ -198,9 +198,7 @@ describe('ClsiFormatChecker', function() {
it('should error when there is more than 5mb of data', function(done) {
this.resources.push({
path: 'massive.tex',
content: require('crypto')
.randomBytes(1000 * 1000 * 5)
.toString('hex')
content: 'hello world\n'.repeat(833333) // over 5mb limit
})
while (this.resources.length < 20) {
@ -213,10 +211,10 @@ describe('ClsiFormatChecker', function() {
return this.ClsiFormatChecker._checkDocsAreUnderSizeLimit(
this.resources,
(err, sizeError) => {
sizeError.totalSize.should.equal(10000016)
sizeError.totalSize.should.equal(16 + 833333 * 11) // 16 is for earlier resources
sizeError.resources.length.should.equal(10)
sizeError.resources[0].path.should.equal('massive.tex')
sizeError.resources[0].size.should.equal(1000 * 1000 * 10)
sizeError.resources[0].size.should.equal(833333 * 11)
return done()
}
)