MCPcopy Create free account
hub / github.com/GlobalTechInfo/MEGA-MD / initializeSession

Function initializeSession

index.js:151–180  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

149 }
150}
151async function initializeSession() {
152 ensureSessionDirectory();
153 const txt = config.sessionId;
154 if (!txt) {
155 if (hasValidSession()) {
156 printLog('success', 'Existing session found. Using saved credentials');
157 return true;
158 }
159 return false;
160 }
161 if (hasValidSession())
162 return true;
163 try {
164 await SaveCreds(txt);
165 await delay(2000);
166 if (hasValidSession()) {
167 printLog('success', 'Session file verified and valid');
168 await delay(1000);
169 return true;
170 }
171 else {
172 printLog('error', 'Session file not valid after download');
173 return false;
174 }
175 }
176 catch (error) {
177 printLog('error', `Error downloading session: ${error.message}`);
178 return false;
179 }
180}
181server.listen(PORT, () => {
182 printLog('success', `Server listening on port ${PORT}`);
183});

Callers 1

mainFunction · 0.85

Calls 5

printLogFunction · 0.90
ensureSessionDirectoryFunction · 0.85
hasValidSessionFunction · 0.85
SaveCredsFunction · 0.85
delayFunction · 0.50

Tested by

no test coverage detected