refactor all redis calls to reject on null

This commit is contained in:
Danny Coates 2017-07-25 12:58:44 -07:00
parent dd0ab710de
commit 424eb2c37a
No known key found for this signature in database
GPG Key ID: 4C442633C62E00CB
2 changed files with 7 additions and 24 deletions

View File

@ -1,8 +1,7 @@
/*** index.html ***/
html {
background: url('resources/send_bg.svg');
font-family:
-apple-system,
font-family: -apple-system,
BlinkMacSystemFont,
'SF Pro Text',
Helvetica,

View File

@ -27,7 +27,6 @@ if (conf.s3_bucket) {
length: awsLength,
get: awsGet,
set: awsSet,
aad: aad,
setField: setField,
delete: awsDelete,
forceDelete: awsForceDelete,
@ -44,7 +43,6 @@ if (conf.s3_bucket) {
length: localLength,
get: localGet,
set: localSet,
aad: aad,
setField: setField,
delete: localDelete,
forceDelete: localForceDelete,
@ -66,11 +64,10 @@ function quit() {
function metadata(id) {
return new Promise((resolve, reject) => {
redis_client.hgetall(id, (err, reply) => {
if (!err) {
resolve(reply);
} else {
reject(err);
if (err || !reply) {
return reject(err);
}
resolve(reply);
});
});
}
@ -78,11 +75,10 @@ function metadata(id) {
function ttl(id) {
return new Promise((resolve, reject) => {
redis_client.ttl(id, (err, reply) => {
if (!err) {
resolve(reply * 1000);
} else {
reject(err);
if (err || !reply) {
return reject(err);
}
resolve(reply * 1000);
});
});
}
@ -114,18 +110,6 @@ function setField(id, key, value) {
redis_client.hset(id, key, value);
}
function aad(id) {
return new Promise((resolve, reject) => {
redis_client.hget(id, 'aad', (err, reply) => {
if (!err) {
resolve(reply);
} else {
reject();
}
});
});
}
function localLength(id) {
return new Promise((resolve, reject) => {
try {