diff --git a/weed/filer2/cassandra/cassandra_store.go b/weed/filer2/cassandra/cassandra_store.go index 8214935f9..40f371e2f 100644 --- a/weed/filer2/cassandra/cassandra_store.go +++ b/weed/filer2/cassandra/cassandra_store.go @@ -2,7 +2,6 @@ package cassandra import ( "context" - "errors" "fmt" "github.com/gocql/gocql" @@ -127,7 +126,7 @@ func (store *CassandraStore) DeleteFolderChildren(ctx context.Context, fullpath } func (store *CassandraStore) ListDirectoryPrefixedEntries(ctx context.Context, fullpath util.FullPath, startFileName string, inclusive bool, limit int, prefix string) (entries []*filer2.Entry, err error) { - return nil, errors.New(filer2.UnsupportedListDirectoryPrefixedErr) + return nil, filer2.UnsupportedListDirectoryPrefixedErr } func (store *CassandraStore) ListDirectoryEntries(ctx context.Context, fullpath util.FullPath, startFileName string, inclusive bool, diff --git a/weed/filer2/etcd/etcd_store.go b/weed/filer2/etcd/etcd_store.go index 93f3f3781..d0b1ff202 100644 --- a/weed/filer2/etcd/etcd_store.go +++ b/weed/filer2/etcd/etcd_store.go @@ -2,7 +2,6 @@ package etcd import ( "context" - "errors" "fmt" "strings" "time" @@ -137,7 +136,7 @@ func (store *EtcdStore) DeleteFolderChildren(ctx context.Context, fullpath weed_ } func (store *EtcdStore) ListDirectoryPrefixedEntries(ctx context.Context, fullpath weed_util.FullPath, startFileName string, inclusive bool, limit int, prefix string) (entries []*filer2.Entry, err error) { - return nil, errors.New(filer2.UnsupportedListDirectoryPrefixedErr) + return nil, filer2.UnsupportedListDirectoryPrefixedErr } func (store *EtcdStore) ListDirectoryEntries(ctx context.Context, fullpath weed_util.FullPath, startFileName string, inclusive bool, limit int) (entries []*filer2.Entry, err error) { diff --git a/weed/filer2/filer.go b/weed/filer2/filer.go index ef81cae2b..a94052996 100644 --- a/weed/filer2/filer.go +++ b/weed/filer2/filer.go @@ -2,6 +2,7 @@ package filer2 import ( "context" + "errors" "fmt" "os" "strings" @@ -19,13 +20,13 @@ import ( ) const ( - PaginationSize = 1024 * 256 - UnsupportedListDirectoryPrefixedErr = "UNSUPPORTED" + PaginationSize = 1024 * 256 ) var ( - OS_UID = uint32(os.Getuid()) - OS_GID = uint32(os.Getgid()) + OS_UID = uint32(os.Getuid()) + OS_GID = uint32(os.Getgid()) + UnsupportedListDirectoryPrefixedErr = errors.New("UNSUPPORTED") ) type Filer struct { diff --git a/weed/filer2/filerstore.go b/weed/filer2/filerstore.go index 3c1e555b1..642ebb3c8 100644 --- a/weed/filer2/filerstore.go +++ b/weed/filer2/filerstore.go @@ -138,7 +138,7 @@ func (fsw *FilerStoreWrapper) ListDirectoryPrefixedEntries(ctx context.Context, stats.FilerStoreHistogram.WithLabelValues(fsw.ActualStore.GetName(), "list").Observe(time.Since(start).Seconds()) }() entries, err := fsw.ActualStore.ListDirectoryPrefixedEntries(ctx, dirPath, startFileName, includeStartFile, limit, prefix) - if err.Error() == UnsupportedListDirectoryPrefixedErr { + if err.Error() == UnsupportedListDirectoryPrefixedErr.Error() { count := 0 notPrefixed, err := fsw.ActualStore.ListDirectoryEntries(ctx, dirPath, startFileName, includeStartFile, limit) if err != nil { diff --git a/weed/filer2/leveldb/leveldb_store.go b/weed/filer2/leveldb/leveldb_store.go index 787671c55..2ea88635b 100644 --- a/weed/filer2/leveldb/leveldb_store.go +++ b/weed/filer2/leveldb/leveldb_store.go @@ -3,7 +3,6 @@ package leveldb import ( "bytes" "context" - "errors" "fmt" "github.com/syndtr/goleveldb/leveldb" leveldb_errors "github.com/syndtr/goleveldb/leveldb/errors" @@ -160,7 +159,7 @@ func (store *LevelDBStore) DeleteFolderChildren(ctx context.Context, fullpath we } func (store *LevelDBStore) ListDirectoryPrefixedEntries(ctx context.Context, fullpath weed_util.FullPath, startFileName string, inclusive bool, limit int, prefix string) (entries []*filer2.Entry, err error) { - return nil, errors.New(filer2.UnsupportedListDirectoryPrefixedErr) + return nil, filer2.UnsupportedListDirectoryPrefixedErr } func (store *LevelDBStore) ListDirectoryEntries(ctx context.Context, fullpath weed_util.FullPath, startFileName string, inclusive bool, diff --git a/weed/filer2/leveldb2/leveldb2_store.go b/weed/filer2/leveldb2/leveldb2_store.go index 4fc110d69..2a9c2fe3f 100644 --- a/weed/filer2/leveldb2/leveldb2_store.go +++ b/weed/filer2/leveldb2/leveldb2_store.go @@ -4,7 +4,6 @@ import ( "bytes" "context" "crypto/md5" - "errors" "fmt" "github.com/syndtr/goleveldb/leveldb" leveldb_errors "github.com/syndtr/goleveldb/leveldb/errors" @@ -169,7 +168,7 @@ func (store *LevelDB2Store) DeleteFolderChildren(ctx context.Context, fullpath w } func (store *LevelDB2Store) ListDirectoryPrefixedEntries(ctx context.Context, fullpath weed_util.FullPath, startFileName string, inclusive bool, limit int, prefix string) (entries []*filer2.Entry, err error) { - return nil, errors.New(filer2.UnsupportedListDirectoryPrefixedErr) + return nil, filer2.UnsupportedListDirectoryPrefixedErr } func (store *LevelDB2Store) ListDirectoryEntries(ctx context.Context, fullpath weed_util.FullPath, startFileName string, inclusive bool, diff --git a/weed/filer2/mongodb/mongodb_store.go b/weed/filer2/mongodb/mongodb_store.go index 314f36ce2..080d6248f 100644 --- a/weed/filer2/mongodb/mongodb_store.go +++ b/weed/filer2/mongodb/mongodb_store.go @@ -2,7 +2,6 @@ package mongodb import ( "context" - "errors" "fmt" "github.com/chrislusf/seaweedfs/weed/filer2" "github.com/chrislusf/seaweedfs/weed/glog" @@ -169,7 +168,7 @@ func (store *MongodbStore) DeleteFolderChildren(ctx context.Context, fullpath ut } func (store *MongodbStore) ListDirectoryPrefixedEntries(ctx context.Context, fullpath util.FullPath, startFileName string, inclusive bool, limit int, prefix string) (entries []*filer2.Entry, err error) { - return nil, errors.New(filer2.UnsupportedListDirectoryPrefixedErr) + return nil, filer2.UnsupportedListDirectoryPrefixedErr } func (store *MongodbStore) ListDirectoryEntries(ctx context.Context, fullpath util.FullPath, startFileName string, inclusive bool, limit int) (entries []*filer2.Entry, err error) { diff --git a/weed/filer2/redis/universal_redis_store.go b/weed/filer2/redis/universal_redis_store.go index 66450b5a7..8cc70c72b 100644 --- a/weed/filer2/redis/universal_redis_store.go +++ b/weed/filer2/redis/universal_redis_store.go @@ -2,7 +2,6 @@ package redis import ( "context" - "errors" "fmt" "sort" "strings" @@ -123,7 +122,7 @@ func (store *UniversalRedisStore) DeleteFolderChildren(ctx context.Context, full } func (store *UniversalRedisStore) ListDirectoryPrefixedEntries(ctx context.Context, fullpath util.FullPath, startFileName string, inclusive bool, limit int, prefix string) (entries []*filer2.Entry, err error) { - return nil, errors.New(filer2.UnsupportedListDirectoryPrefixedErr) + return nil, filer2.UnsupportedListDirectoryPrefixedErr } func (store *UniversalRedisStore) ListDirectoryEntries(ctx context.Context, fullpath util.FullPath, startFileName string, inclusive bool, diff --git a/weed/filer2/redis2/universal_redis_store.go b/weed/filer2/redis2/universal_redis_store.go index 9878799cf..2ce7ebec7 100644 --- a/weed/filer2/redis2/universal_redis_store.go +++ b/weed/filer2/redis2/universal_redis_store.go @@ -2,7 +2,6 @@ package redis2 import ( "context" - "errors" "fmt" "time" @@ -118,7 +117,7 @@ func (store *UniversalRedis2Store) DeleteFolderChildren(ctx context.Context, ful } func (store *UniversalRedis2Store) ListDirectoryPrefixedEntries(ctx context.Context, fullpath util.FullPath, startFileName string, inclusive bool, limit int, prefix string) (entries []*filer2.Entry, err error) { - return nil, errors.New(filer2.UnsupportedListDirectoryPrefixedErr) + return nil, filer2.UnsupportedListDirectoryPrefixedErr } func (store *UniversalRedis2Store) ListDirectoryEntries(ctx context.Context, fullpath util.FullPath, startFileName string, inclusive bool,