mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-06 14:20:55 +03:00
@@ -183,13 +183,6 @@ const (
|
||||
I18nOIDCTokenInvalidRoleAdmin = "oidc.role_admin_err"
|
||||
I18nOIDCTokenInvalidRoleUser = "oidc.role_user_err"
|
||||
I18nOIDCErrGetUser = "oidc.get_user_err"
|
||||
I18nStorageLocal = "storage.local"
|
||||
I18nStorageLocalEncrypted = "storage.encrypted"
|
||||
I18nStorageS3 = "storage.s3"
|
||||
I18nStorageGCS = "storage.gcs"
|
||||
I18nStorageAzureBlob = "storage.azblob"
|
||||
I18nStorageSFTP = "storage.sftp"
|
||||
I18nStorageHTTP = "storage.http"
|
||||
I18nErrorInvalidQuotaSize = "user.invalid_quota_size"
|
||||
I18nErrorTimeOfDayInvalid = "user.time_of_day_invalid"
|
||||
I18nErrorTimeOfDayConflict = "user.time_of_day_conflict"
|
||||
|
||||
@@ -58,25 +58,29 @@ func FindSharedDataPath(name, searchDir string) string {
|
||||
|
||||
// LoadTemplate parses the given template paths.
|
||||
// It behaves like template.Must but it writes a log before exiting.
|
||||
// You can optionally provide a base template (e.g. to define some custom functions)
|
||||
func LoadTemplate(base *template.Template, paths ...string) *template.Template {
|
||||
var t *template.Template
|
||||
var err error
|
||||
|
||||
if base != nil {
|
||||
base, err = base.Clone()
|
||||
if err == nil {
|
||||
t, err = base.ParseFiles(paths...)
|
||||
baseTmpl, err := base.Clone()
|
||||
if err != nil {
|
||||
showTemplateLoadingError(err)
|
||||
}
|
||||
} else {
|
||||
t, err = template.ParseFiles(paths...)
|
||||
t, err := baseTmpl.ParseFiles(paths...)
|
||||
if err != nil {
|
||||
showTemplateLoadingError(err)
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
t, err := template.ParseFiles(paths...)
|
||||
if err != nil {
|
||||
logger.ErrorToConsole("error loading required template: %v", err)
|
||||
logger.ErrorToConsole(templateLoadErrorHints)
|
||||
logger.Error(logSender, "", "error loading required template: %v", err)
|
||||
os.Exit(1)
|
||||
showTemplateLoadingError(err)
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
func showTemplateLoadingError(err error) {
|
||||
logger.ErrorToConsole("error loading required template: %v", err)
|
||||
logger.ErrorToConsole(templateLoadErrorHints)
|
||||
logger.Error(logSender, "", "error loading required template: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user