Skip to content

The swiss army knife of lossless video/audio editing

chore: type fsOperationWithRetry and remove ts-expect-error

PriscaAmajuoyifd5cffaf1a58
diff --git a/src/renderer/src/util.ts b/src/renderer/src/util.ts
index 568de531..766d556a 100644
--- a/src/renderer/src/util.ts
+++ b/src/renderer/src/util.ts
@@ -116,11 +116,10 @@ export async function dirExists(dirPath: string) {
export const testFailFsOperation = false;
// Retry because sometimes write operations fail on windows due to the file being locked for various reasons (often anti-virus) #272 #1797 #1704
-export async function fsOperationWithRetry(operation: () => Promise<unknown>, { signal, retries = 10, minTimeout = 100, maxTimeout = 2000, ...opts }: Options & { retries?: number | undefined, minTimeout?: number | undefined, maxTimeout?: number | undefined } = {}) {
- return pRetry(async () => {
+export async function fsOperationWithRetry<T>(operation: () => Promise<T>, { signal, retries = 10, minTimeout = 100, maxTimeout = 2000, ...opts }: Options & { retries?: number | undefined, minTimeout?: number | undefined, maxTimeout?: number | undefined } = {}): Promise<T> {
+ return pRetry<T>(async () => {
if (testFailFsOperation && Math.random() > 0.3) throw Object.assign(new Error('test delete failure'), { code: 'EPERM' });
- await operation();
- // @ts-expect-error todo
+ return operation();
}, {
retries,
signal,