diff --git a/weed/filer2/cassandra/cassandra_store.go b/weed/filer2/cassandra/cassandra_store.go index a996a6401..8214935f9 100644 --- a/weed/filer2/cassandra/cassandra_store.go +++ b/weed/filer2/cassandra/cassandra_store.go @@ -2,6 +2,7 @@ package cassandra import ( "context" + "errors" "fmt" "github.com/gocql/gocql" @@ -126,7 +127,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, fmt.Errorf("UNSUPPORTED") + return nil, errors.New(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 043bf995d..93f3f3781 100644 --- a/weed/filer2/etcd/etcd_store.go +++ b/weed/filer2/etcd/etcd_store.go @@ -2,6 +2,7 @@ package etcd import ( "context" + "errors" "fmt" "strings" "time" @@ -136,7 +137,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, fmt.Errorf("UNSUPPORTED") + return nil, errors.New(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 cc8fecc42..ef81cae2b 100644 --- a/weed/filer2/filer.go +++ b/weed/filer2/filer.go @@ -18,7 +18,10 @@ import ( "github.com/chrislusf/seaweedfs/weed/wdclient" ) -const PaginationSize = 1024 * 256 +const ( + PaginationSize = 1024 * 256 + UnsupportedListDirectoryPrefixedErr = "UNSUPPORTED" +) var ( OS_UID = uint32(os.Getuid()) diff --git a/weed/filer2/filerstore.go b/weed/filer2/filerstore.go index 9ea39cf11..3c1e555b1 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() == "UNSUPPORTED" { + if err.Error() == UnsupportedListDirectoryPrefixedErr { count := 0 notPrefixed, err := fsw.ActualStore.ListDirectoryEntries(ctx, dirPath, startFileName, includeStartFile, limit) if err != nil { @@ -179,11 +179,6 @@ func (fsw *FilerStoreWrapper) ListDirectoryPrefixedEntries(ctx context.Context, return entries, nil } -func (fsw *FilerStoreWrapper) ListDirectoryUnSupPrefixedEntries(ctx context.Context, dirPath util.FullPath, startFileName string, includeStartFile bool, limit int, prefix string) (entries []*Entry, err error) { - - return entries, nil -} - func (fsw *FilerStoreWrapper) BeginTransaction(ctx context.Context) (context.Context, error) { return fsw.ActualStore.BeginTransaction(ctx) } diff --git a/weed/filer2/leveldb/leveldb_store.go b/weed/filer2/leveldb/leveldb_store.go index 104e3d026..787671c55 100644 --- a/weed/filer2/leveldb/leveldb_store.go +++ b/weed/filer2/leveldb/leveldb_store.go @@ -3,9 +3,10 @@ package leveldb import ( "bytes" "context" + "errors" "fmt" "github.com/syndtr/goleveldb/leveldb" - "github.com/syndtr/goleveldb/leveldb/errors" + leveldb_errors "github.com/syndtr/goleveldb/leveldb/errors" "github.com/syndtr/goleveldb/leveldb/opt" leveldb_util "github.com/syndtr/goleveldb/leveldb/util" @@ -49,7 +50,7 @@ func (store *LevelDBStore) initialize(dir string) (err error) { } if store.db, err = leveldb.OpenFile(dir, opts); err != nil { - if errors.IsCorrupted(err) { + if leveldb_errors.IsCorrupted(err) { store.db, err = leveldb.RecoverFile(dir, opts) } if err != nil { @@ -159,7 +160,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, fmt.Errorf("UNSUPPORTED") + return nil, errors.New(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 478661d0e..4fc110d69 100644 --- a/weed/filer2/leveldb2/leveldb2_store.go +++ b/weed/filer2/leveldb2/leveldb2_store.go @@ -4,9 +4,10 @@ import ( "bytes" "context" "crypto/md5" + "errors" "fmt" "github.com/syndtr/goleveldb/leveldb" - "github.com/syndtr/goleveldb/leveldb/errors" + leveldb_errors "github.com/syndtr/goleveldb/leveldb/errors" "github.com/syndtr/goleveldb/leveldb/opt" leveldb_util "github.com/syndtr/goleveldb/leveldb/util" "io" @@ -52,7 +53,7 @@ func (store *LevelDB2Store) initialize(dir string, dbCount int) (err error) { dbFolder := fmt.Sprintf("%s/%02d", dir, d) os.MkdirAll(dbFolder, 0755) db, dbErr := leveldb.OpenFile(dbFolder, opts) - if errors.IsCorrupted(dbErr) { + if leveldb_errors.IsCorrupted(dbErr) { db, dbErr = leveldb.RecoverFile(dbFolder, opts) } if dbErr != nil { @@ -168,7 +169,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, fmt.Errorf("UNSUPPORTED") + return nil, errors.New(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 1fa18f872..314f36ce2 100644 --- a/weed/filer2/mongodb/mongodb_store.go +++ b/weed/filer2/mongodb/mongodb_store.go @@ -2,6 +2,7 @@ package mongodb import ( "context" + "errors" "fmt" "github.com/chrislusf/seaweedfs/weed/filer2" "github.com/chrislusf/seaweedfs/weed/glog" @@ -168,7 +169,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, fmt.Errorf("UNSUPPORTED") + return nil, errors.New(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 9c71b045d..66450b5a7 100644 --- a/weed/filer2/redis/universal_redis_store.go +++ b/weed/filer2/redis/universal_redis_store.go @@ -2,6 +2,7 @@ package redis import ( "context" + "errors" "fmt" "sort" "strings" @@ -122,7 +123,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, fmt.Errorf("UNSUPPORTED") + return nil, errors.New(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 6490f7bed..9878799cf 100644 --- a/weed/filer2/redis2/universal_redis_store.go +++ b/weed/filer2/redis2/universal_redis_store.go @@ -2,6 +2,7 @@ package redis2 import ( "context" + "errors" "fmt" "time" @@ -117,7 +118,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, fmt.Errorf("UNSUPPORTED") + return nil, errors.New(filer2.UnsupportedListDirectoryPrefixedErr) } func (store *UniversalRedis2Store) ListDirectoryEntries(ctx context.Context, fullpath util.FullPath, startFileName string, inclusive bool,