feat: Allow file and directory creation modes to be configured
The defaults remain the same as before. For now, the config options are global instead of per-user. Note also that the BoltDB creation maintains the old default mode of 0640 since it's not really a user-facing filesystem manipulation. Fixes #5316, #5200
This commit is contained in:
committed by
Henrique Dias
parent
5b7ea9f95a
commit
21ad653b7e
@@ -92,7 +92,7 @@ func tusPostHandler() handleFunc {
|
||||
case errors.Is(err, afero.ErrFileNotFound):
|
||||
dirPath := filepath.Dir(r.URL.Path)
|
||||
if _, statErr := d.user.Fs.Stat(dirPath); os.IsNotExist(statErr) {
|
||||
if mkdirErr := d.user.Fs.MkdirAll(dirPath, files.PermDir); mkdirErr != nil {
|
||||
if mkdirErr := d.user.Fs.MkdirAll(dirPath, d.settings.DirMode); mkdirErr != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,7 @@ func tusPostHandler() handleFunc {
|
||||
fileFlags |= os.O_TRUNC
|
||||
}
|
||||
|
||||
openFile, err := d.user.Fs.OpenFile(r.URL.Path, fileFlags, files.PermFile)
|
||||
openFile, err := d.user.Fs.OpenFile(r.URL.Path, fileFlags, d.settings.FileMode)
|
||||
if err != nil {
|
||||
return errToStatus(err), err
|
||||
}
|
||||
@@ -239,7 +239,7 @@ func tusPatchHandler() handleFunc {
|
||||
)
|
||||
}
|
||||
|
||||
openFile, err := d.user.Fs.OpenFile(r.URL.Path, os.O_WRONLY|os.O_APPEND, files.PermFile)
|
||||
openFile, err := d.user.Fs.OpenFile(r.URL.Path, os.O_WRONLY|os.O_APPEND, d.settings.FileMode)
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, fmt.Errorf("could not open file: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user