Skip to content

Commit

Permalink
callback fixes (with codacy)
Browse files Browse the repository at this point in the history
  • Loading branch information
suculent committed Nov 15, 2023
1 parent 4319111 commit f656a90
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/thinx/transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,15 +379,15 @@ module.exports = class Transfer {

}

save_dtid(tid, keys, ac) {
this.redis.set(tid, JSON.stringify(keys));
async save_dtid(tid, keys, ac) {
await this.redis.set(tid, JSON.stringify(keys));
console.log(`🔨 [debug] [transfer] Accepted udids ${keys.udids}`);
if (keys.udids.length > 1) {
ac(true, "transfer_partially_completed");
this.redis.expire(tid, 3600); // 3600 seconds expiration for this transfer request; should be possibly more (like 72h to pass weekends)
await this.redis.expire(tid, 3600); // 3600 seconds expiration for this transfer request; should be possibly more (like 72h to pass weekends)
} else {
ac(true, "transfer_completed");
this.redis.del(tid);
await this.redis.del(tid);
}
}

Expand Down Expand Up @@ -491,8 +491,9 @@ module.exports = class Transfer {
promises.push(result);
}

Promise.all(promises).then(() => {
this.save_dtid(dtid, json_keys, accept_callback);
Promise.all(promises).then(async () => {
await this.save_dtid(dtid, json_keys);
Promise.resolve(true);
}).catch(e => console.log("[transfer] promise exception", e));
}

Expand Down Expand Up @@ -579,7 +580,7 @@ module.exports = class Transfer {
}

// Store remaining (not declined) keys
await this.storeRemainingKeys(dtid, json_keys, callback);
await this.storeRemainingKeys(dtid, json_keys);

Promise.resolve("decline_completed");
}
Expand Down

0 comments on commit f656a90

Please sign in to comment.