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
This commit is contained in:
41
tests/unit/shared/Stubs/ApplicationDirectoryProviderStub.ts
Normal file
41
tests/unit/shared/Stubs/ApplicationDirectoryProviderStub.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import type {
|
||||
DirectoryCreationOutcome,
|
||||
ApplicationDirectoryProvider,
|
||||
DirectoryType,
|
||||
DirectoryCreationError,
|
||||
} from '@/infrastructure/FileSystem/Directory/ApplicationDirectoryProvider';
|
||||
|
||||
export class ApplicationDirectoryProviderStub implements ApplicationDirectoryProvider {
|
||||
private directoryPaths: Record<DirectoryType, string> = {
|
||||
'update-installation-files': `[${ApplicationDirectoryProviderStub.name}]update installation files directory`,
|
||||
'script-runs': `[${ApplicationDirectoryProviderStub.name}]scripts directory`,
|
||||
};
|
||||
|
||||
private failure: DirectoryCreationError | undefined = undefined;
|
||||
|
||||
public withDirectoryPath(type: DirectoryType, directoryPath: string): this {
|
||||
this.directoryPaths[type] = directoryPath;
|
||||
return this;
|
||||
}
|
||||
|
||||
public provideDirectory(type: DirectoryType): Promise<DirectoryCreationOutcome> {
|
||||
if (this.failure) {
|
||||
return Promise.resolve({
|
||||
success: false,
|
||||
error: this.failure,
|
||||
});
|
||||
}
|
||||
return Promise.resolve({
|
||||
success: true,
|
||||
directoryAbsolutePath: this.directoryPaths[type],
|
||||
});
|
||||
}
|
||||
|
||||
public withFailure(error?: DirectoryCreationError): this {
|
||||
this.failure = error ?? {
|
||||
type: 'DirectoryWriteError',
|
||||
message: `[${ApplicationDirectoryProviderStub.name}]injected failure`,
|
||||
};
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user