feat(cmd): disable a storage with specific mountPath (close #3564)

This commit is contained in:
Andy Hsu
2023-03-07 19:01:40 +08:00
parent 3d3f23ec9e
commit 00ff0a43a7
2 changed files with 61 additions and 0 deletions

View File

@ -51,6 +51,15 @@ func GetStorageById(id uint) (*model.Storage, error) {
return &storage, nil
}
// GetStorageByMountPath Get Storage by mountPath, used to update storage usually
func GetStorageByMountPath(mountPath string) (*model.Storage, error) {
var storage model.Storage
if err := db.Where("mount_path = ?", mountPath).First(&storage).Error; err != nil {
return nil, errors.WithStack(err)
}
return &storage, nil
}
func GetEnabledStorages() ([]model.Storage, error) {
var storages []model.Storage
if err := db.Where(fmt.Sprintf("%s = ?", columnName("disabled")), false).Find(&storages).Error; err != nil {