Fix bd-663: Treat metadata errors as first import instead of failing

- GetMetadata() failures now set lastHash='' instead of returning early
- Allows auto-import to recover from corrupt/missing metadata
- Prevents auto-import from being permanently disabled
- All tests pass

Amp-Thread-ID: https://ampcode.com/threads/T-4e4a57c4-9ac0-43dc-a78e-b7e88123cc65
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Steve Yegge
2025-10-16 19:15:48 -07:00
parent ef31d98b43
commit 27542648ad
2 changed files with 5 additions and 5 deletions

View File

@@ -188,12 +188,12 @@ func autoImportIfNewer() {
ctx := context.Background()
lastHash, err := store.GetMetadata(ctx, "last_import_hash")
if err != nil {
// Metadata not supported or error reading - this shouldn't happen
// since we added metadata table, but be defensive
// Metadata error - treat as first import rather than skipping (bd-663)
// This allows auto-import to recover from corrupt/missing metadata
if os.Getenv("BD_DEBUG") != "" {
fmt.Fprintf(os.Stderr, "Debug: auto-import skipped, metadata error: %v\n", err)
fmt.Fprintf(os.Stderr, "Debug: metadata read failed (%v), treating as first import\n", err)
}
return
lastHash = ""
}
// Compare hashes