1
0
mirror of https://github.com/minio/mc.git synced 2025-11-10 13:42:32 +03:00

watch/events: Support events on Get/Head operations as well. (#2116)

Fixes #2073
This commit is contained in:
Harshavardhana
2017-04-10 11:50:52 -07:00
committed by GitHub
parent fac4ef81b2
commit b0968e29e8
15 changed files with 290 additions and 140 deletions

View File

@@ -1,7 +1,7 @@
// +build linux
/*
* Minio Client (C) 2015 Minio, Inc.
* Minio Client (C) 2015, 2016, 2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this fs except in compliance with the License.
@@ -23,34 +23,40 @@ import (
)
var (
// EventTypePut contains the notify events that will cause a put
// EventTypePut contains the notify events that will cause a put (write)
EventTypePut = []notify.Event{notify.InCloseWrite | notify.InMovedTo}
// EventTypeDelete contains the notify events that will cause a delete
// EventTypeDelete contains the notify events that will cause a delete (remove)
EventTypeDelete = []notify.Event{notify.InDelete | notify.InDeleteSelf | notify.InMovedFrom}
// EventTypeGet contains the notify events that will cause a get (read)
EventTypeGet = []notify.Event{notify.InAccess | notify.InOpen}
)
// IsGetEvent checks if the event return is a get event.
func IsGetEvent(event notify.Event) bool {
for _, ev := range EventTypeGet {
if event == ev {
return true
}
}
return false
}
// IsPutEvent checks if the event returned is a put event
func IsPutEvent(event notify.Event) bool {
switch event {
case notify.InCloseWrite:
return true
case notify.InMovedTo:
return true
for _, ev := range EventTypePut {
if event == ev {
return true
}
}
return false
}
// IsDeleteEvent checks if the event returned is a delete event
func IsDeleteEvent(event notify.Event) bool {
switch event {
case notify.InDelete:
return true
case notify.InDeleteSelf:
return true
case notify.InMovedFrom:
return true
for _, ev := range EventTypeDelete {
if event == ev {
return true
}
}
return false
}