feat: added dataPath for projects

This commit is contained in:
2026-02-12 15:00:37 +01:00
parent 2b95f3d72c
commit 85d196e598
15 changed files with 263 additions and 49 deletions

View File

@@ -5,6 +5,7 @@ import { getDatabase } from './database';
import { registerIpcHandlers, registerChatHandlers, initializeChatHandlers, cleanupChatHandlers } from './ipc';
import { media } from './database/schema';
import { eq } from 'drizzle-orm';
import { getMediaEngine } from './engine/MediaEngine';
let mainWindow: BrowserWindow | null = null;
@@ -22,6 +23,15 @@ protocol.registerSchemesAsPrivileged([
corsEnabled: true,
},
},
{
scheme: 'bds-thumb',
privileges: {
standard: true,
secure: true,
supportFetchAPI: true,
corsEnabled: true,
},
},
]);
function createWindow(): void {
@@ -383,6 +393,39 @@ async function initialize(): Promise<void> {
}
});
// Register custom protocol for serving thumbnail images
// URLs like bds-thumb://media-id will serve the small thumbnail webp
protocol.handle('bds-thumb', async (request) => {
try {
const url = new URL(request.url);
const mediaId = url.hostname;
const engine = getMediaEngine();
const thumbnails = await engine.getThumbnailPaths(mediaId);
if (thumbnails.small) {
return net.fetch(`file://${thumbnails.small}`);
}
// Fallback to full image if thumbnail doesn't exist
const database = getDatabase().getLocal();
const mediaItem = await database
.select()
.from(media)
.where(eq(media.id, mediaId))
.get();
if (mediaItem && mediaItem.filePath) {
return net.fetch(`file://${mediaItem.filePath}`);
}
return new Response('Thumbnail not found', { status: 404 });
} catch (error) {
console.error('Error serving thumbnail:', error);
return new Response('Internal server error', { status: 500 });
}
});
// Register IPC handlers
registerIpcHandlers();