aboutsummaryrefslogtreecommitdiff
path: root/modules/options/static.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/options/static.go')
-rw-r--r--modules/options/static.go50
1 files changed, 6 insertions, 44 deletions
diff --git a/modules/options/static.go b/modules/options/static.go
index 2405d658b..549f4e25b 100644
--- a/modules/options/static.go
+++ b/modules/options/static.go
@@ -8,10 +8,8 @@ package options
import (
"fmt"
"io"
- "io/fs"
"os"
"path"
- "path/filepath"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
@@ -28,17 +26,14 @@ func Dir(name string) ([]string, error) {
var result []string
- customDir := path.Join(setting.CustomPath, "options", name)
- isDir, err := util.IsDir(customDir)
- if err != nil {
- return []string{}, fmt.Errorf("unable to check if custom directory %q is a directory. %w", customDir, err)
- }
- if isDir {
- files, err := util.StatDir(customDir, true)
+ for _, dir := range []string{
+ path.Join(setting.CustomPath, "options", name), // custom dir
+ // no static dir
+ } {
+ files, err := statDirIfExist(dir)
if err != nil {
- return []string{}, fmt.Errorf("unable to read custom directory %q. %w", customDir, err)
+ return nil, err
}
-
result = append(result, files...)
}
@@ -69,39 +64,6 @@ func AssetDir(dirName string) ([]string, error) {
return results, nil
}
-// Locale reads the content of a specific locale from bindata or custom path.
-func Locale(name string) ([]byte, error) {
- return fileFromDir(path.Join("locale", name))
-}
-
-// WalkLocales reads the content of a specific locale from static or custom path.
-func WalkLocales(callback func(path, name string, d fs.DirEntry, err error) error) error {
- if err := walkAssetDir(filepath.Join(setting.CustomPath, "options", "locale"), callback); err != nil && !os.IsNotExist(err) {
- return fmt.Errorf("failed to walk locales. Error: %w", err)
- }
- return nil
-}
-
-// Readme reads the content of a specific readme from bindata or custom path.
-func Readme(name string) ([]byte, error) {
- return fileFromDir(path.Join("readme", path.Clean("/"+name)))
-}
-
-// Gitignore reads the content of a gitignore locale from bindata or custom path.
-func Gitignore(name string) ([]byte, error) {
- return fileFromDir(path.Join("gitignore", path.Clean("/"+name)))
-}
-
-// License reads the content of a specific license from bindata or custom path.
-func License(name string) ([]byte, error) {
- return fileFromDir(path.Join("license", path.Clean("/"+name)))
-}
-
-// Labels reads the content of a specific labels from static or custom path.
-func Labels(name string) ([]byte, error) {
- return fileFromDir(path.Join("label", path.Clean("/"+name)))
-}
-
// fileFromDir is a helper to read files from bindata or custom path.
func fileFromDir(name string) ([]byte, error) {
customPath := path.Join(setting.CustomPath, "options", name)