mirror of
https://github.com/gin-gonic/gin.git
synced 2026-06-06 20:18:19 +08:00
context.SaveUploadedFile: Only run Chmod if mode needs change
This commit is contained in:
parent
73726dc606
commit
eb70194d4a
@ -731,7 +731,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