Skip to content

Commit 399a534

Browse files
committed
chore: annotate creation date in entry metadata
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
1 parent a1a5d2e commit 399a534

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

routes.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ func deleteEntryFromCollection(collections collectionList) func(c echo.Context)
184184

185185
remainingEntries := collection.ListDocuments()
186186
response := successResponse("Entry deleted successfully", map[string]interface{}{
187-
"deleted_entry": r.Entry,
187+
"deleted_entry": r.Entry,
188188
"remaining_entries": remainingEntries,
189-
"entry_count": len(remainingEntries),
189+
"entry_count": len(remainingEntries),
190190
})
191191
return c.JSON(http.StatusOK, response)
192192
}
@@ -351,8 +351,10 @@ func uploadFile(collections collectionList, fileAssets string) func(c echo.Conte
351351
return c.JSON(http.StatusBadRequest, errorResponse(ErrCodeConflict, "Entry already exists", fmt.Sprintf("File '%s' has already been uploaded to collection '%s'", file.Filename, name)))
352352
}
353353

354+
now := time.Now().Format(time.RFC3339)
355+
354356
// Save the file to disk
355-
err = collection.Store(filePath, map[string]string{})
357+
err = collection.Store(filePath, map[string]string{"created_at": now})
356358
if err != nil {
357359
xlog.Error("Failed to store file", err)
358360
return c.JSON(http.StatusInternalServerError, errorResponse(ErrCodeInternalError, "Failed to store file", err.Error()))
@@ -361,7 +363,7 @@ func uploadFile(collections collectionList, fileAssets string) func(c echo.Conte
361363
response := successResponse("File uploaded successfully", map[string]interface{}{
362364
"filename": file.Filename,
363365
"collection": name,
364-
"uploaded_at": time.Now().Format(time.RFC3339),
366+
"created_at": now,
365367
})
366368
return c.JSON(http.StatusOK, response)
367369
}

0 commit comments

Comments
 (0)