mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-03 14:37:44 +01:00
add read only for quota switcher
Signed-off-by: wang yan <wangyan@vmware.com>
This commit is contained in:
parent
b75cbe1a7e
commit
d8e17b122e
@ -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