From 1a0e40b58f485d80d8cc962e806ac7130f534833 Mon Sep 17 00:00:00 2001 From: Antonio Mika Date: Fri, 10 Nov 2023 14:09:55 -0500 Subject: [PATCH] Properly update post time when updated --- filehandlers/imgs/img.go | 3 +++ filehandlers/post_handler.go | 2 ++ 2 files changed, 5 insertions(+) diff --git a/filehandlers/imgs/img.go b/filehandlers/imgs/img.go index 58c02faa..9799461b 100644 --- a/filehandlers/imgs/img.go +++ b/filehandlers/imgs/img.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "strings" + "time" "github.com/charmbracelet/ssh" "github.com/picosh/pico/db" @@ -199,6 +200,7 @@ func (h *UploadImgHandler) writeImg(s ssh.Session, data *PostMetaData) error { } h.Cfg.Logger.Infof("(%s) found, updating record", data.Filename) + now := time.Now() updatePost := db.Post{ ID: data.Cur.ID, @@ -211,6 +213,7 @@ func (h *UploadImgHandler) writeImg(s ssh.Session, data *PostMetaData) error { Text: data.Text, Title: data.Title, Hidden: data.Hidden, + UpdatedAt: &now, } _, err = h.DBPool.UpdatePost(&updatePost) if err != nil { diff --git a/filehandlers/post_handler.go b/filehandlers/post_handler.go index b97d7379..21139206 100644 --- a/filehandlers/post_handler.go +++ b/filehandlers/post_handler.go @@ -302,6 +302,7 @@ func (h *ScpUploadHandler) Write(s ssh.Session, entry *utils.FileEntry) (string, } logger.Infof("(%s) found, updating record", filename) + now := time.Now() updatePost := db.Post{ ID: post.ID, @@ -314,6 +315,7 @@ func (h *ScpUploadHandler) Write(s ssh.Session, entry *utils.FileEntry) (string, Text: metadata.Text, Title: metadata.Title, Hidden: metadata.Hidden, + UpdatedAt: &now, } _, err = h.DBPool.UpdatePost(&updatePost) if err != nil {