api: StatObject if listing returned missing file. (#1945)
This commit is contained in:
+26
-3
@@ -812,7 +812,6 @@ func (c *s3Client) Stat(isIncomplete bool) (*clientContent, *probe.Error) {
|
||||
return objectMetadata, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, probe.NewError(ObjectMissing{})
|
||||
}
|
||||
|
||||
@@ -835,8 +834,32 @@ func (c *s3Client) Stat(isIncomplete bool) (*clientContent, *probe.Error) {
|
||||
return objectMetadata, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, probe.NewError(ObjectMissing{})
|
||||
objectStat, e := c.api.StatObject(bucket, object)
|
||||
if e != nil {
|
||||
errResponse := minio.ToErrorResponse(e)
|
||||
if errResponse.Code == "AccessDenied" {
|
||||
return nil, probe.NewError(PathInsufficientPermission{Path: c.targetURL.String()})
|
||||
}
|
||||
if errResponse.Code == "NoSuchBucket" {
|
||||
return nil, probe.NewError(BucketDoesNotExist{
|
||||
Bucket: bucket,
|
||||
})
|
||||
}
|
||||
if errResponse.Code == "InvalidBucketName" {
|
||||
return nil, probe.NewError(BucketInvalid{
|
||||
Bucket: bucket,
|
||||
})
|
||||
}
|
||||
if errResponse.Code == "NoSuchKey" || errResponse.Code == "InvalidArgument" {
|
||||
return nil, probe.NewError(ObjectMissing{})
|
||||
}
|
||||
return nil, probe.NewError(e)
|
||||
}
|
||||
objectMetadata.URL = *c.targetURL
|
||||
objectMetadata.Time = objectStat.LastModified
|
||||
objectMetadata.Size = objectStat.Size
|
||||
objectMetadata.Type = os.FileMode(0664)
|
||||
return objectMetadata, nil
|
||||
}
|
||||
|
||||
func isAmazon(host string) bool {
|
||||
|
||||
+2
-10
@@ -82,21 +82,13 @@ func objectDifference(sourceClnt, targetClnt Client, sourceURL, targetURL string
|
||||
}
|
||||
|
||||
if !srcEOF && srcCtnt.Err != nil {
|
||||
if isErrIgnored(srcCtnt.Err) {
|
||||
errorIf(srcCtnt.Err.Trace(sourceURL, targetURL), fmt.Sprintf("Failed on '%s'", sourceURL))
|
||||
} else {
|
||||
errorIf(srcCtnt.Err.Trace(sourceURL, targetURL), fmt.Sprintf("Failed on '%s'", sourceURL))
|
||||
}
|
||||
errorIf(srcCtnt.Err.Trace(sourceURL, targetURL), fmt.Sprintf("Failed on '%s'", sourceURL))
|
||||
srcCtnt, srcOk = <-srcCh
|
||||
continue
|
||||
}
|
||||
|
||||
if !tgtEOF && tgtCtnt.Err != nil {
|
||||
if isErrIgnored(tgtCtnt.Err) {
|
||||
errorIf(tgtCtnt.Err.Trace(sourceURL, targetURL), fmt.Sprintf("Failed on '%s'", targetURL))
|
||||
} else {
|
||||
errorIf(tgtCtnt.Err.Trace(sourceURL, targetURL), fmt.Sprintf("Failed on '%s'", targetURL))
|
||||
}
|
||||
errorIf(tgtCtnt.Err.Trace(sourceURL, targetURL), fmt.Sprintf("Failed on '%s'", targetURL))
|
||||
tgtCtnt, tgtOk = <-tgtCh
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user