mirror of https://github.com/Xhofe/alist
fix(storage): Fixed a potential null value issue with not checking firstMount.
- Added a check to see if `firstMount` is null to prevent logic errors. - Adjusted the loading logic of `GetAllRoles` and `GetAllUsers` to only execute when `firstMount` is non-null. - Fixed the `usedBy` check logic to ensure that an error message is returned under the correct conditions. - Optimized code structure to reduce unnecessary execution paths.pull/9322/head
parent
3e2be10cf7
commit
66fd8d5ec8
|
@ -280,6 +280,7 @@ func DeleteStorageById(ctx context.Context, id uint) error {
|
|||
return errors.WithMessage(err, "failed get storage")
|
||||
}
|
||||
firstMount := firstPathSegment(storage.MountPath)
|
||||
if firstMount != "" {
|
||||
roles, err := db.GetAllRoles()
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "failed to load roles")
|
||||
|
@ -305,6 +306,7 @@ func DeleteStorageById(ctx context.Context, id uint) error {
|
|||
if len(usedBy) > 0 {
|
||||
return errors.Errorf("storage is used by %s, please cancel usage first", strings.Join(usedBy, ", "))
|
||||
}
|
||||
}
|
||||
if !storage.Disabled {
|
||||
storageDriver, err := GetStorageByMountPath(storage.MountPath)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue