Moving filesstore services into shared folder (#16940)

* Moving filesstore services into shared folder

* Fixing app-layers generation

* Renaming from filesstore to filestore
Этот коммит содержится в:
Jesús Espino
2021-03-02 14:37:21 +01:00
коммит произвёл GitHub
родитель 5f9ab3783a
Коммит 78355ae2a7
19 изменённых файлов: 55 добавлений и 55 удалений

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

@@ -270,9 +270,9 @@ migrations-bindata: ## Generates bindata migrations
@echo Generating bindata for migrations @echo Generating bindata for migrations
$(GO) generate $(GOFLAGS) ./db/migrations/ $(GO) generate $(GOFLAGS) ./db/migrations/
filesstore-mocks: ## Creates mock files. filestore-mocks: ## Creates mock files.
$(GO) get -modfile=go.tools.mod github.com/vektra/mockery/... $(GO) get -modfile=go.tools.mod github.com/vektra/mockery/...
$(GOBIN)/mockery -dir services/filesstore -all -output services/filesstore/mocks -note 'Regenerate this file using `make filesstore-mocks`.' $(GOBIN)/mockery -dir shared/filestore -all -output shared/filestore/mocks -note 'Regenerate this file using `make filestore-mocks`.'
ldap-mocks: ## Creates mock files for ldap. ldap-mocks: ## Creates mock files for ldap.
$(GO) get -modfile=go.tools.mod github.com/vektra/mockery/... $(GO) get -modfile=go.tools.mod github.com/vektra/mockery/...

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

@@ -172,7 +172,7 @@ func getSystemPing(c *Context, w http.ResponseWriter, r *http.Request) {
filestoreStatusKey := "filestore_status" filestoreStatusKey := "filestore_status"
s[filestoreStatusKey] = model.STATUS_OK s[filestoreStatusKey] = model.STATUS_OK
appErr := c.App.TestFilesStoreConnection() appErr := c.App.TestFileStoreConnection()
if appErr != nil { if appErr != nil {
s[filestoreStatusKey] = model.STATUS_UNHEALTHY s[filestoreStatusKey] = model.STATUS_UNHEALTHY
s[model.STATUS] = model.STATUS_UNHEALTHY s[model.STATUS] = model.STATUS_UNHEALTHY
@@ -450,7 +450,7 @@ func testS3(c *Context, w http.ResponseWriter, r *http.Request) {
cfg.FileSettings.AmazonS3SecretAccessKey = c.App.Config().FileSettings.AmazonS3SecretAccessKey cfg.FileSettings.AmazonS3SecretAccessKey = c.App.Config().FileSettings.AmazonS3SecretAccessKey
} }
appErr := c.App.TestFilesStoreConnectionWithConfig(&cfg.FileSettings) appErr := c.App.TestFileStoreConnectionWithConfig(&cfg.FileSettings)
if appErr != nil { if appErr != nil {
c.Err = appErr c.Err = appErr
return return

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

@@ -23,11 +23,11 @@ import (
"github.com/mattermost/mattermost-server/v5/mlog" "github.com/mattermost/mattermost-server/v5/mlog"
"github.com/mattermost/mattermost-server/v5/model" "github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/plugin" "github.com/mattermost/mattermost-server/v5/plugin"
"github.com/mattermost/mattermost-server/v5/services/filesstore"
"github.com/mattermost/mattermost-server/v5/services/httpservice" "github.com/mattermost/mattermost-server/v5/services/httpservice"
"github.com/mattermost/mattermost-server/v5/services/imageproxy" "github.com/mattermost/mattermost-server/v5/services/imageproxy"
"github.com/mattermost/mattermost-server/v5/services/searchengine" "github.com/mattermost/mattermost-server/v5/services/searchengine"
"github.com/mattermost/mattermost-server/v5/services/timezones" "github.com/mattermost/mattermost-server/v5/services/timezones"
"github.com/mattermost/mattermost-server/v5/shared/filestore"
"github.com/mattermost/mattermost-server/v5/shared/i18n" "github.com/mattermost/mattermost-server/v5/shared/i18n"
"github.com/mattermost/mattermost-server/v5/store" "github.com/mattermost/mattermost-server/v5/store"
) )
@@ -48,7 +48,7 @@ type AppIface interface {
// AddPublicKey will add plugin public key to the config. Overwrites the previous file // AddPublicKey will add plugin public key to the config. Overwrites the previous file
AddPublicKey(name string, key io.Reader) *model.AppError AddPublicKey(name string, key io.Reader) *model.AppError
// Caller must close the first return value // Caller must close the first return value
FileReader(path string) (filesstore.ReadCloseSeeker, *model.AppError) FileReader(path string) (filestore.ReadCloseSeeker, *model.AppError)
// ChannelMembersMinusGroupMembers returns the set of users in the given channel minus the set of users in the given // ChannelMembersMinusGroupMembers returns the set of users in the given channel minus the set of users in the given
// groups. // groups.
// //
@@ -312,7 +312,7 @@ type AppIface interface {
DoAdvancedPermissionsMigration() DoAdvancedPermissionsMigration()
// This function zip's up all the files in fileDatas array and then saves it to the directory specified with the specified zip file name // This function zip's up all the files in fileDatas array and then saves it to the directory specified with the specified zip file name
// Ensure the zip file name ends with a .zip // Ensure the zip file name ends with a .zip
CreateZipFileAndAddFiles(fileBackend filesstore.FileBackend, fileDatas []model.FileData, zipFileName, directory string) error CreateZipFileAndAddFiles(fileBackend filestore.FileBackend, fileDatas []model.FileData, zipFileName, directory string) error
// This to be used for places we check the users password when they are already logged in // This to be used for places we check the users password when they are already logged in
DoubleCheckPassword(user *model.User, password string) *model.AppError DoubleCheckPassword(user *model.User, password string) *model.AppError
// UpdateBotActive marks a bot as active or inactive, along with its corresponding user. // UpdateBotActive marks a bot as active or inactive, along with its corresponding user.
@@ -502,7 +502,7 @@ type AppIface interface {
EnvironmentConfig() map[string]interface{} EnvironmentConfig() map[string]interface{}
ExportPermissions(w io.Writer) error ExportPermissions(w io.Writer) error
FetchSamlMetadataFromIdp(url string) ([]byte, *model.AppError) FetchSamlMetadataFromIdp(url string) ([]byte, *model.AppError)
FileBackend() (filesstore.FileBackend, *model.AppError) FileBackend() (filestore.FileBackend, *model.AppError)
FileExists(path string) (bool, *model.AppError) FileExists(path string) (bool, *model.AppError)
FileModTime(path string) (time.Time, *model.AppError) FileModTime(path string) (time.Time, *model.AppError)
FileSize(path string) (int64, *model.AppError) FileSize(path string) (int64, *model.AppError)
@@ -974,8 +974,8 @@ type AppIface interface {
TelemetryId() string TelemetryId() string
TestElasticsearch(cfg *model.Config) *model.AppError TestElasticsearch(cfg *model.Config) *model.AppError
TestEmail(userID string, cfg *model.Config) *model.AppError TestEmail(userID string, cfg *model.Config) *model.AppError
TestFilesStoreConnection() *model.AppError TestFileStoreConnection() *model.AppError
TestFilesStoreConnectionWithConfig(cfg *model.FileSettings) *model.AppError TestFileStoreConnectionWithConfig(cfg *model.FileSettings) *model.AppError
TestLdap() *model.AppError TestLdap() *model.AppError
TestSiteURL(siteURL string) *model.AppError TestSiteURL(siteURL string) *model.AppError
Timezones() *timezones.Timezones Timezones() *timezones.Timezones

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

@@ -37,7 +37,7 @@ import (
"github.com/mattermost/mattermost-server/v5/model" "github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/plugin" "github.com/mattermost/mattermost-server/v5/plugin"
"github.com/mattermost/mattermost-server/v5/services/docextractor" "github.com/mattermost/mattermost-server/v5/services/docextractor"
"github.com/mattermost/mattermost-server/v5/services/filesstore" "github.com/mattermost/mattermost-server/v5/shared/filestore"
"github.com/mattermost/mattermost-server/v5/store" "github.com/mattermost/mattermost-server/v5/store"
"github.com/mattermost/mattermost-server/v5/utils" "github.com/mattermost/mattermost-server/v5/utils"
) )
@@ -76,7 +76,7 @@ const (
ImagePreviewPixelWidth = 1920 ImagePreviewPixelWidth = 1920
) )
func (a *App) FileBackend() (filesstore.FileBackend, *model.AppError) { func (a *App) FileBackend() (filestore.FileBackend, *model.AppError) {
return a.Srv().FileBackend() return a.Srv().FileBackend()
} }
@@ -89,7 +89,7 @@ func (a *App) CheckMandatoryS3Fields(settings *model.FileSettings) *model.AppErr
return nil return nil
} }
func (a *App) TestFilesStoreConnection() *model.AppError { func (a *App) TestFileStoreConnection() *model.AppError {
backend, err := a.FileBackend() backend, err := a.FileBackend()
if err != nil { if err != nil {
return err return err
@@ -101,9 +101,9 @@ func (a *App) TestFilesStoreConnection() *model.AppError {
return nil return nil
} }
func (a *App) TestFilesStoreConnectionWithConfig(cfg *model.FileSettings) *model.AppError { func (a *App) TestFileStoreConnectionWithConfig(cfg *model.FileSettings) *model.AppError {
license := a.Srv().License() license := a.Srv().License()
backend, err := filesstore.NewFileBackend(cfg.ToFileBackendSettings(license != nil && *license.Features.Compliance)) backend, err := filestore.NewFileBackend(cfg.ToFileBackendSettings(license != nil && *license.Features.Compliance))
if err != nil { if err != nil {
return model.NewAppError("FileBackend", "api.file.no_driver.app_error", nil, err.Error(), http.StatusInternalServerError) return model.NewAppError("FileBackend", "api.file.no_driver.app_error", nil, err.Error(), http.StatusInternalServerError)
} }
@@ -127,7 +127,7 @@ func (a *App) ReadFile(path string) ([]byte, *model.AppError) {
} }
// Caller must close the first return value // Caller must close the first return value
func (a *App) FileReader(path string) (filesstore.ReadCloseSeeker, *model.AppError) { func (a *App) FileReader(path string) (filestore.ReadCloseSeeker, *model.AppError) {
backend, err := a.FileBackend() backend, err := a.FileBackend()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -1310,7 +1310,7 @@ func (a *App) CopyFileInfos(userID string, fileIDs []string) ([]string, *model.A
// This function zip's up all the files in fileDatas array and then saves it to the directory specified with the specified zip file name // This function zip's up all the files in fileDatas array and then saves it to the directory specified with the specified zip file name
// Ensure the zip file name ends with a .zip // Ensure the zip file name ends with a .zip
func (a *App) CreateZipFileAndAddFiles(fileBackend filesstore.FileBackend, fileDatas []model.FileData, zipFileName, directory string) error { func (a *App) CreateZipFileAndAddFiles(fileBackend filestore.FileBackend, fileDatas []model.FileData, zipFileName, directory string) error {
// Create Zip File (temporarily stored on disk) // Create Zip File (temporarily stored on disk)
conglomerateZipFile, err := os.Create(zipFileName) conglomerateZipFile, err := os.Create(zipFileName)
if err != nil { if err != nil {

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

@@ -17,8 +17,8 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/mattermost/mattermost-server/v5/model" "github.com/mattermost/mattermost-server/v5/model"
filesStoreMocks "github.com/mattermost/mattermost-server/v5/services/filesstore/mocks"
"github.com/mattermost/mattermost-server/v5/services/searchengine/mocks" "github.com/mattermost/mattermost-server/v5/services/searchengine/mocks"
filesStoreMocks "github.com/mattermost/mattermost-server/v5/shared/filestore/mocks"
"github.com/mattermost/mattermost-server/v5/utils/fileutils" "github.com/mattermost/mattermost-server/v5/utils/fileutils"
) )

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

@@ -24,12 +24,12 @@ import (
"github.com/mattermost/mattermost-server/v5/mlog" "github.com/mattermost/mattermost-server/v5/mlog"
"github.com/mattermost/mattermost-server/v5/model" "github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/plugin" "github.com/mattermost/mattermost-server/v5/plugin"
"github.com/mattermost/mattermost-server/v5/services/filesstore"
"github.com/mattermost/mattermost-server/v5/services/httpservice" "github.com/mattermost/mattermost-server/v5/services/httpservice"
"github.com/mattermost/mattermost-server/v5/services/imageproxy" "github.com/mattermost/mattermost-server/v5/services/imageproxy"
"github.com/mattermost/mattermost-server/v5/services/searchengine" "github.com/mattermost/mattermost-server/v5/services/searchengine"
"github.com/mattermost/mattermost-server/v5/services/timezones" "github.com/mattermost/mattermost-server/v5/services/timezones"
"github.com/mattermost/mattermost-server/v5/services/tracing" "github.com/mattermost/mattermost-server/v5/services/tracing"
"github.com/mattermost/mattermost-server/v5/shared/filestore"
"github.com/mattermost/mattermost-server/v5/shared/i18n" "github.com/mattermost/mattermost-server/v5/shared/i18n"
"github.com/mattermost/mattermost-server/v5/store" "github.com/mattermost/mattermost-server/v5/store"
"github.com/opentracing/opentracing-go/ext" "github.com/opentracing/opentracing-go/ext"
@@ -2415,7 +2415,7 @@ func (a *OpenTracingAppLayer) CreateWebhookPost(userID string, channel *model.Ch
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (a *OpenTracingAppLayer) CreateZipFileAndAddFiles(fileBackend filesstore.FileBackend, fileDatas []model.FileData, zipFileName string, directory string) error { func (a *OpenTracingAppLayer) CreateZipFileAndAddFiles(fileBackend filestore.FileBackend, fileDatas []model.FileData, zipFileName string, directory string) error {
origCtx := a.ctx origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.CreateZipFileAndAddFiles") span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.CreateZipFileAndAddFiles")
@@ -3688,7 +3688,7 @@ func (a *OpenTracingAppLayer) FetchSamlMetadataFromIdp(url string) ([]byte, *mod
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (a *OpenTracingAppLayer) FileBackend() (filesstore.FileBackend, *model.AppError) { func (a *OpenTracingAppLayer) FileBackend() (filestore.FileBackend, *model.AppError) {
origCtx := a.ctx origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.FileBackend") span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.FileBackend")
@@ -3754,7 +3754,7 @@ func (a *OpenTracingAppLayer) FileModTime(path string) (time.Time, *model.AppErr
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (a *OpenTracingAppLayer) FileReader(path string) (filesstore.ReadCloseSeeker, *model.AppError) { func (a *OpenTracingAppLayer) FileReader(path string) (filestore.ReadCloseSeeker, *model.AppError) {
origCtx := a.ctx origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.FileReader") span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.FileReader")
@@ -14602,9 +14602,9 @@ func (a *OpenTracingAppLayer) TestEmail(userID string, cfg *model.Config) *model
return resultVar0 return resultVar0
} }
func (a *OpenTracingAppLayer) TestFilesStoreConnection() *model.AppError { func (a *OpenTracingAppLayer) TestFileStoreConnection() *model.AppError {
origCtx := a.ctx origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.TestFilesStoreConnection") span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.TestFileStoreConnection")
a.ctx = newCtx a.ctx = newCtx
a.app.Srv().Store.SetContext(newCtx) a.app.Srv().Store.SetContext(newCtx)
@@ -14614,7 +14614,7 @@ func (a *OpenTracingAppLayer) TestFilesStoreConnection() *model.AppError {
}() }()
defer span.Finish() defer span.Finish()
resultVar0 := a.app.TestFilesStoreConnection() resultVar0 := a.app.TestFileStoreConnection()
if resultVar0 != nil { if resultVar0 != nil {
span.LogFields(spanlog.Error(resultVar0)) span.LogFields(spanlog.Error(resultVar0))
@@ -14624,9 +14624,9 @@ func (a *OpenTracingAppLayer) TestFilesStoreConnection() *model.AppError {
return resultVar0 return resultVar0
} }
func (a *OpenTracingAppLayer) TestFilesStoreConnectionWithConfig(cfg *model.FileSettings) *model.AppError { func (a *OpenTracingAppLayer) TestFileStoreConnectionWithConfig(cfg *model.FileSettings) *model.AppError {
origCtx := a.ctx origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.TestFilesStoreConnectionWithConfig") span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.TestFileStoreConnectionWithConfig")
a.ctx = newCtx a.ctx = newCtx
a.app.Srv().Store.SetContext(newCtx) a.app.Srv().Store.SetContext(newCtx)
@@ -14636,7 +14636,7 @@ func (a *OpenTracingAppLayer) TestFilesStoreConnectionWithConfig(cfg *model.File
}() }()
defer span.Finish() defer span.Finish()
resultVar0 := a.app.TestFilesStoreConnectionWithConfig(cfg) resultVar0 := a.app.TestFileStoreConnectionWithConfig(cfg)
if resultVar0 != nil { if resultVar0 != nil {
span.LogFields(spanlog.Error(resultVar0)) span.LogFields(spanlog.Error(resultVar0))

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

@@ -23,8 +23,8 @@ import (
"github.com/mattermost/mattermost-server/v5/mlog" "github.com/mattermost/mattermost-server/v5/mlog"
"github.com/mattermost/mattermost-server/v5/model" "github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/plugin" "github.com/mattermost/mattermost-server/v5/plugin"
"github.com/mattermost/mattermost-server/v5/services/filesstore"
"github.com/mattermost/mattermost-server/v5/services/marketplace" "github.com/mattermost/mattermost-server/v5/services/marketplace"
"github.com/mattermost/mattermost-server/v5/shared/filestore"
"github.com/mattermost/mattermost-server/v5/utils/fileutils" "github.com/mattermost/mattermost-server/v5/utils/fileutils"
) )
@@ -273,7 +273,7 @@ func (a *App) SyncPlugins() *model.AppError {
} }
defer reader.Close() defer reader.Close()
var signature filesstore.ReadCloseSeeker var signature filestore.ReadCloseSeeker
if *a.Config().PluginSettings.RequirePluginSignature { if *a.Config().PluginSettings.RequirePluginSignature {
signature, appErr = a.FileReader(plugin.signaturePath) signature, appErr = a.FileReader(plugin.signaturePath)
if appErr != nil { if appErr != nil {

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

@@ -50,7 +50,7 @@ import (
"github.com/mattermost/mattermost-server/v5/mlog" "github.com/mattermost/mattermost-server/v5/mlog"
"github.com/mattermost/mattermost-server/v5/model" "github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/services/filesstore" "github.com/mattermost/mattermost-server/v5/shared/filestore"
"github.com/mattermost/mattermost-server/v5/utils" "github.com/mattermost/mattermost-server/v5/utils"
) )
@@ -82,7 +82,7 @@ func (a *App) InstallPluginFromData(data model.PluginEventData) {
} }
defer reader.Close() defer reader.Close()
var signature filesstore.ReadCloseSeeker var signature filestore.ReadCloseSeeker
if *a.Config().PluginSettings.RequirePluginSignature { if *a.Config().PluginSettings.RequirePluginSignature {
signature, appErr = a.FileReader(plugin.signaturePath) signature, appErr = a.FileReader(plugin.signaturePath)
if appErr != nil { if appErr != nil {

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

@@ -44,7 +44,6 @@ import (
"github.com/mattermost/mattermost-server/v5/plugin" "github.com/mattermost/mattermost-server/v5/plugin"
"github.com/mattermost/mattermost-server/v5/services/awsmeter" "github.com/mattermost/mattermost-server/v5/services/awsmeter"
"github.com/mattermost/mattermost-server/v5/services/cache" "github.com/mattermost/mattermost-server/v5/services/cache"
"github.com/mattermost/mattermost-server/v5/services/filesstore"
"github.com/mattermost/mattermost-server/v5/services/httpservice" "github.com/mattermost/mattermost-server/v5/services/httpservice"
"github.com/mattermost/mattermost-server/v5/services/imageproxy" "github.com/mattermost/mattermost-server/v5/services/imageproxy"
"github.com/mattermost/mattermost-server/v5/services/mailservice" "github.com/mattermost/mattermost-server/v5/services/mailservice"
@@ -54,6 +53,7 @@ import (
"github.com/mattermost/mattermost-server/v5/services/timezones" "github.com/mattermost/mattermost-server/v5/services/timezones"
"github.com/mattermost/mattermost-server/v5/services/tracing" "github.com/mattermost/mattermost-server/v5/services/tracing"
"github.com/mattermost/mattermost-server/v5/services/upgrader" "github.com/mattermost/mattermost-server/v5/services/upgrader"
"github.com/mattermost/mattermost-server/v5/shared/filestore"
"github.com/mattermost/mattermost-server/v5/shared/i18n" "github.com/mattermost/mattermost-server/v5/shared/i18n"
"github.com/mattermost/mattermost-server/v5/store" "github.com/mattermost/mattermost-server/v5/store"
"github.com/mattermost/mattermost-server/v5/store/localcachelayer" "github.com/mattermost/mattermost-server/v5/store/localcachelayer"
@@ -1573,9 +1573,9 @@ func (s *Server) stopSearchEngine() {
} }
} }
func (s *Server) FileBackend() (filesstore.FileBackend, *model.AppError) { func (s *Server) FileBackend() (filestore.FileBackend, *model.AppError) {
license := s.License() license := s.License()
backend, err := filesstore.NewFileBackend(s.Config().FileSettings.ToFileBackendSettings(license != nil && *license.Features.Compliance)) backend, err := filestore.NewFileBackend(s.Config().FileSettings.ToFileBackendSettings(license != nil && *license.Features.Compliance))
if err != nil { if err != nil {
return nil, model.NewAppError("FileBackend", "api.file.no_driver.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, model.NewAppError("FileBackend", "api.file.no_driver.app_error", nil, err.Error(), http.StatusInternalServerError)
} }

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

@@ -21,7 +21,7 @@ import (
"github.com/mattermost/ldap" "github.com/mattermost/ldap"
"github.com/mattermost/mattermost-server/v5/mlog" "github.com/mattermost/mattermost-server/v5/mlog"
"github.com/mattermost/mattermost-server/v5/services/filesstore" "github.com/mattermost/mattermost-server/v5/shared/filestore"
) )
const ( const (
@@ -1469,14 +1469,14 @@ func (s *FileSettings) SetDefaults(isUpdate bool) {
} }
} }
func (s *FileSettings) ToFileBackendSettings(enableComplianceFeature bool) filesstore.FileBackendSettings { func (s *FileSettings) ToFileBackendSettings(enableComplianceFeature bool) filestore.FileBackendSettings {
if *s.DriverName == IMAGE_DRIVER_LOCAL { if *s.DriverName == IMAGE_DRIVER_LOCAL {
return filesstore.FileBackendSettings{ return filestore.FileBackendSettings{
DriverName: *s.DriverName, DriverName: *s.DriverName,
Directory: *s.Directory, Directory: *s.Directory,
} }
} }
return filesstore.FileBackendSettings{ return filestore.FileBackendSettings{
DriverName: *s.DriverName, DriverName: *s.DriverName,
AmazonS3AccessKeyId: *s.AmazonS3AccessKeyId, AmazonS3AccessKeyId: *s.AmazonS3AccessKeyId,
AmazonS3SecretAccessKey: *s.AmazonS3SecretAccessKey, AmazonS3SecretAccessKey: *s.AmazonS3SecretAccessKey,

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

@@ -1,7 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
package filesstore package filestore
import ( import (
"io" "io"

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

@@ -1,7 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
package filesstore package filestore
import ( import (
"bytes" "bytes"

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

@@ -1,7 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
package filesstore package filestore
import ( import (
"bytes" "bytes"

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

@@ -1,13 +1,13 @@
// Code generated by mockery v1.0.0. DO NOT EDIT. // Code generated by mockery v1.0.0. DO NOT EDIT.
// Regenerate this file using `make filesstore-mocks`. // Regenerate this file using `make filestore-mocks`.
package mocks package mocks
import ( import (
io "io" io "io"
filesstore "github.com/mattermost/mattermost-server/v5/services/filesstore" filestore "github.com/mattermost/mattermost-server/v5/shared/filestore"
mock "github.com/stretchr/testify/mock" mock "github.com/stretchr/testify/mock"
@@ -178,15 +178,15 @@ func (_m *FileBackend) ReadFile(path string) ([]byte, error) {
} }
// Reader provides a mock function with given fields: path // Reader provides a mock function with given fields: path
func (_m *FileBackend) Reader(path string) (filesstore.ReadCloseSeeker, error) { func (_m *FileBackend) Reader(path string) (filestore.ReadCloseSeeker, error) {
ret := _m.Called(path) ret := _m.Called(path)
var r0 filesstore.ReadCloseSeeker var r0 filestore.ReadCloseSeeker
if rf, ok := ret.Get(0).(func(string) filesstore.ReadCloseSeeker); ok { if rf, ok := ret.Get(0).(func(string) filestore.ReadCloseSeeker); ok {
r0 = rf(path) r0 = rf(path)
} else { } else {
if ret.Get(0) != nil { if ret.Get(0) != nil {
r0 = ret.Get(0).(filesstore.ReadCloseSeeker) r0 = ret.Get(0).(filestore.ReadCloseSeeker)
} }
} }

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

@@ -1,6 +1,6 @@
// Code generated by mockery v1.0.0. DO NOT EDIT. // Code generated by mockery v1.0.0. DO NOT EDIT.
// Regenerate this file using `make filesstore-mocks`. // Regenerate this file using `make filestore-mocks`.
package mocks package mocks

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

@@ -1,7 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
package filesstore package filestore
import ( import (
"context" "context"

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

@@ -1,7 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
package filesstore package filestore
import ( import (
"context" "context"
@@ -371,7 +371,7 @@ func (b *S3FileBackend) ListDirectory(path string) ([]string, error) {
path = filepath.Join(b.pathPrefix, path) path = filepath.Join(b.pathPrefix, path)
if !strings.HasSuffix(path, "/") && path != "" { if !strings.HasSuffix(path, "/") && path != "" {
// s3Clnt returns only the path itself when "/" is not present // s3Clnt returns only the path itself when "/" is not present
// appending "/" to make it consistent across all filesstores // appending "/" to make it consistent across all filestores
path = path + "/" path = path + "/"
} }

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

@@ -1,7 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
package filesstore package filestore
import ( import (
"testing" "testing"

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

@@ -13,7 +13,7 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/mattermost/mattermost-server/v5/model" "github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/services/filesstore" "github.com/mattermost/mattermost-server/v5/shared/filestore"
"github.com/mattermost/mattermost-server/v5/utils" "github.com/mattermost/mattermost-server/v5/utils"
"github.com/mattermost/mattermost-server/v5/utils/fileutils" "github.com/mattermost/mattermost-server/v5/utils/fileutils"
) )
@@ -119,7 +119,7 @@ func getTestResourcesToSetup() []testResourceDetails {
} }
func CopyFile(src, dst string) error { func CopyFile(src, dst string) error {
fileBackend, err := filesstore.NewFileBackend(filesstore.FileBackendSettings{DriverName: "local", Directory: ""}) fileBackend, err := filestore.NewFileBackend(filestore.FileBackendSettings{DriverName: "local", Directory: ""})
if err != nil { if err != nil {
return errors.Wrapf(err, "failed to copy file %s to %s", src, dst) return errors.Wrapf(err, "failed to copy file %s to %s", src, dst)
} }