From 424eb2c37ad50ab7778985edbea029e8683e4720 Mon Sep 17 00:00:00 2001 From: Danny Coates Date: Tue, 25 Jul 2017 12:58:44 -0700 Subject: [PATCH] refactor all redis calls to reject on null --- public/main.css | 3 +-- server/storage.js | 28 ++++++---------------------- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/public/main.css b/public/main.css index c04950a6..ef074d8a 100644 --- a/public/main.css +++ b/public/main.css @@ -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, diff --git a/server/storage.js b/server/storage.js index 3fc1af84..93d1c46c 100644 --- a/server/storage.js +++ b/server/storage.js @@ -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 {