fix(storage): apply driver switch on save and repoint upload records

Saving storage settings now activates the selected driver immediately
instead of staging it until migration. When the driver changes, existing
upload rows are repointed to the new storage_driver so /f/{id} reads use
the correct backend. ForDriver can also open non-active drivers from the
saved multi-backend config.
This commit is contained in:
ryan
2026-06-18 13:39:07 +08:00
parent 6fa7034172
commit 1f391e9ec2
9 changed files with 134 additions and 47 deletions
+4 -3
View File
@@ -168,10 +168,11 @@ func ForDriver(ctx context.Context, driver Driver) (Backend, error) {
if err != nil {
return nil, err
}
if cfg.Driver == driver {
return NewBackend(ctx, cfg, driver)
backend, err := NewBackend(ctx, cfg, driver)
if err != nil {
return nil, fmt.Errorf("storage configuration for driver %q is unavailable: %w", driver, err)
}
return nil, fmt.Errorf("storage configuration for driver %q is unavailable", driver)
return backend, nil
}
type functionBackend struct {