feat(metadata): enhance metadata handling by sanitizing extracted data and updating documentation for file storage
This commit is contained in:
@@ -110,6 +110,15 @@ func MarkMetadataComplete(base thoughttypes.ThoughtMetadata, capture config.Capt
|
||||
return out
|
||||
}
|
||||
|
||||
func SanitizeExtracted(in thoughttypes.ThoughtMetadata) thoughttypes.ThoughtMetadata {
|
||||
in.Attachments = nil
|
||||
in.MetadataStatus = ""
|
||||
in.MetadataUpdatedAt = ""
|
||||
in.MetadataLastAttemptedAt = ""
|
||||
in.MetadataError = ""
|
||||
return in
|
||||
}
|
||||
|
||||
func normalizeList(values []string, limit int) []string {
|
||||
seen := make(map[string]struct{}, len(values))
|
||||
result := make([]string, 0, len(values))
|
||||
|
||||
@@ -107,6 +107,38 @@ func TestNormalizeDedupesAttachmentsByFileID(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSanitizeExtractedDropsAttachmentsAndMetadataControlFields(t *testing.T) {
|
||||
id := uuid.New()
|
||||
|
||||
got := SanitizeExtracted(thoughttypes.ThoughtMetadata{
|
||||
Type: "idea",
|
||||
Attachments: []thoughttypes.ThoughtAttachment{{FileID: id, Name: "secret.pdf"}},
|
||||
MetadataStatus: MetadataStatusFailed,
|
||||
MetadataUpdatedAt: "2026-03-30T10:00:00Z",
|
||||
MetadataLastAttemptedAt: "2026-03-30T10:01:00Z",
|
||||
MetadataError: "boom",
|
||||
})
|
||||
|
||||
if len(got.Attachments) != 0 {
|
||||
t.Fatalf("Attachments len = %d, want 0", len(got.Attachments))
|
||||
}
|
||||
if got.MetadataStatus != "" {
|
||||
t.Fatalf("MetadataStatus = %q, want empty", got.MetadataStatus)
|
||||
}
|
||||
if got.MetadataUpdatedAt != "" {
|
||||
t.Fatalf("MetadataUpdatedAt = %q, want empty", got.MetadataUpdatedAt)
|
||||
}
|
||||
if got.MetadataLastAttemptedAt != "" {
|
||||
t.Fatalf("MetadataLastAttemptedAt = %q, want empty", got.MetadataLastAttemptedAt)
|
||||
}
|
||||
if got.MetadataError != "" {
|
||||
t.Fatalf("MetadataError = %q, want empty", got.MetadataError)
|
||||
}
|
||||
if got.Type != "idea" {
|
||||
t.Fatalf("Type = %q, want idea", got.Type)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarkMetadataPendingTracksAttemptWithoutClearingPreviousSuccess(t *testing.T) {
|
||||
attempt := time.Date(2026, 3, 30, 10, 0, 0, 0, time.UTC)
|
||||
base := thoughttypes.ThoughtMetadata{
|
||||
|
||||
Reference in New Issue
Block a user