From 46dfa026f0a03b6a234f5f4798cda61e1a603e77 Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 3 Feb 2020 18:47:18 -0500 Subject: [PATCH] fix an API change that caused a typeError --- lib/commands/core.js | 24 ++++++++++++++---------- lib/rpc.js | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/commands/core.js b/lib/commands/core.js index 6c87959ad..3e98d10dd 100644 --- a/lib/commands/core.js +++ b/lib/commands/core.js @@ -59,14 +59,18 @@ Core.getSession = function (Sessions, key) { return user; }; -Core.expireSession = function (Sessions, key, cb) { +Core.expireSession = function (Sessions, safeKey) { + var session = Sessions[safeKey]; + if (!session) { return; } + if (session.blobstage) { + session.blobstage.close(); + } + delete Sessions[safeKey]; +}; + +Core.expireSessionAsync = function (Env, safeKey, cb) { setTimeout(function () { - var session = Sessions[key]; - if (!session) { return; } - if (session.blobstage) { - session.blobstage.close(); - } - delete Sessions[key]; + Core.expireSession(Sessions, safeKey); cb(void 0, 'OK'); }); }; @@ -77,10 +81,10 @@ var isTooOld = function (time, now) { Core.expireSessions = function (Sessions) { var now = +new Date(); - Object.keys(Sessions).forEach(function (key) { - var session = Sessions[key]; + Object.keys(Sessions).forEach(function (safeKey) { + var session = Sessions[safeKey]; if (session && isTooOld(session.atime, now)) { - Core.expireSession(Sessions, key); + Core.expireSession(Sessions, safeKey); } }); }; diff --git a/lib/rpc.js b/lib/rpc.js index 1acac878c..d541a2550 100644 --- a/lib/rpc.js +++ b/lib/rpc.js @@ -130,7 +130,7 @@ const AUTHENTICATED_USER_SCOPED = { GET_TOTAL_SIZE: Pinning.getTotalSize, UPDATE_LIMITS: Quota.updateLimits, GET_LIMIT: Pinning.getLimit, - EXPIRE_SESSION: Core.expireSession, + EXPIRE_SESSION: Core.expireSessionAsync, REMOVE_PINS: Pinning.removePins, TRIM_PINS: Pinning.trimPins, SET_METADATA: Metadata.setMetadata,