Reducing the filestore dependencies from the rest of the source code (#16816)

* Reducing the filestore dependencies from the rest of the source code

* Making more generic config conversion to FileBackendSettings

* Fixing usage of the NewFileBackend function

* Fixing more usages of the NewFileBackend function

* Fix some linter errors

* Fix more linter errors

* Fixing some unit tests

* Fixing linter problem

* Addressing PR review comments

* Simplifing the CopyFile for tests

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Jesús Espino
2021-02-15 10:09:28 +01:00
коммит произвёл GitHub
родитель a246104d04
Коммит a3de71fba4
15 изменённых файлов: 231 добавлений и 144 удалений

Просмотреть файл

@@ -80,7 +80,8 @@ func (a *App) FileBackend() (filesstore.FileBackend, *model.AppError) {
}
func (a *App) CheckMandatoryS3Fields(settings *model.FileSettings) *model.AppError {
err := filesstore.CheckMandatoryS3Fields(settings)
fileBackendSettings := settings.ToFileBackendSettings(false)
err := fileBackendSettings.CheckMandatoryS3Fields()
if err != nil {
return model.NewAppError("CheckMandatoryS3Fields", "api.admin.test_s3.missing_s3_bucket", nil, err.Error(), http.StatusBadRequest)
}
@@ -101,7 +102,7 @@ func (a *App) TestFilesStoreConnection() *model.AppError {
func (a *App) TestFilesStoreConnectionWithConfig(cfg *model.FileSettings) *model.AppError {
license := a.Srv().License()
backend, err := filesstore.NewFileBackend(cfg, license != nil && *license.Features.Compliance)
backend, err := filesstore.NewFileBackend(cfg.ToFileBackendSettings(license != nil && *license.Features.Compliance))
if err != nil {
return model.NewAppError("FileBackend", "api.file.no_driver.app_error", nil, err.Error(), http.StatusInternalServerError)
}