mirror of
https://gitlab.com/timvisee/send.git
synced 2024-11-10 13:13:00 +01:00
Merge pull request #1299 from slootjes/master
Prevent possible download counter race condition
This commit is contained in:
commit
147ed4c736
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user