Skip to content

Commit b1fdfa5

Browse files
Merge pull request #34 from ScreepsMods/issue/#33
When no file, dont try to read
2 parents 318d405 + c1c48b2 commit b1fdfa5

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/adapters/file.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ class FileAdapter {
2020
}
2121
read (room, tick, callback) {
2222
const file = this.getFilePath(room, tick)
23+
if (!fs.existsSync(file)) {
24+
return Promise.resolve().asCallback(callback)
25+
}
2326
return Promise.resolve()
2427
.then(data => fs.readFileAsync(file))
2528
.then(data => zlib.gunzipAsync(data, 'utf8'))

lib/adapters/sqlite.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class SqliteAdapter {
4242
try {
4343
const record = await History.findOne({ where: { room, tick } })
4444
if (!record) {
45-
throw new Error('Record not found')
45+
return null
4646
}
4747
const data = JSON.parse(await gunzip(record.data, 'utf8'))
4848
if (typeof callback === 'function') callback(null, data)

0 commit comments

Comments
 (0)