MCPcopy Create free account
hub / github.com/ether/etherpad / _touch

Method _touch

src/node/db/SessionStore.ts:221–233  ·  view source on GitHub ↗
(sid: string, sess:any)

Source from the content-addressed store, hash-verified

219 // would behave like set() in that case but it's OK if it doesn't -- express-session will call
220 // set() soon enough.
221 async _touch(sid: string, sess:any) {
222 logger.debug(`TOUCH ${sid}`);
223 sess = await this._updateExpirations(sid, sess, false);
224 if (sess == null) return; // Already expired.
225 const exp = this._expirations.get(sid);
226 // If the session doesn't expire, don't do anything. Ideally we would write the session to the
227 // database if it didn't already exist, but we have no way of knowing that without querying the
228 // database. The query overhead is not worth it because set() should be called soon anyway.
229 if (exp == null) return;
230 if (exp.db != null && (this._refresh == null || exp.real < exp.db + this._refresh)) return;
231 await this._write(sid, sess);
232 exp.db = new Date(sess.cookie.expires).getTime();
233 }
234}
235
236// express-session doesn't support Promise-based methods. This is where the callbackified versions

Callers

nothing calls this directly

Calls 3

_updateExpirationsMethod · 0.95
_writeMethod · 0.95
getMethod · 0.80

Tested by

no test coverage detected