about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2024-06-08 00:52:42 +0200
committerBaitinq <manuelpalenzuelamerino@gmail.com>2024-06-08 01:04:49 +0200
commit61896a6a893220219b3d5aaff2091a3a18ff8b32 (patch)
treeb4d3fe39cc409c337054c2dfbc430daa50bceeae
parentmisc: Cleanup build files (diff)
downloadfs-tracer-backend-61896a6a893220219b3d5aaff2091a3a18ff8b32.tar.gz
fs-tracer-backend-61896a6a893220219b3d5aaff2091a3a18ff8b32.tar.bz2
fs-tracer-backend-61896a6a893220219b3d5aaff2091a3a18ff8b32.zip
payload-processor: fix bug inserting multiple files
-rw-r--r--src/payload-processor/processor/db.go7
1 files changed, 6 insertions, 1 deletions
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
 }