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

@@ -142,16 +142,16 @@ export class PostEngine extends EventEmitter {
await client.execute({ sql: 'DELETE FROM posts_fts WHERE id = ?', args: [id] });
}
private projectBaseDir: string | null = null;
private dataDir: string | null = null;
private getProjectBaseDir(): string {
if (this.projectBaseDir) return this.projectBaseDir;
private getDataDir(): string {
if (this.dataDir) return this.dataDir;
const userDataPath = app.getPath('userData');
return path.join(userDataPath, 'projects', this.currentProjectId);
}
private getPostsBaseDir(): string {
return path.join(this.getProjectBaseDir(), 'posts');
return path.join(this.getDataDir(), 'posts');
}
private getPostsDir(): string {
@@ -179,9 +179,9 @@ export class PostEngine extends EventEmitter {
return path.join(dir, `${slug}.md`);
}
setProjectContext(projectId: string, baseDir?: string): void {
setProjectContext(projectId: string, dataDir?: string): void {
this.currentProjectId = projectId;
this.projectBaseDir = baseDir || null;
this.dataDir = dataDir || null;
}
getProjectContext(): string {