Skip to content

Commit

Permalink
Use modtime from client, not now
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniomika committed Nov 10, 2023
1 parent 1a0e40b commit e571347
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions filehandlers/imgs/img.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ func (h *UploadImgHandler) writeImg(s ssh.Session, data *PostMetaData) error {
}

h.Cfg.Logger.Infof("(%s) found, updating record", data.Filename)
now := time.Now()

modTime := time.Unix(data.Mtime, 0)

updatePost := db.Post{
ID: data.Cur.ID,

Expand All @@ -213,7 +215,7 @@ func (h *UploadImgHandler) writeImg(s ssh.Session, data *PostMetaData) error {
Text: data.Text,
Title: data.Title,
Hidden: data.Hidden,
UpdatedAt: &now,
UpdatedAt: &modTime,
}
_, err = h.DBPool.UpdatePost(&updatePost)
if err != nil {
Expand Down
6 changes: 4 additions & 2 deletions filehandlers/post_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,9 @@ func (h *ScpUploadHandler) Write(s ssh.Session, entry *utils.FileEntry) (string,
}

logger.Infof("(%s) found, updating record", filename)
now := time.Now()

modTime := time.Unix(entry.Mtime, 0)

updatePost := db.Post{
ID: post.ID,

Expand All @@ -315,7 +317,7 @@ func (h *ScpUploadHandler) Write(s ssh.Session, entry *utils.FileEntry) (string,
Text: metadata.Text,
Title: metadata.Title,
Hidden: metadata.Hidden,
UpdatedAt: &now,
UpdatedAt: &modTime,
}
_, err = h.DBPool.UpdatePost(&updatePost)
if err != nil {
Expand Down

0 comments on commit e571347

Please sign in to comment.