diff --git a/pkg/posting/uploads/attach.go b/pkg/posting/uploads/attach.go index b44981a7..af1c444b 100644 --- a/pkg/posting/uploads/attach.go +++ b/pkg/posting/uploads/attach.go @@ -71,6 +71,7 @@ func AttachUploadFromRequest(request *http.Request, writer http.ResponseWriter, } upload := &gcsql.Upload{ OriginalFilename: html.EscapeString(handler.Filename), + FileSize: int(handler.Size), } gcutil.LogStr("originalFilename", upload.OriginalFilename, errEv, infoEv) diff --git a/pkg/posting/uploads/processimage.go b/pkg/posting/uploads/processimage.go index 215cd441..432da251 100644 --- a/pkg/posting/uploads/processimage.go +++ b/pkg/posting/uploads/processimage.go @@ -54,14 +54,6 @@ func processImage(upload *gcsql.Upload, post *gcsql.Post, board string, filePath Str("filePath", filePath).Send() return err } - // Get image filesize - stat, err := os.Stat(filePath) - if err != nil { - errEv.Err(err).Caller(). - Str("filePath", filePath).Send() - return err - } - upload.FileSize = int(stat.Size()) // Get image width and height, as well as thumbnail width and height upload.Width = img.Bounds().Max.X diff --git a/pkg/posting/uploads/processother.go b/pkg/posting/uploads/processother.go index b5acf8b8..001efe68 100644 --- a/pkg/posting/uploads/processother.go +++ b/pkg/posting/uploads/processother.go @@ -24,14 +24,6 @@ func processOther(upload *gcsql.Upload, post *gcsql.Post, board string, filePath } infoEv.Str("post", "withOther") - stat, err := os.Stat(filePath) - if err != nil { - errEv.Err(err).Caller(). - Str("filePath", filePath).Send() - return err - } - - upload.FileSize = int(stat.Size()) if post.ThreadID == 0 { // OP upload.ThumbnailWidth = boardConfig.ThumbWidth @@ -43,7 +35,8 @@ func processOther(upload *gcsql.Upload, post *gcsql.Post, board string, filePath } staticThumbPath := path.Join("static/", cfgThumb) originalThumbPath := path.Join(config.GetSystemCriticalConfig().DocumentRoot, staticThumbPath) - if _, err = os.Stat(originalThumbPath); err != nil { + _, err := os.Stat(originalThumbPath) + if err != nil { errEv.Err(err).Str("originalThumbPath", originalThumbPath).Send() return err } diff --git a/pkg/posting/uploads/processvideo.go b/pkg/posting/uploads/processvideo.go index 1272f75a..1a537f3e 100644 --- a/pkg/posting/uploads/processvideo.go +++ b/pkg/posting/uploads/processvideo.go @@ -58,8 +58,6 @@ func processVideo(upload *gcsql.Upload, post *gcsql.Post, board string, filePath upload.Width = value case "height": upload.Height = value - case "size": - upload.FileSize = value } } thumbType := ThumbnailReply