Add duplicate scan session handling in SocketClient
All checks were successful
farmcontrol/farmcontrol-server/pipeline/head This commit looks good
All checks were successful
farmcontrol/farmcontrol-server/pipeline/head This commit looks good
- Implemented a check in the `startScanSession` method to prevent starting a new scan session if one is already in progress for the same session ID. - Added logging to inform when a duplicate scan session is ignored, enhancing visibility into scan session management. - Updated callback behavior to indicate when a scan session is already running, improving user feedback during scan operations.
This commit is contained in:
parent
5fb867bf27
commit
c6a4ba900e
@ -765,6 +765,18 @@ export class SocketClient {
|
||||
const startToken = {};
|
||||
this.scanSessionTokens.set(sessionId, startToken);
|
||||
|
||||
const existing = this.scanSessions.get(sessionId);
|
||||
if (existing?.scanning) {
|
||||
logger.info(
|
||||
"Scan session already running, ignoring duplicate start:",
|
||||
sessionId,
|
||||
);
|
||||
if (typeof callback === "function") {
|
||||
callback({ success: true, sessionId, alreadyRunning: true });
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
await this.stopScanSession(sessionId);
|
||||
|
||||
if (this.scanSessionTokens.get(sessionId) !== startToken) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user