diff options
Diffstat (limited to 'internal/db/repo_editor.go')
-rw-r--r-- | internal/db/repo_editor.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/internal/db/repo_editor.go b/internal/db/repo_editor.go index cf711557..c525bcd6 100644 --- a/internal/db/repo_editor.go +++ b/internal/db/repo_editor.go @@ -152,7 +152,9 @@ func (repo *Repository) UpdateRepoFile(doer *User, opts UpdateRepoFileOptions) ( oldFilePath := path.Join(localPath, opts.OldTreeName) filePath := path.Join(localPath, opts.NewTreeName) - os.MkdirAll(path.Dir(filePath), os.ModePerm) + if err = os.MkdirAll(path.Dir(filePath), os.ModePerm); err != nil { + return err + } // If it's meant to be a new file, make sure it doesn't exist. if opts.IsNewFile { @@ -206,7 +208,9 @@ func (repo *Repository) GetDiffPreview(branch, treePath, content string) (diff * localPath := repo.LocalCopyPath() filePath := path.Join(localPath, treePath) - os.MkdirAll(filepath.Dir(filePath), os.ModePerm) + if err = os.MkdirAll(filepath.Dir(filePath), os.ModePerm); err != nil { + return nil, err + } if err = ioutil.WriteFile(filePath, []byte(content), 0666); err != nil { return nil, fmt.Errorf("write file: %v", err) } @@ -471,7 +475,9 @@ func (repo *Repository) UploadRepoFiles(doer *User, opts UploadRepoFileOptions) localPath := repo.LocalCopyPath() dirPath := path.Join(localPath, opts.TreePath) - os.MkdirAll(dirPath, os.ModePerm) + if err = os.MkdirAll(dirPath, os.ModePerm); err != nil { + return err + } // Copy uploaded files into repository for _, upload := range uploads { |