aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2022-06-16 22:36:03 +0200
committerGabriel A. Giovanini <mail@gabrielgio.me>2022-06-16 22:42:30 +0200
commit73b1e5746a3f074aa103b5914a02769ff057c56e (patch)
treeb9a5130f043310a8b7d1a1191acbf9b61eaa3215
parentdb7e822dda56d32135eca6d3e3211a50cf93d31a (diff)
downloadmdir-73b1e5746a3f074aa103b5914a02769ff057c56e.tar.gz
mdir-73b1e5746a3f074aa103b5914a02769ff057c56e.tar.bz2
mdir-73b1e5746a3f074aa103b5914a02769ff057c56e.zip
fix: Pass entry as reference
It was not getting the object created by gorm so `.ID` was 0 causing all sort of weird iterations. That is also cause by the lack of testes. That will also be fixed in the next commits.
-rw-r--r--controller/controller.go2
-rw-r--r--db/model.go4
2 files changed, 3 insertions, 3 deletions
diff --git a/controller/controller.go b/controller/controller.go
index 7cbee6a..7fc8748 100644
--- a/controller/controller.go
+++ b/controller/controller.go
@@ -38,7 +38,7 @@ func (e *Env) UpdateEntry(c *gin.Context) {
func (e *Env) CreateEntry(c *gin.Context) {
var entry db.Entry
c.ShouldBind(&entry)
- e.Entries.Create(entry)
+ e.Entries.Create(&entry)
e.Worker.SpawnWorker(entry.ID, entry.Link, entry.OutputFolder)
c.Redirect(http.StatusFound, "/")
}
diff --git a/db/model.go b/db/model.go
index 4b814f9..01d9b9f 100644
--- a/db/model.go
+++ b/db/model.go
@@ -29,8 +29,8 @@ func (m EntryModel) All() []Entry {
return entries
}
-func (m EntryModel) Create(entry Entry) {
- m.DB.Create(&entry)
+func (m EntryModel) Create(entry *Entry) {
+ m.DB.Create(entry)
}
func (m EntryModel) Update(entry Entry) {