mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-23 10:45:45 +01:00
bug fix
This commit is contained in:
parent
14e71f0052
commit
81600e8db4
@ -14,8 +14,6 @@ import (
|
|||||||
// RepPolicyAPI handles /api/replicationPolicies /api/replicationPolicies/:id/enablement
|
// RepPolicyAPI handles /api/replicationPolicies /api/replicationPolicies/:id/enablement
|
||||||
type RepPolicyAPI struct {
|
type RepPolicyAPI struct {
|
||||||
BaseAPI
|
BaseAPI
|
||||||
policyID int64
|
|
||||||
policy *models.RepPolicy
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare validates whether the user has system admin role
|
// Prepare validates whether the user has system admin role
|
||||||
@ -214,11 +212,11 @@ func (pa *RepPolicyAPI) UpdateEnablement() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if pa.policy.Enabled == e.Enabled {
|
if policy.Enabled == e.Enabled {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := dao.UpdateRepPolicyEnablement(pa.policyID, e.Enabled); err != nil {
|
if err := dao.UpdateRepPolicyEnablement(id, e.Enabled); err != nil {
|
||||||
log.Errorf("Failed to update policy enablement in DB, error: %v", err)
|
log.Errorf("Failed to update policy enablement in DB, error: %v", err)
|
||||||
pa.RenderError(http.StatusInternalServerError, "Internal Error")
|
pa.RenderError(http.StatusInternalServerError, "Internal Error")
|
||||||
return
|
return
|
||||||
@ -226,18 +224,18 @@ func (pa *RepPolicyAPI) UpdateEnablement() {
|
|||||||
|
|
||||||
if e.Enabled == 1 {
|
if e.Enabled == 1 {
|
||||||
go func() {
|
go func() {
|
||||||
if err := TriggerReplication(pa.policyID, "", nil, models.RepOpTransfer); err != nil {
|
if err := TriggerReplication(id, "", nil, models.RepOpTransfer); err != nil {
|
||||||
log.Errorf("failed to trigger replication of %d: %v", pa.policyID, err)
|
log.Errorf("failed to trigger replication of %d: %v", id, err)
|
||||||
} else {
|
} else {
|
||||||
log.Infof("replication of %d triggered", pa.policyID)
|
log.Infof("replication of %d triggered", id)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
} else {
|
} else {
|
||||||
go func() {
|
go func() {
|
||||||
if err := postReplicationAction(pa.policyID, "stop"); err != nil {
|
if err := postReplicationAction(id, "stop"); err != nil {
|
||||||
log.Errorf("failed to stop replication of %d: %v", pa.policyID, err)
|
log.Errorf("failed to stop replication of %d: %v", id, err)
|
||||||
} else {
|
} else {
|
||||||
log.Infof("try to stop replication of %d", pa.policyID)
|
log.Infof("try to stop replication of %d", id)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user