| 441 | } artifact_snapshot_tmp_t; |
| 442 | |
| 443 | static bool artifact_snapshot_tmp_open(artifact_snapshot_tmp_t *tmp) { |
| 444 | tmp->dir[0] = '\0'; |
| 445 | tmp->db[0] = '\0'; |
| 446 | int written = snprintf(tmp->dir, sizeof(tmp->dir), "%s/cbm-artifact-XXXXXX", cbm_tmpdir()); |
| 447 | if (written <= 0 || (size_t)written >= sizeof(tmp->dir) || !cbm_mkdtemp(tmp->dir)) { |
| 448 | tmp->dir[0] = '\0'; |
| 449 | return false; |
| 450 | } |
| 451 | written = snprintf(tmp->db, sizeof(tmp->db), "%s/snapshot.db", tmp->dir); |
| 452 | if (written <= 0 || (size_t)written >= sizeof(tmp->db)) { |
| 453 | (void)cbm_rmdir(tmp->dir); |
| 454 | tmp->dir[0] = '\0'; |
| 455 | return false; |
| 456 | } |
| 457 | return true; |
| 458 | } |
| 459 | |
| 460 | /* Anchored cleanup — every exit from prepare_snapshot_db runs this, so neither |
| 461 | * the copy nor its WAL/SHM sidecars outlive the export. Removing the directory |
no test coverage detected