mirror of
https://github.com/pgsty/minio.git
synced 2026-08-10 08:13:28 +03:00
api: Notify events only if bucket notifications are set. (#2293)
While the existing code worked, it went to an entire cycle of constructing event structure and end up not sending it. Avoid this in the first place, but returning quickly if notifications are not set on the bucket.
This commit is contained in:
committed by
Anand Babu (AB) Periasamy
parent
3054b74260
commit
77248bd6e8
+15
-3
@@ -25,6 +25,7 @@ import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
mux "github.com/gorilla/mux"
|
||||
@@ -391,14 +392,25 @@ func (api objectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *h
|
||||
|
||||
// Load notification config if any.
|
||||
nConfig, err := api.loadNotificationConfig(bucket)
|
||||
// Notifications not set, return.
|
||||
if err == errNoSuchNotifications {
|
||||
return
|
||||
}
|
||||
// For all other errors, return.
|
||||
if err != nil {
|
||||
errorIf(err, "Unable to load notification config for bucket: \"%s\"", bucket)
|
||||
return
|
||||
}
|
||||
|
||||
size := int64(0) // FIXME: support notify size.
|
||||
// Notify event.
|
||||
notifyObjectCreatedEvent(nConfig, ObjectCreatedPost, bucket, object, md5Sum, size)
|
||||
// Fetch object info for notifications.
|
||||
objInfo, err := api.ObjectAPI.GetObjectInfo(bucket, object)
|
||||
if err != nil {
|
||||
errorIf(err, "Unable to fetch object info for \"%s\"", path.Join(bucket, object))
|
||||
return
|
||||
}
|
||||
|
||||
// Notify object created event.
|
||||
notifyObjectCreatedEvent(nConfig, ObjectCreatedPost, bucket, objInfo)
|
||||
}
|
||||
|
||||
// HeadBucketHandler - HEAD Bucket
|
||||
|
||||
Reference in New Issue
Block a user