[MM-40179] Go into directories when trying to export attachments (#19249)
* MM-40179 traverse directories when trying to export * fix test * fix s3 to behabe the same way * add test for paths way too deep * test recursion only on localstorage * make list directories non recursively the default approach * fix linting error * fix non-recursive case Co-authored-by: = <=> Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
9d10199e5f
Коммит
4bf3d6a7f5
19
app/file.go
19
app/file.go
@@ -179,11 +179,24 @@ func (s *Server) removeFile(path string) *model.AppError {
|
||||
}
|
||||
|
||||
func (a *App) ListDirectory(path string) ([]string, *model.AppError) {
|
||||
return a.Srv().listDirectory(path)
|
||||
return a.Srv().listDirectory(path, false)
|
||||
}
|
||||
|
||||
func (s *Server) listDirectory(path string) ([]string, *model.AppError) {
|
||||
paths, nErr := s.FileBackend().ListDirectory(path)
|
||||
func (a *App) ListDirectoryRecursively(path string) ([]string, *model.AppError) {
|
||||
return a.Srv().listDirectory(path, true)
|
||||
}
|
||||
|
||||
func (s *Server) listDirectory(path string, recursion bool) ([]string, *model.AppError) {
|
||||
backend := s.FileBackend()
|
||||
var paths []string
|
||||
var nErr error
|
||||
|
||||
if recursion {
|
||||
paths, nErr = backend.ListDirectoryRecursively(path)
|
||||
} else {
|
||||
paths, nErr = backend.ListDirectory(path)
|
||||
}
|
||||
|
||||
if nErr != nil {
|
||||
return nil, model.NewAppError("ListDirectory", "api.file.list_directory.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user