fix watcher await
This commit is contained in:
@@ -46,7 +46,7 @@ export class LibraryService extends EventEmitter {
|
|||||||
private configCore: SystemConfigCore;
|
private configCore: SystemConfigCore;
|
||||||
private watchLibraries = false;
|
private watchLibraries = false;
|
||||||
private watchLock = false;
|
private watchLock = false;
|
||||||
private watchers: Record<string, () => void> = {};
|
private watchers: Record<string, () => Promise<void>> = {};
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(IAccessRepository) accessRepository: IAccessRepository,
|
@Inject(IAccessRepository) accessRepository: IAccessRepository,
|
||||||
@@ -175,7 +175,7 @@ export class LibraryService extends EventEmitter {
|
|||||||
|
|
||||||
async unwatch(id: string) {
|
async unwatch(id: string) {
|
||||||
if (this.watchers[id]) {
|
if (this.watchers[id]) {
|
||||||
this.watchers[id]();
|
await this.watchers[id]();
|
||||||
delete this.watchers[id];
|
delete this.watchers[id];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,6 @@ export interface IStorageRepository {
|
|||||||
crawl(crawlOptions: CrawlOptionsDto): Promise<string[]>;
|
crawl(crawlOptions: CrawlOptionsDto): Promise<string[]>;
|
||||||
copyFile(source: string, target: string): Promise<void>;
|
copyFile(source: string, target: string): Promise<void>;
|
||||||
rename(source: string, target: string): Promise<void>;
|
rename(source: string, target: string): Promise<void>;
|
||||||
watch(paths: string[], options: WatchOptions, events: Partial<WatchEvents>): () => void;
|
watch(paths: string[], options: WatchOptions, events: Partial<WatchEvents>): () => Promise<void>;
|
||||||
utimes(filepath: string, atime: Date, mtime: Date): Promise<void>;
|
utimes(filepath: string, atime: Date, mtime: Date): Promise<void>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,6 +148,6 @@ export class FilesystemProvider implements IStorageRepository {
|
|||||||
watcher.on(StorageEventType.UNLINK, (path) => events.onUnlink?.(path));
|
watcher.on(StorageEventType.UNLINK, (path) => events.onUnlink?.(path));
|
||||||
watcher.on(StorageEventType.ERROR, (error) => events.onError?.(error));
|
watcher.on(StorageEventType.ERROR, (error) => events.onError?.(error));
|
||||||
|
|
||||||
return () => watcher.close();
|
return async () => await watcher.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ interface MockWatcherOptions {
|
|||||||
| StorageEventType.ERROR;
|
| StorageEventType.ERROR;
|
||||||
value: string;
|
value: string;
|
||||||
}>;
|
}>;
|
||||||
close?: () => void;
|
close?: () => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const makeMockWatcher =
|
export const makeMockWatcher =
|
||||||
@@ -37,7 +37,7 @@ export const makeMockWatcher =
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return () => close?.();
|
return async () => await close?.();
|
||||||
};
|
};
|
||||||
|
|
||||||
export const newStorageRepositoryMock = (reset = true): jest.Mocked<IStorageRepository> => {
|
export const newStorageRepositoryMock = (reset = true): jest.Mocked<IStorageRepository> => {
|
||||||
|
|||||||
Reference in New Issue
Block a user