From 3053c68bdf02e5a45d05388916bcc082d17c8768 Mon Sep 17 00:00:00 2001 From: Yury Date: Tue, 29 Oct 2024 11:40:44 +0300 Subject: [PATCH] chore(lint): fixed linting issues --- api/src/controllers/internal/Session.ts | 46 ++++++++++++++----------- api/src/controllers/user.ts | 2 +- api/src/utils/upload.ts | 5 ++- 3 files changed, 28 insertions(+), 25 deletions(-) diff --git a/api/src/controllers/internal/Session.ts b/api/src/controllers/internal/Session.ts index 3573658..3000c07 100644 --- a/api/src/controllers/internal/Session.ts +++ b/api/src/controllers/internal/Session.ts @@ -189,33 +189,37 @@ ${autoExecContent}` } private scheduleSessionDestroy(session: Session) { - setTimeout(async () => { - if (session.inUse) { - // adding 10 more minutes - const newDeathTimeStamp = - parseInt(session.deathTimeStamp) + 10 * 60 * 1000 - session.deathTimeStamp = newDeathTimeStamp.toString() - - this.scheduleSessionDestroy(session) - } else { - const { expiresAfterMins } = session - - // delay session destroy if expiresAfterMins present - if (expiresAfterMins && !expiresAfterMins.used) { - // calculate session death time using expiresAfterMins + setTimeout( + async () => { + if (session.inUse) { + // adding 10 more minutes const newDeathTimeStamp = - parseInt(session.deathTimeStamp) + expiresAfterMins.mins * 60 * 1000 + parseInt(session.deathTimeStamp) + 10 * 60 * 1000 session.deathTimeStamp = newDeathTimeStamp.toString() - // set expiresAfterMins to true to avoid using it again - session.expiresAfterMins!.used = true - this.scheduleSessionDestroy(session) } else { - await this.deleteSession(session) + const { expiresAfterMins } = session + + // delay session destroy if expiresAfterMins present + if (expiresAfterMins && !expiresAfterMins.used) { + // calculate session death time using expiresAfterMins + const newDeathTimeStamp = + parseInt(session.deathTimeStamp) + + expiresAfterMins.mins * 60 * 1000 + session.deathTimeStamp = newDeathTimeStamp.toString() + + // set expiresAfterMins to true to avoid using it again + session.expiresAfterMins!.used = true + + this.scheduleSessionDestroy(session) + } else { + await this.deleteSession(session) + } } - } - }, parseInt(session.deathTimeStamp) - new Date().getTime() - 100) + }, + parseInt(session.deathTimeStamp) - new Date().getTime() - 100 + ) } } diff --git a/api/src/controllers/user.ts b/api/src/controllers/user.ts index 424df90..d8790d9 100644 --- a/api/src/controllers/user.ts +++ b/api/src/controllers/user.ts @@ -285,7 +285,7 @@ const getUser = async ( username: user.username, isActive: user.isActive, isAdmin: user.isAdmin, - autoExec: getAutoExec ? user.autoExec ?? '' : undefined, + autoExec: getAutoExec ? (user.autoExec ?? '') : undefined, groups: user.groups } } diff --git a/api/src/utils/upload.ts b/api/src/utils/upload.ts index d4a4119..f85cf57 100644 --- a/api/src/utils/upload.ts +++ b/api/src/utils/upload.ts @@ -51,9 +51,8 @@ export const generateFileUploadSasCode = async ( let fileCount = 0 const uploadedFiles: UploadedFiles[] = [] - const sasSessionFolderList: string[] = await listFilesInFolder( - sasSessionFolder - ) + const sasSessionFolderList: string[] = + await listFilesInFolder(sasSessionFolder) sasSessionFolderList.forEach((fileName) => { let fileCountString = fileCount < 100 ? '0' + fileCount : fileCount fileCountString = fileCount < 10 ? '00' + fileCount : fileCount