Merge branch 'main' of https://github.com/steveyegge/beads
This commit is contained in:
1366
.beads/beads.jsonl
1366
.beads/beads.jsonl
File diff suppressed because one or more lines are too long
@@ -33,7 +33,8 @@ func ensureDatabaseFresh(ctx context.Context) error {
|
||||
if err != nil {
|
||||
// If we can't determine staleness, allow operation to proceed
|
||||
// (better to show potentially stale data than block user)
|
||||
fmt.Fprintf(os.Stderr, "Warning: could not check database staleness: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "Warning: Could not verify database freshness: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "Proceeding anyway. Data may be stale.\n\n")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -262,10 +262,16 @@ func CheckStaleness(ctx context.Context, store storage.Storage, dbPath string) (
|
||||
return false, nil
|
||||
}
|
||||
|
||||
// Empty string means no metadata was set (memory store behavior)
|
||||
if lastImportStr == "" {
|
||||
// No metadata yet - expected for first run
|
||||
return false, nil
|
||||
}
|
||||
|
||||
lastImportTime, err := time.Parse(time.RFC3339, lastImportStr)
|
||||
if err != nil {
|
||||
// Corrupted metadata - not critical, assume not stale
|
||||
return false, nil
|
||||
// Corrupted metadata - this is abnormal and should be reported
|
||||
return false, fmt.Errorf("corrupted last_import_time in metadata (cannot parse as RFC3339): %w", err)
|
||||
}
|
||||
|
||||
// Find JSONL using database directory
|
||||
|
||||
@@ -343,6 +343,30 @@ func TestCheckStaleness_NewerJSONL(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckStaleness_CorruptedMetadata(t *testing.T) {
|
||||
store := memory.New("")
|
||||
ctx := context.Background()
|
||||
|
||||
tmpDir, err := os.MkdirTemp("", "bd-stale-test-*")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
dbPath := filepath.Join(tmpDir, "bd.db")
|
||||
|
||||
// Set invalid timestamp format
|
||||
store.SetMetadata(ctx, "last_import_time", "not-a-valid-timestamp")
|
||||
|
||||
_, err = CheckStaleness(ctx, store, dbPath)
|
||||
if err == nil {
|
||||
t.Error("Expected error for corrupted metadata, got nil")
|
||||
}
|
||||
if err != nil && !strings.Contains(err.Error(), "corrupted last_import_time") {
|
||||
t.Errorf("Expected 'corrupted last_import_time' error, got: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckForMergeConflicts(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
Reference in New Issue
Block a user