Browse Source

leveldb3: ensure repeatable adding removing buckets

pull/1743/head
Chris Lu 4 years ago
parent
commit
ca73013453
  1. 14
      weed/filer/leveldb3/leveldb3_store.go

14
weed/filer/leveldb3/leveldb3_store.go

@ -137,6 +137,18 @@ func (store *LevelDB3Store) findDB(fullpath weed_util.FullPath, isForChildren bo
return db, bucket, shortPath, nil return db, bucket, shortPath, nil
} }
func (store *LevelDB3Store) closeDB(bucket string) {
store.dbsLock.Lock()
defer store.dbsLock.Unlock()
if db, found := store.dbs[bucket]; found {
db.Close()
delete(store.dbs, bucket)
}
}
func (store *LevelDB3Store) BeginTransaction(ctx context.Context) (context.Context, error) { func (store *LevelDB3Store) BeginTransaction(ctx context.Context) (context.Context, error) {
return ctx, nil return ctx, nil
} }
@ -240,7 +252,7 @@ func (store *LevelDB3Store) DeleteFolderChildren(ctx context.Context, fullpath w
} }
if bucket != DEFAULT && shortPath == "/" { if bucket != DEFAULT && shortPath == "/" {
db.Close()
store.closeDB(bucket)
if bucket != "" { // just to make sure if bucket != "" { // just to make sure
os.RemoveAll(store.dir + "/" + bucket) os.RemoveAll(store.dir + "/" + bucket)
} }

Loading…
Cancel
Save