/{website,internal,docs,cmd}: integration tests and more split backend fixes

This commit is contained in:
coffeegoddd☕️✨
2026-01-20 13:39:04 -08:00
parent ba432847e0
commit 422bc838ed
21 changed files with 892 additions and 156 deletions

View File

@@ -267,9 +267,10 @@ func sanitizeMetadataKey(key string) string {
// This function does NOT provide atomicity between JSONL write, metadata updates, and DB mtime.
// If a crash occurs between these operations, metadata may be inconsistent. However, this is
// acceptable because:
// 1. The worst case is "JSONL content has changed" error on next export
// 2. User can fix by running 'bd import' (safe, no data loss)
// 3. Current approach is simple and doesn't require complex WAL or format changes
// 1. The worst case is "JSONL content has changed" error on next export
// 2. User can fix by running 'bd import' (safe, no data loss)
// 3. Current approach is simple and doesn't require complex WAL or format changes
//
// Future: Consider defensive checks on startup if this becomes a common issue.
func updateExportMetadata(ctx context.Context, store storage.Storage, jsonlPath string, log daemonLogger, keySuffix string) {
// Sanitize keySuffix to handle Windows paths with colons
@@ -456,9 +457,12 @@ func performExport(ctx context.Context, store storage.Storage, autoCommit, autoP
// Update database mtime to be >= JSONL mtime (fixes #278, #301, #321)
// This prevents validatePreExport from incorrectly blocking on next export
// with "JSONL is newer than database" after daemon auto-export
dbPath := filepath.Join(beadsDir, "beads.db")
if err := TouchDatabaseFile(dbPath, jsonlPath); err != nil {
log.log("Warning: failed to update database mtime: %v", err)
// Dolt backend does not have a SQLite DB file; mtime touch is SQLite-only.
if _, ok := store.(*sqlite.SQLiteStorage); ok {
dbPath := filepath.Join(beadsDir, "beads.db")
if err := TouchDatabaseFile(dbPath, jsonlPath); err != nil {
log.log("Warning: failed to update database mtime: %v", err)
}
}
}
@@ -755,8 +759,11 @@ func performSync(ctx context.Context, store storage.Storage, autoCommit, autoPus
// Update database mtime to be >= JSONL mtime
// This prevents validatePreExport from incorrectly blocking on next export
if err := TouchDatabaseFile(dbPath, jsonlPath); err != nil {
log.log("Warning: failed to update database mtime: %v", err)
// Dolt backend does not have a SQLite DB file; mtime touch is SQLite-only.
if _, ok := store.(*sqlite.SQLiteStorage); ok {
if err := TouchDatabaseFile(dbPath, jsonlPath); err != nil {
log.log("Warning: failed to update database mtime: %v", err)
}
}
}
@@ -872,8 +879,11 @@ func performSync(ctx context.Context, store storage.Storage, autoCommit, autoPus
// Update database mtime after import (fixes #278, #301, #321)
// Sync branch import can update JSONL timestamp, so ensure DB >= JSONL
if err := TouchDatabaseFile(dbPath, jsonlPath); err != nil {
log.log("Warning: failed to update database mtime: %v", err)
// Dolt backend does not have a SQLite DB file; mtime touch is SQLite-only.
if _, ok := store.(*sqlite.SQLiteStorage); ok {
if err := TouchDatabaseFile(dbPath, jsonlPath); err != nil {
log.log("Warning: failed to update database mtime: %v", err)
}
}
// Validate import didn't cause data loss