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 ***/ /*** index.html ***/
html { html {
background: url('resources/send_bg.svg'); background: url('resources/send_bg.svg');
font-family: font-family: -apple-system,
-apple-system,
BlinkMacSystemFont, BlinkMacSystemFont,
'SF Pro Text', 'SF Pro Text',
Helvetica, Helvetica,

View File

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