mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-27 02:58:05 +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)
|
||||
return
|
||||
}
|
||||
cur := config.ReadOnly()
|
||||
// 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 !cur {
|
||||
config.GetCfgManager().Set(common.ReadOnly, true)
|
||||
config.GetCfgManager().Save()
|
||||
}
|
||||
if err := ia.ensureQuota(); err != nil {
|
||||
ia.SendInternalServerError(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
defer func() {
|
||||
config.GetCfgManager().Set(common.ReadOnly, cur)
|
||||
config.GetCfgManager().Set(common.QuotaPerProjectEnable, req.Enabled)
|
||||
config.GetCfgManager().Save()
|
||||
}()
|
||||
|
Loading…
Reference in New Issue
Block a user