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:
@@ -0,0 +1,34 @@
|
||||
import { FileReadWriteOperations } from '@/infrastructure/ReadbackFileWriter/NodeReadbackFileWriter';
|
||||
import { StubWithObservableMethodCalls } from '@tests/unit/shared/Stubs/StubWithObservableMethodCalls';
|
||||
|
||||
export class FileReadWriteOperationsStub
|
||||
extends StubWithObservableMethodCalls<FileReadWriteOperations>
|
||||
implements FileReadWriteOperations {
|
||||
private readonly writtenFiles: Record<string, string> = {};
|
||||
|
||||
public writeFile = (filePath: string, fileContents: string, encoding: NodeJS.BufferEncoding) => {
|
||||
this.registerMethodCall({
|
||||
methodName: 'writeFile',
|
||||
args: [filePath, fileContents, encoding],
|
||||
});
|
||||
this.writtenFiles[filePath] = fileContents;
|
||||
return Promise.resolve();
|
||||
};
|
||||
|
||||
public access = (...args: Parameters<FileReadWriteOperations['access']>) => {
|
||||
this.registerMethodCall({
|
||||
methodName: 'access',
|
||||
args: [...args],
|
||||
});
|
||||
return Promise.resolve();
|
||||
};
|
||||
|
||||
public readFile = (filePath: string, encoding: NodeJS.BufferEncoding) => {
|
||||
this.registerMethodCall({
|
||||
methodName: 'readFile',
|
||||
args: [filePath, encoding],
|
||||
});
|
||||
const fileContents = this.writtenFiles[filePath];
|
||||
return Promise.resolve(fileContents);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user