mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-11 17:56:37 +08:00
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:
@@ -441,7 +441,7 @@ func TestUpdateStorageConfigValidation(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("stage local config while active s3 is unreachable", func(t *testing.T) {
|
||||
t.Run("switch to local while active s3 is unreachable", func(t *testing.T) {
|
||||
activeCfg := storage.DefaultConfig()
|
||||
activeCfg.Driver = storage.DriverS3
|
||||
activeCfg.S3.Endpoint = "http://127.0.0.1:9999"
|
||||
@@ -486,8 +486,8 @@ func TestUpdateStorageConfigValidation(t *testing.T) {
|
||||
if err := json.Unmarshal([]byte(dbCfg.Value), &savedCfg); err != nil {
|
||||
t.Fatalf("parse saved storage config failed: %v", err)
|
||||
}
|
||||
if savedCfg.Driver != storage.DriverS3 {
|
||||
t.Fatalf("active driver = %q, want %q until migration completes", savedCfg.Driver, storage.DriverS3)
|
||||
if savedCfg.Driver != storage.DriverLocal {
|
||||
t.Fatalf("active driver = %q, want %q after save", savedCfg.Driver, storage.DriverLocal)
|
||||
}
|
||||
if savedCfg.Local.Root != tempDir {
|
||||
t.Fatalf("staged local root = %q, want %q", savedCfg.Local.Root, tempDir)
|
||||
|
||||
Reference in New Issue
Block a user