Skip to content

Commit

Permalink
fix(storage): delete storage fails if a panic occurred during initial…
Browse files Browse the repository at this point in the history
…ization (AlistGo#7501)

* fix(storage): store storages map when init storage panic

* fix(drivers): add nil check to drop method
  • Loading branch information
Jason-Fly authored and MadDogOwner committed Nov 16, 2024
1 parent a5a2661 commit 08a1707
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion drivers/chaoxing/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ func (d *ChaoXing) Init(ctx context.Context) error {
}

func (d *ChaoXing) Drop(ctx context.Context) error {
d.cron.Stop()
if d.cron != nil {
d.cron.Stop()
}
return nil
}

Expand Down
4 changes: 3 additions & 1 deletion drivers/vtencent/drive.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ func (d *Vtencent) Init(ctx context.Context) error {
}

func (d *Vtencent) Drop(ctx context.Context) error {
d.cron.Stop()
if d.cron != nil {
d.cron.Stop()
}
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/op/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func initStorage(ctx context.Context, storage model.Storage, storageDriver drive
log.Errorf("panic init storage: %s", errInfo)
driverStorage.SetStatus(errInfo)
MustSaveDriverStorage(storageDriver)
storagesMap.Delete(driverStorage.MountPath)
storagesMap.Store(driverStorage.MountPath, storageDriver)
}
}()
// Unmarshal Addition
Expand Down

0 comments on commit 08a1707

Please sign in to comment.