Skip to content

Commit

Permalink
Properly update post time when updated
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniomika committed Nov 10, 2023
1 parent 0c6b9a9 commit 1a0e40b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions filehandlers/imgs/img.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"strings"
"time"

"github.com/charmbracelet/ssh"
"github.com/picosh/pico/db"
Expand Down Expand Up @@ -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,

Expand All @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions filehandlers/post_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -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 {
Expand Down

0 comments on commit 1a0e40b

Please sign in to comment.