fix: 修改同步快照过程中的名称校验 (#3797)

pull/3805/head
ssongliu 2024-02-03 13:14:22 +08:00 committed by GitHub
parent fdf9046430
commit 0449868d3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 0 additions and 8 deletions

View File

@ -77,10 +77,6 @@ func (u *SnapshotService) SnapshotImport(req dto.SnapshotImport) error {
if !strings.HasPrefix(shortName, "1panel_v") || !strings.HasSuffix(shortName, ".tar.gz") || len(nameItems) != 3 {
return fmt.Errorf("incorrect snapshot name format of %s", shortName)
}
formatTime, err := time.Parse("20060102150405", strings.ReplaceAll(nameItems[2], ".tar.gz", ""))
if err != nil {
return fmt.Errorf("incorrect snapshot name format of %s", shortName)
}
if strings.HasSuffix(snap, ".tar.gz") {
snap = strings.ReplaceAll(snap, ".tar.gz", "")
}
@ -91,10 +87,6 @@ func (u *SnapshotService) SnapshotImport(req dto.SnapshotImport) error {
Version: nameItems[1],
Description: req.Description,
Status: constant.StatusSuccess,
BaseModel: model.BaseModel{
CreatedAt: formatTime,
UpdatedAt: formatTime,
},
}
if err := snapshotRepo.Create(&itemSnap); err != nil {
return err