mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-11 22:40:26 +01:00
Separate app DB per Git worktree (#348)
This commit is contained in:
@@ -86,6 +86,9 @@ try {
|
|||||||
// Continue with default ports
|
// Continue with default ports
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get worktree name from current directory
|
||||||
|
const worktreeName = path.basename(process.cwd());
|
||||||
|
|
||||||
// Create .env.local with unique ports
|
// Create .env.local with unique ports
|
||||||
const envContent = `# Auto-generated by git post-checkout hook
|
const envContent = `# Auto-generated by git post-checkout hook
|
||||||
# This file configures ports for this worktree to avoid conflicts
|
# This file configures ports for this worktree to avoid conflicts
|
||||||
@@ -95,6 +98,9 @@ YAAK_DEV_PORT=${maxDevPort}
|
|||||||
|
|
||||||
# MCP Server port (main worktree uses 64343)
|
# MCP Server port (main worktree uses 64343)
|
||||||
YAAK_PLUGIN_MCP_SERVER_PORT=${maxMcpPort}
|
YAAK_PLUGIN_MCP_SERVER_PORT=${maxMcpPort}
|
||||||
|
|
||||||
|
# Database path prefix for worktree isolation
|
||||||
|
YAAK_DB_PATH_PREFIX=worktrees/${worktreeName}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
fs.writeFileSync(envLocalPath, envContent, 'utf8');
|
fs.writeFileSync(envLocalPath, envContent, 'utf8');
|
||||||
|
|||||||
@@ -51,8 +51,17 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
|||||||
let app_path = app_handle.path().app_data_dir().unwrap();
|
let app_path = app_handle.path().app_data_dir().unwrap();
|
||||||
create_dir_all(app_path.clone()).expect("Problem creating App directory!");
|
create_dir_all(app_path.clone()).expect("Problem creating App directory!");
|
||||||
|
|
||||||
let db_file_path = app_path.join("db.sqlite");
|
// Support per-worktree databases via YAAK_DB_PATH_PREFIX env var
|
||||||
let blob_db_file_path = app_path.join("blobs.sqlite");
|
let db_dir = match std::env::var("YAAK_DB_PATH_PREFIX") {
|
||||||
|
Ok(prefix) if !prefix.is_empty() => {
|
||||||
|
let dir = app_path.join(prefix);
|
||||||
|
create_dir_all(&dir).expect("Problem creating DB directory!");
|
||||||
|
dir
|
||||||
|
}
|
||||||
|
_ => app_path.clone(),
|
||||||
|
};
|
||||||
|
let db_file_path = db_dir.join("db.sqlite");
|
||||||
|
let blob_db_file_path = db_dir.join("blobs.sqlite");
|
||||||
|
|
||||||
// Main database pool
|
// Main database pool
|
||||||
let manager = SqliteConnectionManager::file(db_file_path);
|
let manager = SqliteConnectionManager::file(db_file_path);
|
||||||
|
|||||||
Reference in New Issue
Block a user