feat(sidebar): reveal local db file in OS file manager

This commit is contained in:
t8y2 committed 2026-06-13 16:00:47 +08:00
1 parent 6a87f31fdc
commit d091b0db85
16 files changed
+265 -1

No files matched your search

@@ -40,3 +40,34 @@ pub fn skips_tcp_probe(db_type: &DatabaseType) -> bool {
matches!(db_type, DatabaseType::Sqlite | DatabaseType::DuckDb | DatabaseType::Turso | DatabaseType::Jdbc)
|| is_agent_type(db_type)
}
/// Database types whose connection backs onto a single local file (or may, in the
/// case of H2 file mode). Used to decide whether to expose a "reveal in file
/// manager" affordance. Whether the H2 connection is actually in file mode must
/// be determined separately by parsing the JDBC URL.
pub fn is_local_file_db_type(db_type: &DatabaseType) -> bool {
matches!(db_type, DatabaseType::Sqlite | DatabaseType::DuckDb | DatabaseType::Access | DatabaseType::H2)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn local_file_db_types_match_expected_set() {
assert!(is_local_file_db_type(&DatabaseType::Sqlite));
assert!(is_local_file_db_type(&DatabaseType::DuckDb));
assert!(is_local_file_db_type(&DatabaseType::Access));
assert!(is_local_file_db_type(&DatabaseType::H2));
}
#[test]
fn non_local_file_db_types_rejected() {
assert!(!is_local_file_db_type(&DatabaseType::Mysql));
assert!(!is_local_file_db_type(&DatabaseType::Postgres));
assert!(!is_local_file_db_type(&DatabaseType::Redis));
assert!(!is_local_file_db_type(&DatabaseType::MongoDb));
assert!(!is_local_file_db_type(&DatabaseType::Turso));
assert!(!is_local_file_db_type(&DatabaseType::Rqlite));
}
}