mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-11 17:46:41 -05:00
Use unique Tauri identifier per worktree for app data isolation
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -37,3 +37,6 @@ tmp
|
|||||||
.zed
|
.zed
|
||||||
codebook.toml
|
codebook.toml
|
||||||
target
|
target
|
||||||
|
|
||||||
|
# Per-worktree Tauri config (generated by post-checkout hook)
|
||||||
|
src-tauri/tauri.worktree.conf.json
|
||||||
|
|||||||
@@ -98,14 +98,22 @@ 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');
|
||||||
console.log(`Created .env.local with YAAK_DEV_PORT=${maxDevPort} and YAAK_PLUGIN_MCP_SERVER_PORT=${maxMcpPort}`);
|
console.log(`Created .env.local with YAAK_DEV_PORT=${maxDevPort} and YAAK_PLUGIN_MCP_SERVER_PORT=${maxMcpPort}`);
|
||||||
|
|
||||||
|
// Create tauri.worktree.conf.json with unique app identifier for complete isolation
|
||||||
|
// This gives each worktree its own app data directory, avoiding the need for DB path prefixes
|
||||||
|
const tauriWorktreeConfig = {
|
||||||
|
identifier: `app.yaak.desktop.dev.${worktreeName}`,
|
||||||
|
productName: `Daak (${worktreeName})`
|
||||||
|
};
|
||||||
|
|
||||||
|
const tauriConfigPath = path.join(process.cwd(), 'src-tauri', 'tauri.worktree.conf.json');
|
||||||
|
fs.writeFileSync(tauriConfigPath, JSON.stringify(tauriWorktreeConfig, null, 2) + '\n', 'utf8');
|
||||||
|
console.log(`Created tauri.worktree.conf.json with identifier: ${tauriWorktreeConfig.identifier}`);
|
||||||
|
|
||||||
// Copy gitignored editor config folders from main worktree (.zed, .vscode, .claude, etc.)
|
// Copy gitignored editor config folders from main worktree (.zed, .vscode, .claude, etc.)
|
||||||
// This ensures your editor settings, tasks, and configurations are available in the new worktree
|
// This ensures your editor settings, tasks, and configurations are available in the new worktree
|
||||||
// without needing to manually copy them or commit them to git.
|
// without needing to manually copy them or commit them to git.
|
||||||
@@ -148,12 +156,4 @@ try {
|
|||||||
// Continue anyway
|
// Continue anyway
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run npm run init to install dependencies and bootstrap
|
console.log('\n✓ Worktree setup complete! Run `npm run init` to install dependencies.');
|
||||||
console.log('\nRunning npm run init to install dependencies and bootstrap...');
|
|
||||||
try {
|
|
||||||
execSync('npm run init', { stdio: 'inherit' });
|
|
||||||
console.log('\n✓ Worktree setup complete!');
|
|
||||||
} catch (err) {
|
|
||||||
console.error('\n✗ Failed to run npm run init. You may need to run it manually.');
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -51,17 +51,8 @@ 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!");
|
||||||
|
|
||||||
// Support per-worktree databases via YAAK_DB_PATH_PREFIX env var
|
let db_file_path = app_path.join("db.sqlite");
|
||||||
let db_dir = match std::env::var("YAAK_DB_PATH_PREFIX") {
|
let blob_db_file_path = app_path.join("blobs.sqlite");
|
||||||
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