This commit addresses issues #264 and #304, where users were not receiving error messages when script execution failed due to antivirus intervention, particularly with Microsoft Defender. Now, desktop app users will see a detailed error message with guidance on next steps if script saving or execution fails due to antivirus removal. Key changes: - Implement a check to detect failure in file writing, including reading the written file back. This method effectively detects antivirus interventions, as the read operation triggers an antivirus scan, leading to file deletion by the antivirus. - Introduce a specific error message for scenarios where an antivirus intervention is detected.
This commit is contained in:
29
tests/unit/shared/Stubs/ReadbackFileWriterStub.ts
Normal file
29
tests/unit/shared/Stubs/ReadbackFileWriterStub.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { FileWriteErrorType, FileWriteOutcome, ReadbackFileWriter } from '@/infrastructure/ReadbackFileWriter/ReadbackFileWriter';
|
||||
import { StubWithObservableMethodCalls } from './StubWithObservableMethodCalls';
|
||||
|
||||
export class ReadbackFileWriterStub
|
||||
extends StubWithObservableMethodCalls<ReadbackFileWriter>
|
||||
implements ReadbackFileWriter {
|
||||
private outcome: FileWriteOutcome = { success: true };
|
||||
|
||||
public writeAndVerifyFile(
|
||||
...args: Parameters<ReadbackFileWriter['writeAndVerifyFile']>
|
||||
): Promise<FileWriteOutcome> {
|
||||
this.registerMethodCall({
|
||||
methodName: 'writeAndVerifyFile',
|
||||
args: [...args],
|
||||
});
|
||||
return Promise.resolve(this.outcome);
|
||||
}
|
||||
|
||||
public configureFailure(errorType: FileWriteErrorType, message: string): this {
|
||||
this.outcome = {
|
||||
success: false,
|
||||
error: {
|
||||
type: errorType,
|
||||
message: `[${ReadbackFileWriterStub.name}] ${message}`,
|
||||
},
|
||||
};
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user