diff --git a/internal/importer/importer.go b/internal/importer/importer.go index af424258..7bdbd433 100644 --- a/internal/importer/importer.go +++ b/internal/importer/importer.go @@ -568,6 +568,7 @@ func upsertIssues(ctx context.Context, sqliteStore *sqlite.SQLiteStorage, issues // GH#865: Check timestamp-aware protection first // If local snapshot has a newer version, protect it from being overwritten if shouldProtectFromUpdate(existing.ID, incoming.UpdatedAt, opts.ProtectLocalExportIDs) { + debugLogProtection(existing.ID, opts.ProtectLocalExportIDs[existing.ID], incoming.UpdatedAt) result.Skipped++ continue } @@ -672,6 +673,7 @@ func upsertIssues(ctx context.Context, sqliteStore *sqlite.SQLiteStorage, issues // GH#865: Check timestamp-aware protection first // If local snapshot has a newer version, protect it from being overwritten if shouldProtectFromUpdate(incoming.ID, incoming.UpdatedAt, opts.ProtectLocalExportIDs) { + debugLogProtection(incoming.ID, opts.ProtectLocalExportIDs[incoming.ID], incoming.UpdatedAt) result.Skipped++ continue } @@ -948,6 +950,14 @@ func shouldProtectFromUpdate(issueID string, incomingTime time.Time, protectMap return !incomingTime.After(localTime) } +// debugLogProtection logs when timestamp-aware protection triggers (for debugging sync issues). +func debugLogProtection(issueID string, localTime, incomingTime time.Time) { + if os.Getenv("BD_DEBUG_SYNC") != "" { + fmt.Fprintf(os.Stderr, "[debug] Protected %s: local=%s >= incoming=%s\n", + issueID, localTime.Format(time.RFC3339), incomingTime.Format(time.RFC3339)) + } +} + func GetPrefixList(prefixes map[string]int) []string { var result []string keys := make([]string, 0, len(prefixes))