s3: Use head API before listing in client.Stat() (#3156)
Stat() is supposed to return valid information for existing objects and existing prefixes as well. The current mechanism issues a listing request and searches for the object or prefix in the returned list, but this could take time if there are a lot of entries under a parent prefix. The new commit changes the internal behavior but not the functional output. It issues a HEAD request first, if there is no object then assumes it is a prefix and does listing in order to find it.
This commit is contained in:
+1
-1
@@ -152,7 +152,7 @@ func catURL(sourceURL string, encKeyDB map[string][]prefixSSEPair) *probe.Error
|
||||
// downloaded object is equal to the original one. FS files
|
||||
// are ignored since some of them have zero size though they
|
||||
// have contents like files under /proc.
|
||||
client, content, err := url2Stat(sourceURL, false, false, encKeyDB)
|
||||
client, content, err := url2Stat(sourceURL, false, encKeyDB)
|
||||
if err == nil && client.GetURL().Type == objectStorage {
|
||||
size = content.Size
|
||||
}
|
||||
|
||||
+15
-19
@@ -1020,7 +1020,7 @@ func (f *fsClient) SetAccess(access string, isJSON bool) *probe.Error {
|
||||
}
|
||||
|
||||
// Stat - get metadata from path.
|
||||
func (f *fsClient) Stat(isIncomplete, isFetchMeta, isPreserve bool, sse encrypt.ServerSide) (content *ClientContent, err *probe.Error) {
|
||||
func (f *fsClient) Stat(isIncomplete, isPreserve bool, sse encrypt.ServerSide) (content *ClientContent, err *probe.Error) {
|
||||
st, err := f.fsStat(isIncomplete)
|
||||
if err != nil {
|
||||
return nil, err.Trace(f.PathURL.String())
|
||||
@@ -1035,26 +1035,22 @@ func (f *fsClient) Stat(isIncomplete, isFetchMeta, isPreserve bool, sse encrypt.
|
||||
"Content-Type": guessURLContentType(f.PathURL.Path),
|
||||
}
|
||||
|
||||
// isFetchMeta is true only in the case of mc stat command which lists any extended attributes
|
||||
// present for this object.
|
||||
if isFetchMeta {
|
||||
path := f.PathURL.String()
|
||||
metaData, pErr := getAllXattrs(path)
|
||||
if pErr != nil {
|
||||
path := f.PathURL.String()
|
||||
metaData, pErr := getAllXattrs(path)
|
||||
if pErr != nil {
|
||||
return content, nil
|
||||
}
|
||||
for k, v := range metaData {
|
||||
content.Metadata[k] = v
|
||||
}
|
||||
// Populates meta data with file system attribute only in case of
|
||||
// when preserve flag is passed.
|
||||
if isPreserve {
|
||||
fileAttr, err := disk.GetFileSystemAttrs(path)
|
||||
if err != nil {
|
||||
return content, nil
|
||||
}
|
||||
for k, v := range metaData {
|
||||
content.Metadata[k] = v
|
||||
}
|
||||
// Populates meta data with file system attribute only in case of
|
||||
// when preserve flag is passed.
|
||||
if isPreserve {
|
||||
fileAttr, err := disk.GetFileSystemAttrs(path)
|
||||
if err != nil {
|
||||
return content, nil
|
||||
}
|
||||
content.Metadata["mc-attrs"] = fileAttr
|
||||
}
|
||||
content.Metadata["mc-attrs"] = fileAttr
|
||||
}
|
||||
|
||||
return content, nil
|
||||
|
||||
@@ -210,7 +210,7 @@ func (s *TestSuite) TestStatBucket(c *C) {
|
||||
c.Assert(err, IsNil)
|
||||
err = fsClient.MakeBucket("us-east-1", true, false)
|
||||
c.Assert(err, IsNil)
|
||||
_, err = fsClient.Stat(false, false, false, nil)
|
||||
_, err = fsClient.Stat(false, false, nil)
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
@@ -334,7 +334,7 @@ func (s *TestSuite) TestStatObject(c *C) {
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(n, Equals, int64(len(data)))
|
||||
|
||||
content, err := fsClient.Stat(false, false, false, nil)
|
||||
content, err := fsClient.Stat(false, false, nil)
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(content.Size, Equals, int64(dataLen))
|
||||
}
|
||||
|
||||
+60
-63
@@ -1300,11 +1300,43 @@ func (c *S3Client) listObjectWrapper(bucket, object string, isRecursive bool, do
|
||||
return c.api.ListObjectsV2(bucket, object, isRecursive, doneCh)
|
||||
}
|
||||
|
||||
// Stat - send a 'HEAD' on a bucket or object to fetch its metadata.
|
||||
func (c *S3Client) Stat(isIncomplete, isFetchMeta, isPreserve bool, sse encrypt.ServerSide) (*ClientContent, *probe.Error) {
|
||||
func (c *S3Client) statIncompleteUpload(bucket, object string) (*ClientContent, *probe.Error) {
|
||||
nonRecursive := false
|
||||
objectMetadata := &ClientContent{}
|
||||
// Prefix to pass to minio-go listing in order to fetch a given object/directory
|
||||
prefix := strings.TrimRight(object, string(c.targetURL.Separator))
|
||||
|
||||
for objectMultipartInfo := range c.api.ListIncompleteUploads(bucket, prefix, nonRecursive, nil) {
|
||||
if objectMultipartInfo.Err != nil {
|
||||
return nil, probe.NewError(objectMultipartInfo.Err)
|
||||
}
|
||||
|
||||
if objectMultipartInfo.Key == object {
|
||||
objectMetadata.URL = *c.targetURL
|
||||
objectMetadata.Time = objectMultipartInfo.Initiated
|
||||
objectMetadata.Size = objectMultipartInfo.Size
|
||||
objectMetadata.Type = os.FileMode(0664)
|
||||
objectMetadata.Metadata = map[string]string{}
|
||||
return objectMetadata, nil
|
||||
}
|
||||
|
||||
if strings.HasSuffix(objectMultipartInfo.Key, string(c.targetURL.Separator)) {
|
||||
objectMetadata.URL = *c.targetURL
|
||||
objectMetadata.Type = os.ModeDir
|
||||
objectMetadata.Metadata = map[string]string{}
|
||||
return objectMetadata, nil
|
||||
}
|
||||
}
|
||||
return nil, probe.NewError(ObjectMissing{})
|
||||
}
|
||||
|
||||
// Stat - send a 'HEAD' on a bucket or object to fetch its metadata. It also returns
|
||||
// a DIR type content if a prefix does exist in the server.
|
||||
func (c *S3Client) Stat(isIncomplete, isPreserve bool, sse encrypt.ServerSide) (*ClientContent, *probe.Error) {
|
||||
c.Lock()
|
||||
defer c.Unlock()
|
||||
bucket, object := c.url2BucketAndObject()
|
||||
|
||||
// Bucket name cannot be empty, stat on URL has no meaning.
|
||||
if bucket == "" {
|
||||
return nil, probe.NewError(BucketNameEmpty{})
|
||||
@@ -1318,6 +1350,11 @@ func (c *S3Client) Stat(isIncomplete, isFetchMeta, isPreserve bool, sse encrypt.
|
||||
return content, nil
|
||||
}
|
||||
|
||||
// If the request is for incomplete upload stat, handle it here.
|
||||
if isIncomplete {
|
||||
return c.statIncompleteUpload(bucket, object)
|
||||
}
|
||||
|
||||
// The following code tries to calculate if a given prefix/object does really exist
|
||||
// using minio-go listing API. The following inputs are supported:
|
||||
// - /path/to/existing/object
|
||||
@@ -1326,41 +1363,28 @@ func (c *S3Client) Stat(isIncomplete, isFetchMeta, isPreserve bool, sse encrypt.
|
||||
// - /path/to/empty_directory
|
||||
// - /path/to/empty_directory/
|
||||
|
||||
opts := minio.StatObjectOptions{}
|
||||
opts.ServerSideEncryption = sse
|
||||
|
||||
if !strings.HasSuffix(object, string(c.targetURL.Separator)) {
|
||||
// Issue HEAD request first but ignore no such key error
|
||||
// so we can check if there is such prefix which exists
|
||||
ctnt, err := c.getObjectStat(bucket, object, opts)
|
||||
if err == nil {
|
||||
return ctnt, err
|
||||
}
|
||||
// Ignore object missing error but return for other errors
|
||||
if !errors.As(err.ToGoError(), &ObjectMissing{}) {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
nonRecursive := false
|
||||
objectMetadata := &ClientContent{}
|
||||
|
||||
// Prefix to pass to minio-go listing in order to fetch a given object/directory
|
||||
// Prefix to pass to minio-go listing in order to fetch if a prefix exists
|
||||
prefix := strings.TrimRight(object, string(c.targetURL.Separator))
|
||||
|
||||
// If the request is for incomplete upload stat, handle it here.
|
||||
if isIncomplete {
|
||||
for objectMultipartInfo := range c.api.ListIncompleteUploads(bucket, prefix, nonRecursive, nil) {
|
||||
if objectMultipartInfo.Err != nil {
|
||||
return nil, probe.NewError(objectMultipartInfo.Err)
|
||||
}
|
||||
|
||||
if objectMultipartInfo.Key == object {
|
||||
objectMetadata.URL = *c.targetURL
|
||||
objectMetadata.Time = objectMultipartInfo.Initiated
|
||||
objectMetadata.Size = objectMultipartInfo.Size
|
||||
objectMetadata.Type = os.FileMode(0664)
|
||||
objectMetadata.Metadata = map[string]string{}
|
||||
return objectMetadata, nil
|
||||
}
|
||||
|
||||
if strings.HasSuffix(objectMultipartInfo.Key, string(c.targetURL.Separator)) {
|
||||
objectMetadata.URL = *c.targetURL
|
||||
objectMetadata.Type = os.ModeDir
|
||||
objectMetadata.Metadata = map[string]string{}
|
||||
return objectMetadata, nil
|
||||
}
|
||||
}
|
||||
return nil, probe.NewError(ObjectMissing{})
|
||||
}
|
||||
|
||||
opts := minio.StatObjectOptions{}
|
||||
opts.ServerSideEncryption = sse
|
||||
|
||||
for objectStat := range c.listObjectWrapper(bucket, prefix, nonRecursive, nil, false) {
|
||||
if objectStat.Err != nil {
|
||||
return nil, probe.NewError(objectStat.Err)
|
||||
@@ -1368,37 +1392,11 @@ func (c *S3Client) Stat(isIncomplete, isFetchMeta, isPreserve bool, sse encrypt.
|
||||
if strings.HasSuffix(objectStat.Key, string(c.targetURL.Separator)) {
|
||||
objectMetadata.URL = *c.targetURL
|
||||
objectMetadata.Type = os.ModeDir
|
||||
if isFetchMeta {
|
||||
stat, err := c.getObjectStat(bucket, object, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
objectMetadata.ETag = stat.ETag
|
||||
objectMetadata.Metadata = stat.Metadata
|
||||
objectMetadata.Expires = stat.Expires
|
||||
}
|
||||
return objectMetadata, nil
|
||||
} else if strings.Contains(objectStat.Key, object) {
|
||||
// Object name could be either full-name or a prefix
|
||||
objectMetadata.URL = *c.targetURL
|
||||
objectMetadata.Time = objectStat.LastModified
|
||||
objectMetadata.Size = objectStat.Size
|
||||
objectMetadata.ETag = objectStat.ETag
|
||||
objectMetadata.Type = os.FileMode(0664)
|
||||
objectMetadata.Metadata = map[string]string{}
|
||||
objectMetadata.Expires = objectStat.Expires
|
||||
if isFetchMeta {
|
||||
stat, err := c.getObjectStat(bucket, object, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
objectMetadata.Metadata = stat.Metadata
|
||||
objectMetadata.Expires = stat.Expires
|
||||
}
|
||||
return objectMetadata, nil
|
||||
}
|
||||
}
|
||||
return c.getObjectStat(bucket, object, opts)
|
||||
|
||||
return nil, probe.NewError(ObjectMissing{})
|
||||
}
|
||||
|
||||
// getObjectStat returns the metadata of an object from a HEAD call.
|
||||
@@ -1768,7 +1766,7 @@ func (c *S3Client) listIncompleteRecursiveInRoutineDirOpt(contentCh chan *Client
|
||||
} else if strings.HasSuffix(object, string(c.targetURL.Separator)) {
|
||||
// Get stat of given object is a directory.
|
||||
isIncomplete := true
|
||||
content, perr := c.Stat(isIncomplete, false, false, nil)
|
||||
content, perr := c.Stat(isIncomplete, false, nil)
|
||||
cContent = content
|
||||
if perr != nil {
|
||||
contentCh <- &ClientContent{Err: perr.Trace(bucket)}
|
||||
@@ -1914,8 +1912,7 @@ func (c *S3Client) listRecursiveInRoutineDirOpt(contentCh chan *ClientContent, d
|
||||
} else {
|
||||
// Get stat of given object is a directory.
|
||||
isIncomplete := false
|
||||
isFetchMeta := false
|
||||
content, perr := c.Stat(isIncomplete, isFetchMeta, false, nil)
|
||||
content, perr := c.Stat(isIncomplete, false, nil)
|
||||
cContent = content
|
||||
if perr != nil {
|
||||
contentCh <- &ClientContent{Err: perr.Trace(bucket)}
|
||||
|
||||
+2
-2
@@ -171,7 +171,7 @@ func urlJoinPath(url1, url2 string) string {
|
||||
}
|
||||
|
||||
// url2Stat returns stat info for URL.
|
||||
func url2Stat(urlStr string, isFetchMeta, fileAttr bool, encKeyDB map[string][]prefixSSEPair) (client Client, content *ClientContent, err *probe.Error) {
|
||||
func url2Stat(urlStr string, fileAttr bool, encKeyDB map[string][]prefixSSEPair) (client Client, content *ClientContent, err *probe.Error) {
|
||||
client, err = newClient(urlStr)
|
||||
if err != nil {
|
||||
return nil, nil, err.Trace(urlStr)
|
||||
@@ -179,7 +179,7 @@ func url2Stat(urlStr string, isFetchMeta, fileAttr bool, encKeyDB map[string][]p
|
||||
alias, _ := url2Alias(urlStr)
|
||||
sse := getSSE(urlStr, encKeyDB[alias])
|
||||
|
||||
content, err = client.Stat(false, isFetchMeta, fileAttr, sse)
|
||||
content, err = client.Stat(false, fileAttr, sse)
|
||||
if err != nil {
|
||||
return nil, nil, err.Trace(urlStr)
|
||||
}
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ const defaultMultipartThreadsNum = 4
|
||||
// Client - client interface
|
||||
type Client interface {
|
||||
// Common operations
|
||||
Stat(isIncomplete, isFetchMeta, isPreserve bool, sse encrypt.ServerSide) (content *ClientContent, err *probe.Error)
|
||||
Stat(isIncomplete, isPreserve bool, sse encrypt.ServerSide) (content *ClientContent, err *probe.Error)
|
||||
List(isRecursive, isIncomplete, isFetchMeta bool, showDir DirOpt) <-chan *ClientContent
|
||||
|
||||
// Bucket operations
|
||||
|
||||
@@ -107,7 +107,7 @@ func getEncKeys(ctx *cli.Context) (map[string][]prefixSSEPair, *probe.Error) {
|
||||
func isAliasURLDir(aliasURL string, keys map[string][]prefixSSEPair) bool {
|
||||
// If the target url exists, check if it is a directory
|
||||
// and return immediately.
|
||||
_, targetContent, err := url2Stat(aliasURL, false, false, keys)
|
||||
_, targetContent, err := url2Stat(aliasURL, false, keys)
|
||||
if err == nil {
|
||||
return targetContent.Type.IsDir()
|
||||
}
|
||||
@@ -174,7 +174,7 @@ func getSourceStream(alias string, urlStr string, fetchStat bool, sse encrypt.Se
|
||||
}
|
||||
metadata = make(map[string]string)
|
||||
if fetchStat {
|
||||
st, err := sourceClnt.Stat(false, true, false, sse)
|
||||
st, err := sourceClnt.Stat(false, false, sse)
|
||||
if err != nil {
|
||||
return nil, nil, err.Trace(alias, urlStr)
|
||||
}
|
||||
@@ -311,7 +311,7 @@ func getAllMetadata(sourceAlias, sourceURLStr string, srcSSE encrypt.ServerSide,
|
||||
if err != nil {
|
||||
return nil, err.Trace(sourceAlias, sourceURLStr)
|
||||
}
|
||||
st, err := sourceClnt.Stat(false, true, false, srcSSE)
|
||||
st, err := sourceClnt.Stat(false, false, srcSSE)
|
||||
if err != nil {
|
||||
return nil, err.Trace(sourceAlias, sourceURLStr)
|
||||
}
|
||||
@@ -478,7 +478,7 @@ func getFileAttrMeta(sURLs URLs, encKeyDB map[string][]prefixSSEPair) (string, *
|
||||
return "", err.Trace(sourceURL.String())
|
||||
}
|
||||
|
||||
sourceMeta, err := srcClt.Stat(false, true, true, srcSSE)
|
||||
sourceMeta, err := srcClt.Stat(false, true, srcSSE)
|
||||
if err != nil {
|
||||
return "", err.Trace(sourceURL.String())
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ func probeS3Signature(accessKey, secretKey, url string) (string, *probe.Error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if _, err := s3Client.Stat(false, false, false, nil); err != nil {
|
||||
if _, err := s3Client.Stat(false, false, nil); err != nil {
|
||||
e := err.ToGoError()
|
||||
if _, ok := e.(BucketDoesNotExist); ok {
|
||||
// Bucket doesn't exist, means signature probing worked successfully.
|
||||
|
||||
@@ -44,7 +44,7 @@ func checkCopySyntax(ctx *cli.Context, encKeyDB map[string][]prefixSSEPair, isMv
|
||||
|
||||
// Verify if source(s) exists.
|
||||
for _, srcURL := range srcURLs {
|
||||
_, _, err := url2Stat(srcURL, false, false, encKeyDB)
|
||||
_, _, err := url2Stat(srcURL, false, encKeyDB)
|
||||
if err != nil {
|
||||
console.Fatalf("Unable to validate source %s\n", srcURL)
|
||||
}
|
||||
@@ -103,7 +103,7 @@ func checkCopySyntaxTypeA(srcURLs []string, tgtURL string, keys map[string][]pre
|
||||
fatalIf(errInvalidArgument().Trace(), "Invalid number of source arguments.")
|
||||
}
|
||||
srcURL := srcURLs[0]
|
||||
_, srcContent, err := url2Stat(srcURL, false, false, keys)
|
||||
_, srcContent, err := url2Stat(srcURL, false, keys)
|
||||
fatalIf(err.Trace(srcURL), "Unable to stat source `"+srcURL+"`.")
|
||||
|
||||
if !srcContent.Type.IsRegular() {
|
||||
@@ -118,7 +118,7 @@ func checkCopySyntaxTypeB(srcURLs []string, tgtURL string, keys map[string][]pre
|
||||
fatalIf(errInvalidArgument().Trace(), "Invalid number of source arguments.")
|
||||
}
|
||||
srcURL := srcURLs[0]
|
||||
_, srcContent, err := url2Stat(srcURL, false, false, keys)
|
||||
_, srcContent, err := url2Stat(srcURL, false, keys)
|
||||
fatalIf(err.Trace(srcURL), "Unable to stat source `"+srcURL+"`.")
|
||||
|
||||
if !srcContent.Type.IsRegular() {
|
||||
@@ -126,7 +126,7 @@ func checkCopySyntaxTypeB(srcURLs []string, tgtURL string, keys map[string][]pre
|
||||
}
|
||||
|
||||
// Check target.
|
||||
if _, tgtContent, err := url2Stat(tgtURL, false, false, keys); err == nil {
|
||||
if _, tgtContent, err := url2Stat(tgtURL, false, keys); err == nil {
|
||||
if !tgtContent.Type.IsDir() {
|
||||
fatalIf(errInvalidArgument().Trace(tgtURL), "Target `"+tgtURL+"` is not a folder.")
|
||||
}
|
||||
@@ -141,14 +141,14 @@ func checkCopySyntaxTypeC(srcURLs []string, tgtURL string, isRecursive bool, key
|
||||
}
|
||||
|
||||
// Check target.
|
||||
if _, tgtContent, err := url2Stat(tgtURL, false, false, keys); err == nil {
|
||||
if _, tgtContent, err := url2Stat(tgtURL, false, keys); err == nil {
|
||||
if !tgtContent.Type.IsDir() {
|
||||
fatalIf(errInvalidArgument().Trace(tgtURL), "Target `"+tgtURL+"` is not a folder.")
|
||||
}
|
||||
}
|
||||
|
||||
for _, srcURL := range srcURLs {
|
||||
c, srcContent, err := url2Stat(srcURL, false, false, keys)
|
||||
c, srcContent, err := url2Stat(srcURL, false, keys)
|
||||
// incomplete uploads are not necessary for copy operation, no need to verify for them.
|
||||
isIncomplete := false
|
||||
if err != nil {
|
||||
@@ -186,7 +186,7 @@ func checkCopySyntaxTypeC(srcURLs []string, tgtURL string, isRecursive bool, key
|
||||
func checkCopySyntaxTypeD(srcURLs []string, tgtURL string, keys map[string][]prefixSSEPair, isMvCmd bool) {
|
||||
// Source can be anything: file, dir, dir...
|
||||
// Check target if it is a dir
|
||||
if _, tgtContent, err := url2Stat(tgtURL, false, false, keys); err == nil {
|
||||
if _, tgtContent, err := url2Stat(tgtURL, false, keys); err == nil {
|
||||
if !tgtContent.Type.IsDir() {
|
||||
fatalIf(errInvalidArgument().Trace(tgtURL), "Target `"+tgtURL+"` is not a folder.")
|
||||
}
|
||||
|
||||
+3
-3
@@ -53,7 +53,7 @@ const (
|
||||
func guessCopyURLType(sourceURLs []string, targetURL string, isRecursive bool, keys map[string][]prefixSSEPair) (copyURLsType, *probe.Error) {
|
||||
if len(sourceURLs) == 1 { // 1 Source, 1 Target
|
||||
sourceURL := sourceURLs[0]
|
||||
_, sourceContent, err := url2Stat(sourceURL, false, false, keys)
|
||||
_, sourceContent, err := url2Stat(sourceURL, false, keys)
|
||||
if err != nil {
|
||||
return copyURLsTypeInvalid, err
|
||||
}
|
||||
@@ -88,7 +88,7 @@ func prepareCopyURLsTypeA(sourceURL string, targetURL string, encKeyDB map[strin
|
||||
// Find alias and expanded clientURL.
|
||||
targetAlias, targetURL, _ := mustExpandAlias(targetURL)
|
||||
|
||||
_, sourceContent, err := url2Stat(sourceURL, false, false, encKeyDB)
|
||||
_, sourceContent, err := url2Stat(sourceURL, false, encKeyDB)
|
||||
if err != nil {
|
||||
// Source does not exist or insufficient privileges.
|
||||
return URLs{Error: err.Trace(sourceURL)}
|
||||
@@ -121,7 +121,7 @@ func prepareCopyURLsTypeB(sourceURL string, targetURL string, encKeyDB map[strin
|
||||
// Find alias and expanded clientURL.
|
||||
targetAlias, targetURL, _ := mustExpandAlias(targetURL)
|
||||
|
||||
_, sourceContent, err := url2Stat(sourceURL, false, false, encKeyDB)
|
||||
_, sourceContent, err := url2Stat(sourceURL, false, encKeyDB)
|
||||
if err != nil {
|
||||
// Source does not exist or insufficient privileges.
|
||||
return URLs{Error: err.Trace(sourceURL)}
|
||||
|
||||
+2
-2
@@ -123,7 +123,7 @@ func checkDiffSyntax(ctx *cli.Context, encKeyDB map[string][]prefixSSEPair) {
|
||||
// Diff only works between two directories, verify them below.
|
||||
|
||||
// Verify if firstURL is accessible.
|
||||
_, firstContent, err := url2Stat(firstURL, false, false, encKeyDB)
|
||||
_, firstContent, err := url2Stat(firstURL, false, encKeyDB)
|
||||
if err != nil {
|
||||
fatalIf(err.Trace(firstURL), fmt.Sprintf("Unable to stat '%s'.", firstURL))
|
||||
}
|
||||
@@ -134,7 +134,7 @@ func checkDiffSyntax(ctx *cli.Context, encKeyDB map[string][]prefixSSEPair) {
|
||||
}
|
||||
|
||||
// Verify if secondURL is accessible.
|
||||
_, secondContent, err := url2Stat(secondURL, false, false, encKeyDB)
|
||||
_, secondContent, err := url2Stat(secondURL, false, encKeyDB)
|
||||
if err != nil {
|
||||
fatalIf(err.Trace(secondURL), fmt.Sprintf("Unable to stat '%s'.", secondURL))
|
||||
}
|
||||
|
||||
+1
-1
@@ -170,7 +170,7 @@ func checkFindSyntax(ctx *cli.Context, encKeyDB map[string][]prefixSSEPair) {
|
||||
|
||||
// Extract input URLs and validate.
|
||||
for _, url := range args {
|
||||
_, _, err := url2Stat(url, false, false, encKeyDB)
|
||||
_, _, err := url2Stat(url, false, encKeyDB)
|
||||
if err != nil && !isURLPrefixExists(url, false) {
|
||||
// Bucket name empty is a valid error for 'find myminio' unless we are using watch, treat it as such.
|
||||
if _, ok := err.ToGoError().(BucketNameEmpty); ok && !ctx.Bool("watch") {
|
||||
|
||||
+1
-1
@@ -420,7 +420,7 @@ func getShareURL(path string) string {
|
||||
clnt, err := newClientFromAlias(targetAlias, targetURLFull)
|
||||
fatalIf(err.Trace(targetAlias, targetURLFull), "Unable to initialize client instance from alias.")
|
||||
|
||||
content, err := clnt.Stat(false, false, false, nil)
|
||||
content, err := clnt.Stat(false, false, nil)
|
||||
fatalIf(err.Trace(targetURLFull, targetAlias), "Unable to lookup file/object.")
|
||||
|
||||
// Skip if its a directory.
|
||||
|
||||
+2
-2
@@ -91,7 +91,7 @@ func checkListSyntax(ctx *cli.Context) {
|
||||
isIncomplete := ctx.Bool("incomplete")
|
||||
|
||||
for _, url := range URLs {
|
||||
_, _, err := url2Stat(url, false, false, nil)
|
||||
_, _, err := url2Stat(url, false, nil)
|
||||
if err != nil && !isURLPrefixExists(url, isIncomplete) {
|
||||
// Bucket name empty is a valid error for 'ls myminio',
|
||||
// treat it as such.
|
||||
@@ -133,7 +133,7 @@ func mainList(ctx *cli.Context) error {
|
||||
|
||||
if !strings.HasSuffix(targetURL, string(clnt.GetURL().Separator)) {
|
||||
var st *ClientContent
|
||||
st, err = clnt.Stat(isIncomplete, false, false, nil)
|
||||
st, err = clnt.Stat(isIncomplete, false, nil)
|
||||
if st != nil && err == nil && st.Type.IsDir() {
|
||||
targetURL = targetURL + string(clnt.GetURL().Separator)
|
||||
clnt, err = newClient(targetURL)
|
||||
|
||||
+2
-2
@@ -456,7 +456,7 @@ func (mj *mirrorJob) watchMirror(ctx context.Context, cancelMirror context.Cance
|
||||
}
|
||||
shouldQueue := false
|
||||
if !mj.isOverwrite {
|
||||
_, err = targetClient.Stat(false, false, false, tgtSSE)
|
||||
_, err = targetClient.Stat(false, false, tgtSSE)
|
||||
if err == nil {
|
||||
continue
|
||||
} // doesn't exist
|
||||
@@ -482,7 +482,7 @@ func (mj *mirrorJob) watchMirror(ctx context.Context, cancelMirror context.Cance
|
||||
mj.statusCh <- mirrorURL.WithError(err)
|
||||
return
|
||||
}
|
||||
_, err = targetClient.Stat(false, false, false, tgtSSE)
|
||||
_, err = targetClient.Stat(false, false, tgtSSE)
|
||||
if err == nil {
|
||||
if mirrorURL.SourceContent.Retention {
|
||||
shouldQueue = true
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ func checkMirrorSyntax(ctx *cli.Context, encKeyDB map[string][]prefixSSEPair) {
|
||||
|
||||
/****** Generic rules *******/
|
||||
if !ctx.Bool("watch") {
|
||||
_, srcContent, err := url2Stat(srcURL, false, false, encKeyDB)
|
||||
_, srcContent, err := url2Stat(srcURL, false, encKeyDB)
|
||||
// incomplete uploads are not necessary for copy operation, no need to verify for them.
|
||||
isIncomplete := false
|
||||
if err != nil && !isURLPrefixExists(srcURL, isIncomplete) {
|
||||
|
||||
+1
-1
@@ -215,7 +215,7 @@ func mainRemoveBucket(ctx *cli.Context) error {
|
||||
cErr = exitStatus(globalErrorExitStatus)
|
||||
continue
|
||||
}
|
||||
_, err = clnt.Stat(false, false, false, nil)
|
||||
_, err = clnt.Stat(false, false, nil)
|
||||
if err != nil {
|
||||
switch err.ToGoError().(type) {
|
||||
case BucketNameEmpty:
|
||||
|
||||
@@ -93,7 +93,7 @@ func checkShareDownloadSyntax(ctx *cli.Context, encKeyDB map[string][]prefixSSEP
|
||||
isRecursive := ctx.Bool("recursive")
|
||||
if !isRecursive {
|
||||
for _, url := range ctx.Args() {
|
||||
_, _, err := url2Stat(url, false, false, encKeyDB)
|
||||
_, _, err := url2Stat(url, false, encKeyDB)
|
||||
if err != nil {
|
||||
fatalIf(err.Trace(url), "Unable to stat `"+url+"`.")
|
||||
}
|
||||
@@ -122,11 +122,10 @@ func doShareDownloadURL(targetURL string, isRecursive bool, expiry time.Duration
|
||||
|
||||
// Generate share URL for each target.
|
||||
isIncomplete := false
|
||||
isFetchMeta := false
|
||||
// Channel which will receive objects whose URLs need to be shared
|
||||
objectsCh := make(chan *ClientContent)
|
||||
|
||||
content, err := clnt.Stat(isIncomplete, isFetchMeta, false, nil)
|
||||
content, err := clnt.Stat(isIncomplete, false, nil)
|
||||
if err != nil {
|
||||
return err.Trace(clnt.GetURL().String())
|
||||
}
|
||||
|
||||
+1
-1
@@ -89,7 +89,7 @@ func checkStatSyntax(ctx *cli.Context, encKeyDB map[string][]prefixSSEPair) {
|
||||
isIncomplete := false
|
||||
|
||||
for _, url := range URLs {
|
||||
_, _, err := url2Stat(url, false, false, encKeyDB)
|
||||
_, _, err := url2Stat(url, false, encKeyDB)
|
||||
if err != nil && !isURLPrefixExists(url, isIncomplete) {
|
||||
fatalIf(err.Trace(url), "Unable to stat `"+url+"`.")
|
||||
}
|
||||
|
||||
+1
-1
@@ -176,7 +176,7 @@ func statURL(targetURL string, isIncomplete, isRecursive bool, encKeyDB map[stri
|
||||
return nil, errTargetNotFound(targetURL).Trace(url, standardizedURL)
|
||||
}
|
||||
|
||||
_, stat, err := url2Stat(url, true, true, encKeyDB)
|
||||
_, stat, err := url2Stat(url, true, encKeyDB)
|
||||
if err != nil {
|
||||
stat = content
|
||||
}
|
||||
|
||||
+1
-1
@@ -119,7 +119,7 @@ func checkTreeSyntax(ctx *cli.Context) {
|
||||
}
|
||||
|
||||
for _, url := range args {
|
||||
if _, _, err := url2Stat(url, false, false, nil); err != nil && !isURLPrefixExists(url, false) {
|
||||
if _, _, err := url2Stat(url, false, nil); err != nil && !isURLPrefixExists(url, false) {
|
||||
fatalIf(err.Trace(url), "Unable to tree `"+url+"`.")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user