From 61896a6a893220219b3d5aaff2091a3a18ff8b32 Mon Sep 17 00:00:00 2001 From: Baitinq Date: Sat, 8 Jun 2024 00:52:42 +0200 Subject: payload-processor: fix bug inserting multiple files --- src/payload-processor/processor/db.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/payload-processor/processor/db.go b/src/payload-processor/processor/db.go index 607f97d..eb67a79 100644 --- a/src/payload-processor/processor/db.go +++ b/src/payload-processor/processor/db.go @@ -2,6 +2,7 @@ package processor import ( "context" + "log" "github.com/Baitinq/fs-tracer-backend/lib" "github.com/jmoiron/sqlx" @@ -25,8 +26,12 @@ func NewDB(db *sqlx.DB) DB { func (db DBImpl) InsertFiles(ctx context.Context, files []lib.File, user_id string) error { for _, file := range files { file.User_id = user_id + //TODO: Do bulk insert _, err := db.db.NamedExecContext(ctx, "INSERT INTO public.file (user_id, absolute_path, contents, timestamp) VALUES (:user_id, :absolute_path, :contents, :timestamp)", file) - return err + if err != nil { + return err + } + log.Println("Inserted file: ", file) } return nil } -- cgit 1.4.1