Skip to content

Fix/antivirus scan cancel#242

Merged
egalvis27 merged 9 commits intomainfrom
fix/antivirus-scan-cancel
Feb 13, 2026
Merged

Fix/antivirus scan cancel#242
egalvis27 merged 9 commits intomainfrom
fix/antivirus-scan-cancel

Conversation

@egalvis27
Copy link

What is Changed / Added


The scan cancellation method has been refactored to use an AbortController. Additionally, to prevent processes from continuing to run in the background, the daily scan is now canceled automatically when a custom scan is initiated.

Why

A user reported an issue where the daily scan continues running in the background and consuming resources even after initiating a custom scan.

signal?: AbortSignal,
): Promise<void | null> => {
if (isCancelled && isCancelled()) {
if (signal?.aborted) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to make the abortSignal optional? if its optional why have it in the first place?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 26 to 29
currentScan = new ScanOrchestrator();

await currentScan.scanPaths(paths);
currentScan = null;
await currentScan.scanPaths(paths);
currentScan = null;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why it needs to be this way? seems odd you could do a helper function that handles this and make this function only call that,

msg: 'Error in performScan:',
error,
});
throw error;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to catch an exception only to re-throw it again? doesnt make sense, maybe it is a better idea to wrap in trycatch the caller and let the caller handle said exception

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

const currentScannedFile = await antivirus.scanFile(scannedItem.pathName);
const currentScannedFile = await antivirus.scanFile(
scannedItem.pathName,
backgroundScanAbortController!.signal,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be careful with this, I would even try to find another way to do this only to avoid this expression

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

const currentScannedFile = await antivirus.scanFile(scannedItem.pathName);
const currentScannedFile = await antivirus.scanFile(scannedItem.pathName, backgroundScanAbortController!.signal);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

await getFilesFromDirectory(userSystemPath.path, (file: string) => backgroundQueue!.pushAsync(file));
await getFilesFromDirectory(
userSystemPath.path,
(file: string) => backgroundQueue!.pushAsync(file),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
36.8% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@egalvis27 egalvis27 merged commit 894c41e into main Feb 13, 2026
8 of 9 checks passed
@egalvis27 egalvis27 deleted the fix/antivirus-scan-cancel branch February 13, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants