diff --git a/server/routes/download.js b/server/routes/download.js index 7828c880..006f11c2 100644 --- a/server/routes/download.js +++ b/server/routes/download.js @@ -34,7 +34,7 @@ module.exports = async function(req, res) { if (dl >= dlimit) { await storage.del(id); } else { - await storage.setField(id, 'dl', dl); + await storage.incrementField(id, 'dl'); } } catch (e) { log.info('StorageError:', id); diff --git a/server/storage/index.js b/server/storage/index.js index 1c80f26c..3e46c5c1 100644 --- a/server/storage/index.js +++ b/server/storage/index.js @@ -62,6 +62,10 @@ class DB { this.redis.hset(id, key, value); } + incrementField(id, key, increment = 1) { + this.redis.hincrby(id, key, increment); + } + async del(id) { const filePath = await this.getPrefixedId(id); this.storage.del(filePath);