mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-02-13 03:50:07 +08:00
fix: fix the issue of abnormal display of backup account size (#7833)
This commit is contained in:
parent
8c2bb231c6
commit
364edbe2ca
@ -166,14 +166,30 @@ func (u *BackupRepo) GetRecord(opts ...DBOption) (*model.BackupRecord, error) {
|
||||
|
||||
func (u *BackupRepo) SyncAll(data []model.BackupAccount) error {
|
||||
tx := global.DB.Begin()
|
||||
if err := tx.Where("is_public = ?", 1).Delete(&model.BackupAccount{}).Error; err != nil {
|
||||
var oldAccounts []model.BackupAccount
|
||||
_ = tx.Where("is_public = ?", 1).Find(&oldAccounts).Error
|
||||
oldAccountMap := make(map[string]uint)
|
||||
for _, item := range oldAccounts {
|
||||
oldAccountMap[item.Name] = item.ID
|
||||
}
|
||||
for _, item := range data {
|
||||
if val, ok := oldAccountMap[item.Name]; ok {
|
||||
item.ID = val
|
||||
delete(oldAccountMap, item.Name)
|
||||
} else {
|
||||
item.ID = 0
|
||||
}
|
||||
if err := tx.Model(model.BackupAccount{}).Where("id = ?", item.ID).Save(&item).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
if err := tx.Model(model.BackupAccount{}).Save(&data).Error; err != nil {
|
||||
}
|
||||
for _, val := range oldAccountMap {
|
||||
if err := tx.Where("id = ?", val).Delete(&model.BackupAccount{}).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
}
|
||||
tx.Commit()
|
||||
return nil
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ var InitSetting = &gormigrate.Migration{
|
||||
return err
|
||||
}
|
||||
|
||||
if err := tx.Create(&model.Setting{Key: "EncryptKey", Value: common.RandStr(16)}).Error; err != nil {
|
||||
if err := tx.Create(&model.Setting{Key: "EncryptKey", Value: global.CONF.Base.EncryptKey}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if err := tx.Create(&model.Setting{Key: "SystemIP", Value: ""}).Error; err != nil {
|
||||
|
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div>
|
||||
<div v-loading="loading">
|
||||
<LayoutContent :title="$t('setting.backupAccount')">
|
||||
<template #leftToolBar>
|
||||
<el-button type="primary" @click="onOpenDialog('create')">
|
||||
|
Loading…
x
Reference in New Issue
Block a user