增加备份和导出功能

This commit is contained in:
dushixiang
2021-11-15 14:21:46 +08:00
parent 52309870d8
commit 1d232f7269
14 changed files with 472 additions and 134 deletions

View File

@ -42,7 +42,10 @@ func (r StorageService) InitStorages() error {
}
drivePath := r.GetBaseDrivePath()
storages := r.storageRepository.FindAll()
storages, err := r.storageRepository.FindAll()
if err != nil {
return err
}
for i := 0; i < len(storages); i++ {
storage := storages[i]
// 判断是否为遗留的数据:磁盘空间在,但用户已删除
@ -137,6 +140,9 @@ func (r StorageService) DeleteStorageById(id string, force bool) error {
drivePath := r.GetBaseDrivePath()
storage, err := r.storageRepository.FindById(id)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil
}
return err
}
if !force && storage.IsDefault {