mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-01 12:06:38 +08:00
fix: add storage deletion with library cleanup and scan validation
- Delete storage config now properly removes related libraries and media - Scanner validates storage config exists before starting cloud scan - Prevents orphaned scans when storage is removed - Added repository methods: DeleteByType, FindByID for storage config - Remove unused storageHandler route to fix compilation
This commit is contained in:
@@ -65,3 +65,19 @@ func (r *StorageConfigRepository) Upsert(ctx context.Context, c *model.StorageCo
|
||||
"updated_at": time.Now(),
|
||||
}).Error
|
||||
}
|
||||
|
||||
|
||||
// Delete removes a storage config by ID.
|
||||
func (r *StorageConfigRepository) Delete(ctx context.Context, id string) error {
|
||||
return r.db.WithContext(ctx).Where("id = ?", id).Delete(&model.StorageConfig{}).Error
|
||||
}
|
||||
|
||||
// FindByID returns a storage config by ID.
|
||||
func (r *StorageConfigRepository) FindByID(ctx context.Context, id string) (*model.StorageConfig, error) {
|
||||
var c model.StorageConfig
|
||||
err := r.db.WithContext(ctx).Where("id = ?", id).First(&c).Error
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
return &c, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user