MM-27178: Use FileSettings.Directory in export tool (#15100)
* MM-27178: use FileSettings.Directory in export * Set empty FileSettings.Directory to default value * Validate that FileSettings.Directory is non-empty * Don't set FileSettings.Directory to / in fixConfig * Run make i18n-extract Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
8b7e00f0f7
Коммит
70e649b36a
@@ -206,6 +206,11 @@ func bulkExportCmdF(command *cobra.Command, args []string) error {
|
|||||||
// Path to directory of custom emoji
|
// Path to directory of custom emoji
|
||||||
pathToEmojiDir := "data/emoji/"
|
pathToEmojiDir := "data/emoji/"
|
||||||
|
|
||||||
|
customDataDir := a.Config().FileSettings.Directory
|
||||||
|
if customDataDir != nil && *customDataDir != "" {
|
||||||
|
pathToEmojiDir = *customDataDir + "emoji/"
|
||||||
|
}
|
||||||
|
|
||||||
// Name of the directory to export custom emoji
|
// Name of the directory to export custom emoji
|
||||||
dirNameToExportEmoji := "exported_emoji"
|
dirNameToExportEmoji := "exported_emoji"
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ func fixConfig(cfg *model.Config) bool {
|
|||||||
|
|
||||||
// Ensure the directory for a local file store has a trailing slash.
|
// Ensure the directory for a local file store has a trailing slash.
|
||||||
if *cfg.FileSettings.DriverName == model.IMAGE_DRIVER_LOCAL {
|
if *cfg.FileSettings.DriverName == model.IMAGE_DRIVER_LOCAL {
|
||||||
if !strings.HasSuffix(*cfg.FileSettings.Directory, "/") {
|
if *cfg.FileSettings.Directory != "" && !strings.HasSuffix(*cfg.FileSettings.Directory, "/") {
|
||||||
*cfg.FileSettings.Directory += "/"
|
*cfg.FileSettings.Directory += "/"
|
||||||
changed = true
|
changed = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5722,6 +5722,10 @@
|
|||||||
"id": "model.config.is_valid.data_retention.message_retention_days_too_low.app_error",
|
"id": "model.config.is_valid.data_retention.message_retention_days_too_low.app_error",
|
||||||
"translation": "Message retention must be one day or longer."
|
"translation": "Message retention must be one day or longer."
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "model.config.is_valid.directory.app_error",
|
||||||
|
"translation": "Invalid Local Storage Directory. Must be a non-empty string."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "model.config.is_valid.display.custom_url_schemes.app_error",
|
"id": "model.config.is_valid.display.custom_url_schemes.app_error",
|
||||||
"translation": "The custom URL scheme {{.Scheme}} is invalid. Custom URL schemes must start with a letter and contain only letters, numbers, plus (+), period (.) and hyphen (-)."
|
"translation": "The custom URL scheme {{.Scheme}} is invalid. Custom URL schemes must start with a letter and contain only letters, numbers, plus (+), period (.) and hyphen (-)."
|
||||||
|
|||||||
@@ -1280,7 +1280,7 @@ func (s *FileSettings) SetDefaults(isUpdate bool) {
|
|||||||
s.DriverName = NewString(IMAGE_DRIVER_LOCAL)
|
s.DriverName = NewString(IMAGE_DRIVER_LOCAL)
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.Directory == nil {
|
if s.Directory == nil || *s.Directory == "" {
|
||||||
s.Directory = NewString(FILE_SETTINGS_DEFAULT_DIRECTORY)
|
s.Directory = NewString(FILE_SETTINGS_DEFAULT_DIRECTORY)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3018,6 +3018,10 @@ func (s *FileSettings) isValid() *AppError {
|
|||||||
return NewAppError("Config.IsValid", "model.config.is_valid.file_salt.app_error", nil, "", http.StatusBadRequest)
|
return NewAppError("Config.IsValid", "model.config.is_valid.file_salt.app_error", nil, "", http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if *s.Directory == "" {
|
||||||
|
return NewAppError("Config.IsValid", "model.config.is_valid.directory.app_error", nil, "", http.StatusBadRequest)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user