fix: files and directories are created with the correct permissions (#2966)

This commit is contained in:
ねらひかだ 2024-01-30 18:12:38 +09:00 committed by GitHub
parent 04e03a83b4
commit 5c5ab6b875
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 6 deletions

View file

@ -98,7 +98,7 @@ func resourcePostHandler(fileCache FileCache) handleFunc {
// Directories creation on POST.
if strings.HasSuffix(r.URL.Path, "/") {
err := d.user.Fs.MkdirAll(r.URL.Path, 0775) //nolint:gomnd
err := d.user.Fs.MkdirAll(r.URL.Path, files.PermDir)
return errToStatus(err), err
}
@ -256,12 +256,12 @@ func addVersionSuffix(source string, fs afero.Fs) string {
func writeFile(fs afero.Fs, dst string, in io.Reader) (os.FileInfo, error) {
dir, _ := path.Split(dst)
err := fs.MkdirAll(dir, 0775) //nolint:gomnd
err := fs.MkdirAll(dir, files.PermDir)
if err != nil {
return nil, err
}
file, err := fs.OpenFile(dst, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0775) //nolint:gomnd
file, err := fs.OpenFile(dst, os.O_RDWR|os.O_CREATE|os.O_TRUNC, files.PermFile)
if err != nil {
return nil, err
}