Skip to content

Commit c4e59cb

Browse files
committed
Test for non-existant file
1 parent a162ef4 commit c4e59cb

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

lib/debug.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ exports.container = debug('solid:container')
1313
exports.accounts = debug('solid:accounts')
1414
exports.email = debug('solid:email')
1515
exports.ldp = debug('solid:ldp')
16+
exports.other = debug('solid:other')

lib/utils.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const path = require('path')
2020
const $rdf = require('rdflib')
2121
const from = require('from2')
2222
const url = require('url')
23+
const debug = require('./debug').other
2324
var ns = require('solid-namespace')($rdf)
2425

2526
/**
@@ -249,7 +250,13 @@ function routeResolvedFile (router, path, file, appendFileName = true) {
249250

250251
function getQuota (root, serverUri) {
251252
const filename = path.join(root, 'settings/serverSide.ttl')
252-
const prefs = fs.readFileSync(filename, 'utf8')
253+
var prefs
254+
try {
255+
prefs = fs.readFileSync(filename, 'utf8')
256+
} catch (error) {
257+
debug('Setting no quota. While reading serverSide.ttl, got ' + error)
258+
return Infinity
259+
}
253260
var graph = $rdf.graph()
254261
const storageUri = serverUri + '/'
255262
$rdf.parse(prefs, graph, storageUri, 'text/turtle')

test/integration/quota-test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@ describe('Quota', function () {
1414
it('Get the quota', function () {
1515
expect(getQuota(path.join('test/resources/', root), 'https://localhost')).to.equal(2000)
1616
})
17+
it('Get the quota with non-existant file', function () {
18+
expect(getQuota(path.join('nowhere/', root), 'https://localhost')).to.equal(Infinity)
19+
})
1720
})

0 commit comments

Comments
 (0)