mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-29 21:54:13 +01:00
Merge pull request #8929 from wy65701436/read-only-sync
add read only for quota switcher
This commit is contained in:
commit
b844443509
@ -88,14 +88,20 @@ func (ia *InternalAPI) SwitchQuota() {
|
|||||||
ia.SendBadRequestError(err)
|
ia.SendBadRequestError(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
cur := config.ReadOnly()
|
||||||
// quota per project from disable to enable, it needs to update the quota usage bases on the DB records.
|
// quota per project from disable to enable, it needs to update the quota usage bases on the DB records.
|
||||||
if !config.QuotaPerProjectEnable() && req.Enabled {
|
if !config.QuotaPerProjectEnable() && req.Enabled {
|
||||||
|
if !cur {
|
||||||
|
config.GetCfgManager().Set(common.ReadOnly, true)
|
||||||
|
config.GetCfgManager().Save()
|
||||||
|
}
|
||||||
if err := ia.ensureQuota(); err != nil {
|
if err := ia.ensureQuota(); err != nil {
|
||||||
ia.SendInternalServerError(err)
|
ia.SendInternalServerError(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
|
config.GetCfgManager().Set(common.ReadOnly, cur)
|
||||||
config.GetCfgManager().Set(common.QuotaPerProjectEnable, req.Enabled)
|
config.GetCfgManager().Set(common.QuotaPerProjectEnable, req.Enabled)
|
||||||
config.GetCfgManager().Save()
|
config.GetCfgManager().Save()
|
||||||
}()
|
}()
|
||||||
|
Loading…
Reference in New Issue
Block a user