mirror of
https://github.com/gin-gonic/gin.git
synced 2026-01-15 20:17:09 +08:00
context.SaveUploadedFile: Only run Chmod if mode needs change
This commit is contained in:
parent
915e4c90d2
commit
0365757669
@ -720,7 +720,12 @@ func (c *Context) SaveUploadedFile(file *multipart.FileHeader, dst string, perm
|
||||
if err = os.MkdirAll(dir, mode); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = os.Chmod(dir, mode); err != nil {
|
||||
// Only run Chmod if mode is not as configured
|
||||
info, err := os.Stat(dir)
|
||||
if err == nil && info.Mode().Perm() != mode {
|
||||
err = os.Chmod(dir, mode)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user