fix(duckdb): allow opening non-existent database files

This commit is contained in:
t8y2 committed 2026-06-27 15:01:06 +08:00
1 parent 55cd442cdb
commit 9ae4d4b59e
1 file changed
+7 -1
+7 -1
View File
@@ -39,7 +39,13 @@ fn validate_duckdb_path(path: &str) -> Result<(), String> {
return Err(format!("Database file path is a directory, not a file: {}", path)); return Err(format!("Database file path is a directory, not a file: {}", path));
} }
if !path_obj.exists() { if !path_obj.exists() {
return Err(format!("Database file does not exist: {}", path)); // DuckDB creates a new database file on open when the parent directory
// exists. Only reject paths whose parent directory is missing.
if let Some(parent) = path_obj.parent() {
if !parent.as_os_str().is_empty() && !parent.exists() {
return Err(format!("Parent directory does not exist: {}", parent.display()));
}
}
} }
Ok(()) Ok(())
} }