fix mirror crash if source is deleted (#3206)

This commit is contained in:
Harshavardhana
2020-05-05 23:55:35 -07:00
committed by GitHub
parent b99c313366
commit dc2ad27429
2 changed files with 13 additions and 2 deletions
+12 -1
View File
@@ -629,8 +629,19 @@ func (c *S3Client) notificationToEventsInfo(ninfo minio.NotificationInfo) []Even
var eventsInfo = make([]EventInfo, len(ninfo.Records))
for i, record := range ninfo.Records {
bucketName := record.S3.Bucket.Name
var key string
// Unescape only if needed, look for URL encoded content.
if strings.Contains(record.S3.Object.Key, "%2F") {
var e error
key, e = url.QueryUnescape(record.S3.Object.Key)
if e != nil {
key = record.S3.Object.Key
}
} else {
key = record.S3.Object.Key
}
u := c.targetURL.Clone()
u.Path = path.Join(string(u.Separator), bucketName, record.S3.Object.Key)
u.Path = path.Join(string(u.Separator), bucketName, key)
if strings.HasPrefix(record.EventName, "s3:ObjectCreated:") {
if strings.HasPrefix(record.EventName, "s3:ObjectCreated:Copy") {
eventsInfo[i] = EventInfo{
+1 -1
View File
@@ -227,7 +227,7 @@ func getSourceStream(alias string, urlStr string, fetchStat bool, sse encrypt.Se
if mok {
oinfo, e := mo.Stat()
if e != nil {
return nil, nil, err.Trace(alias, urlStr)
return nil, nil, probe.NewError(e).Trace(alias, urlStr)
}
st = &ClientContent{}
st.Time = oinfo.LastModified