repos / pico

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

commit
3a969c2
parent
e571347
author
Antonio Mika
date
2023-11-10 19:29:38 +0000 UTC
Properly check mod time as well for updating a post
2 files changed,  +6, -6
M filehandlers/imgs/img.go
+3, -3
 1@@ -194,15 +194,15 @@ func (h *UploadImgHandler) writeImg(s ssh.Session, data *PostMetaData) error {
 2 			}
 3 		}
 4 	} else {
 5-		if data.Shasum == data.Cur.Shasum {
 6+		modTime := time.Unix(data.Mtime, 0)
 7+
 8+		if data.Shasum == data.Cur.Shasum && modTime.Equal(*data.Cur.UpdatedAt) {
 9 			h.Cfg.Logger.Infof("(%s) found, but image is identical, skipping", data.Filename)
10 			return nil
11 		}
12 
13 		h.Cfg.Logger.Infof("(%s) found, updating record", data.Filename)
14 
15-		modTime := time.Unix(data.Mtime, 0)
16-
17 		updatePost := db.Post{
18 			ID: data.Cur.ID,
19 
M filehandlers/post_handler.go
+3, -3
 1@@ -295,7 +295,9 @@ func (h *ScpUploadHandler) Write(s ssh.Session, entry *utils.FileEntry) (string,
 2 			}
 3 		}
 4 	} else {
 5-		if metadata.Text == post.Text {
 6+		modTime := time.Unix(entry.Mtime, 0)
 7+
 8+		if metadata.Text == post.Text && modTime.Equal(*post.UpdatedAt) {
 9 			logger.Infof("(%s) found, but text is identical, skipping", filename)
10 			curl := shared.NewCreateURL(h.Cfg)
11 			return h.Cfg.FullPostURL(curl, user.Name, metadata.Slug), nil
12@@ -303,8 +305,6 @@ func (h *ScpUploadHandler) Write(s ssh.Session, entry *utils.FileEntry) (string,
13 
14 		logger.Infof("(%s) found, updating record", filename)
15 
16-		modTime := time.Unix(entry.Mtime, 0)
17-
18 		updatePost := db.Post{
19 			ID: post.ID,
20