Fix an issue where one broken channel can prevent others from saving

Son of a bitch.
This commit is contained in:
Calvin Montgomery 2016-12-28 23:24:08 -08:00
parent b0daa58874
commit 31880fa625
3 changed files with 8 additions and 6 deletions

View File

@ -2,7 +2,7 @@
"author": "Calvin Montgomery", "author": "Calvin Montgomery",
"name": "CyTube", "name": "CyTube",
"description": "Online media synchronizer and chat", "description": "Online media synchronizer and chat",
"version": "3.25.2", "version": "3.26.0",
"repository": { "repository": {
"url": "http://github.com/calzoneman/sync" "url": "http://github.com/calzoneman/sync"
}, },

View File

@ -77,10 +77,11 @@ export class DatabaseStore {
} }
if (totalSize > SIZE_LIMIT) { if (totalSize > SIZE_LIMIT) {
throw new ChannelStateSizeError('Channel state size is too large', { return Promise.reject(new ChannelStateSizeError(
'Channel state size is too large', {
limit: SIZE_LIMIT, limit: SIZE_LIMIT,
actual: totalSize actual: totalSize
}); }));
} }
return queryAsync(buildUpdateQuery(rowCount), substitutions); return queryAsync(buildUpdateQuery(rowCount), substitutions);

View File

@ -20,10 +20,11 @@ export class FileStore {
const filename = this.filenameForChannel(channelName); const filename = this.filenameForChannel(channelName);
return statAsync(filename).then(stats => { return statAsync(filename).then(stats => {
if (stats.size > SIZE_LIMIT) { if (stats.size > SIZE_LIMIT) {
throw new ChannelStateSizeError('Channel state file is too large', { return Promise.reject(
new ChannelStateSizeError('Channel state file is too large', {
limit: SIZE_LIMIT, limit: SIZE_LIMIT,
actual: stats.size actual: stats.size
}); }));
} else { } else {
return readFileAsync(filename); return readFileAsync(filename);
} }
@ -31,7 +32,7 @@ export class FileStore {
try { try {
return JSON.parse(fileContents); return JSON.parse(fileContents);
} catch (e) { } catch (e) {
throw new Error('Channel state file is not valid JSON: ' + e); return Promise.reject(new Error('Channel state file is not valid JSON: ' + e));
} }
}); });
} }