fix: 优化同步快照名称重复错误显示 (#1478)

This commit is contained in:
ssongliu
2023-06-29 02:30:10 +00:00
committed by GitHub
parent 38c0d290e7
commit 847c14ddda
+6
View File
@@ -56,6 +56,12 @@ func (u *SnapshotService) SnapshotImport(req dto.SnapshotImport) error {
if len(req.Names) == 0 {
return fmt.Errorf("incorrect snapshot request body: %v", req.Names)
}
for _, snapName := range req.Names {
snap, _ := snapshotRepo.Get(commonRepo.WithByName(snapName))
if snap.ID != 0 {
return constant.ErrRecordExist
}
}
for _, snap := range req.Names {
nameItems := strings.Split(snap, "_")
if !strings.HasPrefix(snap, "1panel_v") || !strings.HasSuffix(snap, ".tar.gz") || len(nameItems) != 3 {