mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 16:34:30 +01:00
cache: fix root folder caching
This commit is contained in:
parent
1c75581959
commit
f9a1a7e700
15
backend/cache/storage_persistent.go
vendored
15
backend/cache/storage_persistent.go
vendored
@ -202,13 +202,24 @@ func (b *Persistent) AddBatchDir(cachedDirs []*Directory) error {
|
||||
}
|
||||
|
||||
return b.db.Update(func(tx *bolt.Tx) error {
|
||||
bucket := b.getBucket(cachedDirs[0].Dir, true, tx)
|
||||
var bucket *bolt.Bucket
|
||||
if cachedDirs[0].Dir == "" {
|
||||
bucket = tx.Bucket([]byte(RootBucket))
|
||||
} else {
|
||||
bucket = b.getBucket(cachedDirs[0].Dir, true, tx)
|
||||
}
|
||||
if bucket == nil {
|
||||
return errors.Errorf("couldn't open bucket (%v)", cachedDirs[0].Dir)
|
||||
}
|
||||
|
||||
for _, cachedDir := range cachedDirs {
|
||||
b, err := bucket.CreateBucketIfNotExists([]byte(cachedDir.Name))
|
||||
var b *bolt.Bucket
|
||||
var err error
|
||||
if cachedDir.Name == "" {
|
||||
b = bucket
|
||||
} else {
|
||||
b, err = bucket.CreateBucketIfNotExists([]byte(cachedDir.Name))
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user