repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

commit
e571347
parent
1a0e40b
author
Antonio Mika
date
2023-11-10 19:20:02 +0000 UTC
Use modtime from client, not now
2 files changed,  +8, -4
M filehandlers/imgs/img.go
+4, -2
 1@@ -200,7 +200,9 @@ func (h *UploadImgHandler) writeImg(s ssh.Session, data *PostMetaData) error {
 2 		}
 3 
 4 		h.Cfg.Logger.Infof("(%s) found, updating record", data.Filename)
 5-		now := time.Now()
 6+
 7+		modTime := time.Unix(data.Mtime, 0)
 8+
 9 		updatePost := db.Post{
10 			ID: data.Cur.ID,
11 
12@@ -213,7 +215,7 @@ func (h *UploadImgHandler) writeImg(s ssh.Session, data *PostMetaData) error {
13 			Text:        data.Text,
14 			Title:       data.Title,
15 			Hidden:      data.Hidden,
16-			UpdatedAt:   &now,
17+			UpdatedAt:   &modTime,
18 		}
19 		_, err = h.DBPool.UpdatePost(&updatePost)
20 		if err != nil {
M filehandlers/post_handler.go
+4, -2
 1@@ -302,7 +302,9 @@ func (h *ScpUploadHandler) Write(s ssh.Session, entry *utils.FileEntry) (string,
 2 		}
 3 
 4 		logger.Infof("(%s) found, updating record", filename)
 5-		now := time.Now()
 6+
 7+		modTime := time.Unix(entry.Mtime, 0)
 8+
 9 		updatePost := db.Post{
10 			ID: post.ID,
11 
12@@ -315,7 +317,7 @@ func (h *ScpUploadHandler) Write(s ssh.Session, entry *utils.FileEntry) (string,
13 			Text:        metadata.Text,
14 			Title:       metadata.Title,
15 			Hidden:      metadata.Hidden,
16-			UpdatedAt:   &now,
17+			UpdatedAt:   &modTime,
18 		}
19 		_, err = h.DBPool.UpdatePost(&updatePost)
20 		if err != nil {