Unverified Commit a77e6053 authored by Mattermost Build's avatar Mattermost Build Committed by GitHub
Browse files

MM-27178: Use FileSettings.Directory in export tool (#15100) (#15210)



* 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: default avatarMattermod <mattermod@users.noreply.github.com>
(cherry picked from commit 70e649b3

)
Co-authored-by: default avatarAlejandro García Montoro <alejandro.garciamontoro@gmail.com>
parent 0f4038ae
......@@ -206,6 +206,11 @@ func bulkExportCmdF(command *cobra.Command, args []string) error {
// Path to directory of custom emoji
pathToEmojiDir := "data/emoji/"
customDataDir := a.Config().FileSettings.Directory
if customDataDir != nil && *customDataDir != "" {
pathToEmojiDir = *customDataDir + "emoji/"
}
// Name of the directory to export custom 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.
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 += "/"
changed = true
}
......
......@@ -5502,6 +5502,10 @@
"id": "model.config.is_valid.data_retention.message_retention_days_too_low.app_error",
"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",
"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 (-)."
......
......@@ -1301,7 +1301,7 @@ func (s *FileSettings) SetDefaults(isUpdate bool) {
s.DriverName = NewString(IMAGE_DRIVER_LOCAL)
}
if s.Directory == nil {
if s.Directory == nil || *s.Directory == "" {
s.Directory = NewString(FILE_SETTINGS_DEFAULT_DIRECTORY)
}
......@@ -3034,6 +3034,10 @@ func (s *FileSettings) isValid() *AppError {
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
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment