handle repository deletion event in API

This commit is contained in:
Wenkai Yin 2016-06-29 17:10:17 +08:00
parent ac17546d38
commit 23b026655c
2 changed files with 9 additions and 11 deletions

View File

@ -154,7 +154,15 @@ func (ra *RepositoryAPI) Delete() {
ra.CustomAbort(http.StatusInternalServerError, "internal error")
}
log.Infof("delete tag: %s %s", repoName, t)
go TriggerReplicationByRepository(repoName, []string{t}, models.RepOpDelete)
}
go func() {
log.Debug("refreshing catalog cache")
if err := cache.RefreshCatalogCache(); err != nil {
log.Errorf("error occurred while refresh catalog cache: %v", err)
}
}()
}
type tag struct {

View File

@ -73,7 +73,7 @@ func (n *NotificationHandler) Post() {
log.Errorf("failed to add access log: %v", err)
}
}()
if action == "push" || action == "delete" {
if action == "push" {
go func() {
if err := cache.RefreshCatalogCache(); err != nil {
log.Errorf("failed to refresh cache: %v", err)
@ -83,8 +83,6 @@ func (n *NotificationHandler) Post() {
operation := ""
if action == "push" {
operation = models.RepOpTransfer
} else {
operation = models.RepOpDelete
}
go api.TriggerReplicationByRepository(repository, []string{tag}, operation)
@ -96,14 +94,6 @@ func filterEvents(notification *models.Notification) ([]*models.Event, error) {
events := []*models.Event{}
for _, event := range notification.Events {
//delete
// TODO add tag field
if event.Action == "delete" {
events = append(events, &event)
continue
}
isManifest, err := regexp.MatchString(manifestPattern, event.Target.MediaType)
if err != nil {
log.Errorf("failed to match the media type against pattern: %v", err)