示例#1
0
文件: common.go 项目: nanopack/portal
func SetVips(vips []core.Vip) error {
	// in case of failure
	oldVips, err := database.GetVips()
	if err != nil {
		return err
	}

	// apply vips to vipmgr
	err = vipmgr.SetVips(vips)
	if err != nil {
		return err
	}

	if !database.CentralStore {
		// save to backend
		err = database.SetVips(vips)
		if err != nil {
			// undo vipmgr action
			if uerr := vipmgr.SetVips(oldVips); uerr != nil {
				err = fmt.Errorf("%v - %v", err.Error(), uerr.Error())
			}
			return err
		}
	}
	return nil
}
示例#2
0
文件: none.go 项目: nanopack/portal
func (n None) SetVips(vips []core.Vip) error {
	err := common.SetVips(vips)
	if err != nil {
		return err
	}
	if database.CentralStore {
		return database.SetVips(vips)
	}
	return nil
}