mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-03 03:36:22 -07:00
Don't depend on each file handler function to get file size
This commit is contained in:
parent
cfbe7a8ffb
commit
b0e81aac99
4 changed files with 3 additions and 19 deletions
|
@ -71,6 +71,7 @@ func AttachUploadFromRequest(request *http.Request, writer http.ResponseWriter,
|
||||||
}
|
}
|
||||||
upload := &gcsql.Upload{
|
upload := &gcsql.Upload{
|
||||||
OriginalFilename: html.EscapeString(handler.Filename),
|
OriginalFilename: html.EscapeString(handler.Filename),
|
||||||
|
FileSize: int(handler.Size),
|
||||||
}
|
}
|
||||||
gcutil.LogStr("originalFilename", upload.OriginalFilename, errEv, infoEv)
|
gcutil.LogStr("originalFilename", upload.OriginalFilename, errEv, infoEv)
|
||||||
|
|
||||||
|
|
|
@ -54,14 +54,6 @@ func processImage(upload *gcsql.Upload, post *gcsql.Post, board string, filePath
|
||||||
Str("filePath", filePath).Send()
|
Str("filePath", filePath).Send()
|
||||||
return err
|
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
|
// Get image width and height, as well as thumbnail width and height
|
||||||
upload.Width = img.Bounds().Max.X
|
upload.Width = img.Bounds().Max.X
|
||||||
|
|
|
@ -24,14 +24,6 @@ func processOther(upload *gcsql.Upload, post *gcsql.Post, board string, filePath
|
||||||
}
|
}
|
||||||
infoEv.Str("post", "withOther")
|
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 {
|
if post.ThreadID == 0 {
|
||||||
// OP
|
// OP
|
||||||
upload.ThumbnailWidth = boardConfig.ThumbWidth
|
upload.ThumbnailWidth = boardConfig.ThumbWidth
|
||||||
|
@ -43,7 +35,8 @@ func processOther(upload *gcsql.Upload, post *gcsql.Post, board string, filePath
|
||||||
}
|
}
|
||||||
staticThumbPath := path.Join("static/", cfgThumb)
|
staticThumbPath := path.Join("static/", cfgThumb)
|
||||||
originalThumbPath := path.Join(config.GetSystemCriticalConfig().DocumentRoot, staticThumbPath)
|
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()
|
errEv.Err(err).Str("originalThumbPath", originalThumbPath).Send()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,8 +58,6 @@ func processVideo(upload *gcsql.Upload, post *gcsql.Post, board string, filePath
|
||||||
upload.Width = value
|
upload.Width = value
|
||||||
case "height":
|
case "height":
|
||||||
upload.Height = value
|
upload.Height = value
|
||||||
case "size":
|
|
||||||
upload.FileSize = value
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
thumbType := ThumbnailReply
|
thumbType := ThumbnailReply
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue