Files
privacy.sexy/tests/unit/shared/Stubs/FileSystemAccessorWithRetryStub.ts
undergroundwires 2f31bc7b06 Fix file retention after updates on macOS #417
This fixes issue #417 where autoupdate installer files were not deleted
on macOS, leading to accumulation of old installers.

Key changes:

- Store update files in application-specific directory
- Clear update files directory on every app launch

Other supporting changes:

- Refactor file system operations to be more testable and reusable
- Improve separation of concerns in directory management
- Enhance dependency injection for auto-update logic
- Fix async completion to support `await` operations
- Add additional logging and revise some log messages during updates
2024-10-07 17:33:47 +02:00

22 lines
623 B
TypeScript

import type { FileSystemAccessorWithRetry } from '@/presentation/electron/main/Update/ManualUpdater/FileSystemAccessorWithRetry';
export class FileSystemAccessorWithRetryStub {
private retryAmount = 0;
public withAlwaysRetry(retryAmount: number): this {
this.retryAmount = retryAmount;
return this;
}
public get(): FileSystemAccessorWithRetry {
return async (fileOperation) => {
const result = await fileOperation();
for (let i = 0; i < this.retryAmount; i++) {
// eslint-disable-next-line no-await-in-loop
await fileOperation();
}
return result;
};
}
}