summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/mattermost/mattermost-server/v6/shared
diff options
context:
space:
mode:
authorWim <wim@42.be>2022-05-02 00:10:54 +0200
committerGitHub <noreply@github.com>2022-05-02 00:10:54 +0200
commit81e6f75aa491c7bfa11780dd622587cf5fff3c8f (patch)
tree817bca1b4071842029af876ab622bfdcb0360cca /vendor/github.com/mattermost/mattermost-server/v6/shared
parent888c8b9a845866730485a3a88c27027d0960d521 (diff)
downloadmatterbridge-msglm-81e6f75aa491c7bfa11780dd622587cf5fff3c8f.tar.gz
matterbridge-msglm-81e6f75aa491c7bfa11780dd622587cf5fff3c8f.tar.bz2
matterbridge-msglm-81e6f75aa491c7bfa11780dd622587cf5fff3c8f.zip
Update dependencies (#1822)
Diffstat (limited to 'vendor/github.com/mattermost/mattermost-server/v6/shared')
-rw-r--r--vendor/github.com/mattermost/mattermost-server/v6/shared/filestore/filesstore.go1
-rw-r--r--vendor/github.com/mattermost/mattermost-server/v6/shared/filestore/localstore.go45
-rw-r--r--vendor/github.com/mattermost/mattermost-server/v6/shared/filestore/s3store.go13
-rw-r--r--vendor/github.com/mattermost/mattermost-server/v6/shared/mlog/levels.go2
4 files changed, 50 insertions, 11 deletions
diff --git a/vendor/github.com/mattermost/mattermost-server/v6/shared/filestore/filesstore.go b/vendor/github.com/mattermost/mattermost-server/v6/shared/filestore/filesstore.go
index ef02895d..c17ea1f6 100644
--- a/vendor/github.com/mattermost/mattermost-server/v6/shared/filestore/filesstore.go
+++ b/vendor/github.com/mattermost/mattermost-server/v6/shared/filestore/filesstore.go
@@ -35,6 +35,7 @@ type FileBackend interface {
FileModTime(path string) (time.Time, error)
ListDirectory(path string) ([]string, error)
+ ListDirectoryRecursively(path string) ([]string, error)
RemoveDirectory(path string) error
}
diff --git a/vendor/github.com/mattermost/mattermost-server/v6/shared/filestore/localstore.go b/vendor/github.com/mattermost/mattermost-server/v6/shared/filestore/localstore.go
index 5ed882de..e2d53e49 100644
--- a/vendor/github.com/mattermost/mattermost-server/v6/shared/filestore/localstore.go
+++ b/vendor/github.com/mattermost/mattermost-server/v6/shared/filestore/localstore.go
@@ -188,19 +188,48 @@ func (b *LocalFileBackend) RemoveFile(path string) error {
return nil
}
-func (b *LocalFileBackend) ListDirectory(path string) ([]string, error) {
- var paths []string
- fileInfos, err := ioutil.ReadDir(filepath.Join(b.directory, path))
+// basePath: path to get to the file but won't be added to the end result
+// path: basePath+path current directory we are looking at
+// maxDepth: parameter to prevent infinite recursion, once this is reached we won't look any further
+func appendRecursively(basePath, path string, maxDepth int) ([]string, error) {
+ results := []string{}
+ dirEntries, err := os.ReadDir(filepath.Join(basePath, path))
if err != nil {
if os.IsNotExist(err) {
- return paths, nil
+ return results, nil
}
- return nil, errors.Wrapf(err, "unable to list the directory %s", path)
+ return results, errors.Wrapf(err, "unable to list the directory %s", path)
}
- for _, fileInfo := range fileInfos {
- paths = append(paths, filepath.Join(path, fileInfo.Name()))
+ for _, dirEntry := range dirEntries {
+ entryName := dirEntry.Name()
+ entryPath := filepath.Join(path, entryName)
+ if entryName == "." || entryName == ".." || entryPath == path {
+ continue
+ }
+ if dirEntry.IsDir() {
+ if maxDepth <= 0 {
+ mlog.Warn("Max Depth reached", mlog.String("path", entryPath))
+ results = append(results, entryPath)
+ continue // we'll ignore it if max depth is reached.
+ }
+ nestedResults, err := appendRecursively(basePath, entryPath, maxDepth-1)
+ if err != nil {
+ return results, err
+ }
+ results = append(results, nestedResults...)
+ } else {
+ results = append(results, entryPath)
+ }
}
- return paths, nil
+ return results, nil
+}
+
+func (b *LocalFileBackend) ListDirectory(path string) ([]string, error) {
+ return appendRecursively(b.directory, path, 0)
+}
+
+func (b *LocalFileBackend) ListDirectoryRecursively(path string) ([]string, error) {
+ return appendRecursively(b.directory, path, 10)
}
func (b *LocalFileBackend) RemoveDirectory(path string) error {
diff --git a/vendor/github.com/mattermost/mattermost-server/v6/shared/filestore/s3store.go b/vendor/github.com/mattermost/mattermost-server/v6/shared/filestore/s3store.go
index c45f626a..5ab6f1ce 100644
--- a/vendor/github.com/mattermost/mattermost-server/v6/shared/filestore/s3store.go
+++ b/vendor/github.com/mattermost/mattermost-server/v6/shared/filestore/s3store.go
@@ -396,7 +396,7 @@ func getPathsFromObjectInfos(in <-chan s3.ObjectInfo) <-chan s3.ObjectInfo {
return out
}
-func (b *S3FileBackend) ListDirectory(path string) ([]string, error) {
+func (b *S3FileBackend) listDirectory(path string, recursion bool) ([]string, error) {
path = filepath.Join(b.pathPrefix, path)
if !strings.HasSuffix(path, "/") && path != "" {
// s3Clnt returns only the path itself when "/" is not present
@@ -405,7 +405,8 @@ func (b *S3FileBackend) ListDirectory(path string) ([]string, error) {
}
opts := s3.ListObjectsOptions{
- Prefix: path,
+ Prefix: path,
+ Recursive: recursion,
}
var paths []string
for object := range b.client.ListObjects(context.Background(), b.bucket, opts) {
@@ -424,6 +425,14 @@ func (b *S3FileBackend) ListDirectory(path string) ([]string, error) {
return paths, nil
}
+func (b *S3FileBackend) ListDirectory(path string) ([]string, error) {
+ return b.listDirectory(path, false)
+}
+
+func (b *S3FileBackend) ListDirectoryRecursively(path string) ([]string, error) {
+ return b.listDirectory(path, true)
+}
+
func (b *S3FileBackend) RemoveDirectory(path string) error {
opts := s3.ListObjectsOptions{
Prefix: filepath.Join(b.pathPrefix, path),
diff --git a/vendor/github.com/mattermost/mattermost-server/v6/shared/mlog/levels.go b/vendor/github.com/mattermost/mattermost-server/v6/shared/mlog/levels.go
index c0b30996..1c88e816 100644
--- a/vendor/github.com/mattermost/mattermost-server/v6/shared/mlog/levels.go
+++ b/vendor/github.com/mattermost/mattermost-server/v6/shared/mlog/levels.go
@@ -14,7 +14,7 @@ var (
LvlInfo = logr.Info // ID = 4
LvlDebug = logr.Debug // ID = 5
LvlTrace = logr.Trace // ID = 6
- StdAll = []Level{LvlPanic, LvlFatal, LvlError, LvlWarn, LvlInfo, LvlDebug, LvlTrace}
+ StdAll = []Level{LvlPanic, LvlFatal, LvlError, LvlWarn, LvlInfo, LvlDebug, LvlTrace, LvlStdLog}
// non-standard "critical" level
LvlCritical = Level{ID: 7, Name: "critical"}
// used by redirected standard logger