Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions drivers/onedrive/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,20 @@ func (d *Onedrive) InitReference(refStorage driver.Driver) error {
}

func (d *Onedrive) Drop(ctx context.Context) error {
d.mutex.Lock()
defer d.mutex.Unlock()
// RootFolderPath may change before this driver instance is reinitialized.
d.root = nil
d.ref = nil
return nil
}

func (d *Onedrive) GetRoot(ctx context.Context) (model.Obj, error) {
d.mutex.Lock()
defer d.mutex.Unlock()
if d.root != nil {
return d.root, nil
}
d.mutex.Lock()
defer d.mutex.Unlock()
root := &Object{
ObjThumb: model.ObjThumb{
Object: model.Object{
Expand Down
12 changes: 7 additions & 5 deletions internal/op/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,16 @@ func UpdateStorage(ctx context.Context, storage model.Storage) error {
return nil
}
storageDriver, err := GetStorageByMountPath(oldStorage.MountPath)
if err != nil {
return errors.WithMessage(err, "failed get storage driver")
}
// Storage settings may change which objects are exposed at the same mount
// path, so cached entries must be discarded before reinitializing the driver.
Cache.DeleteDirectoryTree(storageDriver, "/")
Cache.InvalidateStorageDetails(storageDriver)
if oldStorage.MountPath != storage.MountPath {
// mount path renamed, need to drop the storage
storagesMap.Delete(oldStorage.MountPath)
Cache.DeleteDirectoryTree(storageDriver, "/")
Cache.InvalidateStorageDetails(storageDriver)
}
if err != nil {
return errors.WithMessage(err, "failed get storage driver")
}
err = storageDriver.Drop(ctx)
if err != nil {
Expand Down
Loading