(cg: &crate::tracedecay::TraceDecay)
| 214 | // --------------------------------------------------------------------------- |
| 215 | |
| 216 | async fn sample_database(cg: &crate::tracedecay::TraceDecay) -> Result<DatabaseSnapshot> { |
| 217 | let project_root = cg.project_root().to_path_buf(); |
| 218 | let db_path = cg.db_path().clone(); |
| 219 | let db_size_bytes = file_size(&db_path); |
| 220 | let wal_size_bytes = file_size(&with_suffix(&db_path, "-wal")); |
| 221 | let shm_size_bytes = file_size(&with_suffix(&db_path, "-shm")); |
| 222 | let journal_mode = read_journal_mode(cg).await.ok(); |
| 223 | let source_total_bytes = read_source_total_bytes(cg).await.unwrap_or(0); |
| 224 | let (node_count, edge_count) = read_graph_counts(cg).await.unwrap_or((0, 0)); |
| 225 | Ok(DatabaseSnapshot { |
| 226 | project_root, |
| 227 | db_path, |
| 228 | db_size_bytes, |
| 229 | wal_size_bytes, |
| 230 | shm_size_bytes, |
| 231 | journal_mode, |
| 232 | source_total_bytes, |
| 233 | node_count, |
| 234 | edge_count, |
| 235 | }) |
| 236 | } |
| 237 | |
| 238 | fn file_size(path: &Path) -> u64 { |
| 239 | std::fs::metadata(path).map_or(0, |m| m.len()) |
no test coverage detected