feat: allow projects to have external data path for posts and media

This commit is contained in:
2026-02-12 15:33:45 +01:00
parent 85d196e598
commit e8c05ee8be
10 changed files with 239 additions and 170 deletions

View File

@@ -15,6 +15,7 @@ export class DatabaseConnection {
private localDb: DrizzleDB | null = null;
private localClient: Client | null = null;
private config: DatabaseConfig;
private _closing = false;
constructor(config?: Partial<DatabaseConfig>) {
const userDataPath = app.getPath('userData');
@@ -58,9 +59,15 @@ export class DatabaseConnection {
return this.localDb;
}
get isClosing(): boolean {
return this._closing;
}
getLocal(): DrizzleDB {
if (!this.localDb) {
throw new Error('Local database not initialized. Call initializeLocal() first.');
throw new Error(this._closing
? 'Database is closing'
: 'Local database not initialized. Call initializeLocal() first.');
}
return this.localDb;
}
@@ -449,6 +456,7 @@ export class DatabaseConnection {
}
async close(): Promise<void> {
this._closing = true;
if (this.localClient) {
this.localClient.close();
this.localClient = null;