fix file by id in the parent field

This commit is contained in:
2025-11-11 23:53:49 +11:00
parent 5b2090c102
commit 7308e3c97c
6 changed files with 60 additions and 3 deletions

View File

@@ -225,6 +225,9 @@ export class MainApp {
ipcMain.handle(IPC_CHANNELS.libraryScan, async () => this.requireLibrary().scanLibrary());
ipcMain.handle(IPC_CHANNELS.libraryList, async () => this.requireLibrary().listFiles());
ipcMain.handle(IPC_CHANNELS.libraryGetById, async (_event: IpcMainInvokeEvent, fileId: number) =>
this.requireLibrary().getFileById(fileId)
);
ipcMain.handle(IPC_CHANNELS.libraryDuplicates, async () => this.requireLibrary().listDuplicates());
ipcMain.handle(IPC_CHANNELS.searchQuery, async (_event: IpcMainInvokeEvent, query: string) =>
this.requireSearch().search(query)

View File

@@ -214,6 +214,20 @@ export class LibraryService {
return this.database.listFiles();
}
/**
* Attempts to resolve a file summary by id. Returns null when the record no longer exists.
*/
public getFileById(fileId: number): AudioFileSummary | null {
try {
return this.database.getFileById(fileId);
} catch (error) {
if (error instanceof Error) {
console.warn(`Failed to resolve file by id ${fileId}:`, error.message);
}
return null;
}
}
/**
* Returns groups of files that have identical checksums (potential duplicates).
*/