summaryrefslogtreecommitdiffstats
path: root/modules/templates/dynamic.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/templates/dynamic.go')
-rw-r--r--modules/templates/dynamic.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/modules/templates/dynamic.go b/modules/templates/dynamic.go
index 4896580f62..a86e71a8c8 100644
--- a/modules/templates/dynamic.go
+++ b/modules/templates/dynamic.go
@@ -33,6 +33,21 @@ func GetAsset(name string) ([]byte, error) {
return os.ReadFile(filepath.Join(setting.StaticRootPath, name))
}
+// GetAssetFilename returns the filename of the provided asset
+func GetAssetFilename(name string) (string, error) {
+ filename := filepath.Join(setting.CustomPath, name)
+ _, err := os.Stat(filename)
+ if err != nil && !os.IsNotExist(err) {
+ return filename, err
+ } else if err == nil {
+ return filename, nil
+ }
+
+ filename = filepath.Join(setting.StaticRootPath, name)
+ _, err = os.Stat(filename)
+ return filename, err
+}
+
// walkTemplateFiles calls a callback for each template asset
func walkTemplateFiles(callback func(path, name string, d fs.DirEntry, err error) error) error {
if err := walkAssetDir(filepath.Join(setting.CustomPath, "templates"), true, callback); err != nil && !os.IsNotExist(err) {