|
|
@ -377,18 +377,24 @@ func loadNotificationConfig(bucket string, objAPI ObjectLayer) (*notificationCon |
|
|
|
// 'errNoSuchNotifications'. This is default when no
|
|
|
|
// 'errNoSuchNotifications'. This is default when no
|
|
|
|
// bucket notifications are found on the bucket.
|
|
|
|
// bucket notifications are found on the bucket.
|
|
|
|
if isErrObjectNotFound(err) || isErrIncompleteBody(err) { |
|
|
|
if isErrObjectNotFound(err) || isErrIncompleteBody(err) { |
|
|
|
return nil, errNoSuchNotifications |
|
|
|
return nil, traceError(errNoSuchNotifications) |
|
|
|
} |
|
|
|
} |
|
|
|
errorIf(err, "Unable to load bucket-notification for bucket %s", bucket) |
|
|
|
errorIf(err, "Unable to load bucket-notification for bucket %s", bucket) |
|
|
|
// Returns error for other errors.
|
|
|
|
// Returns error for other errors.
|
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if `notifications.xml` is empty we should return NoSuchNotifications.
|
|
|
|
|
|
|
|
if buffer.Len() == 0 { |
|
|
|
|
|
|
|
return nil, traceError(errNoSuchNotifications) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Unmarshal notification bytes.
|
|
|
|
// Unmarshal notification bytes.
|
|
|
|
notificationConfigBytes := buffer.Bytes() |
|
|
|
notificationConfigBytes := buffer.Bytes() |
|
|
|
notificationCfg := ¬ificationConfig{} |
|
|
|
notificationCfg := ¬ificationConfig{} |
|
|
|
if err = xml.Unmarshal(notificationConfigBytes, ¬ificationCfg); err != nil { |
|
|
|
// Unmarshal notification bytes only if we read data.
|
|
|
|
return nil, err |
|
|
|
if err = xml.Unmarshal(notificationConfigBytes, notificationCfg); err != nil { |
|
|
|
|
|
|
|
return nil, traceError(err) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Return success.
|
|
|
|
// Return success.
|
|
|
@ -418,23 +424,27 @@ func loadListenerConfig(bucket string, objAPI ObjectLayer) ([]listenerConfig, er |
|
|
|
var buffer bytes.Buffer |
|
|
|
var buffer bytes.Buffer |
|
|
|
err := objAPI.GetObject(minioMetaBucket, lcPath, 0, -1, &buffer) |
|
|
|
err := objAPI.GetObject(minioMetaBucket, lcPath, 0, -1, &buffer) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
// 'notification.xml' not found return
|
|
|
|
// 'listener.json' not found return
|
|
|
|
// 'errNoSuchNotifications'. This is default when no
|
|
|
|
// 'errNoSuchNotifications'. This is default when no
|
|
|
|
// bucket listeners are found on the bucket.
|
|
|
|
// bucket listeners are found on the bucket
|
|
|
|
if isErrObjectNotFound(err) { |
|
|
|
if isErrObjectNotFound(err) || isErrIncompleteBody(err) { |
|
|
|
return nil, errNoSuchNotifications |
|
|
|
return nil, traceError(errNoSuchNotifications) |
|
|
|
} |
|
|
|
} |
|
|
|
errorIf(err, "Unable to load bucket-listeners for bucket %s", bucket) |
|
|
|
errorIf(err, "Unable to load bucket-listeners for bucket %s", bucket) |
|
|
|
// Returns error for other errors.
|
|
|
|
// Returns error for other errors.
|
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Unmarshal notification bytes.
|
|
|
|
// if `listener.json` is empty we should return NoSuchNotifications.
|
|
|
|
|
|
|
|
if buffer.Len() == 0 { |
|
|
|
|
|
|
|
return nil, traceError(errNoSuchNotifications) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var lCfg []listenerConfig |
|
|
|
var lCfg []listenerConfig |
|
|
|
lConfigBytes := buffer.Bytes() |
|
|
|
lConfigBytes := buffer.Bytes() |
|
|
|
if err = json.Unmarshal(lConfigBytes, &lCfg); err != nil { |
|
|
|
if err = json.Unmarshal(lConfigBytes, &lCfg); err != nil { |
|
|
|
errorIf(err, "Unable to unmarshal listener config from JSON.") |
|
|
|
errorIf(err, "Unable to unmarshal listener config from JSON.") |
|
|
|
return nil, err |
|
|
|
return nil, traceError(err) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Return success.
|
|
|
|
// Return success.
|
|
|
|