Files
mc/cmd/urls.go
T
Harshavardhana 38aec4d875 mirror and cp should print size in --json mode. (#1890)
```sh
mc cp -r --json /usr/bin /tmp | jq .
...
...
{
  "status": "success",
  "source": "/usr/bin/gcm-viewer",
  "target": "/tmp/bin/gcm-viewer",
  "size": 87128,
  "totalCount": 2602,
  "totalSize": 677422730
}
```

This allows scripts to build progress around this data.
2016-11-20 14:46:24 -08:00

73 lines
2.0 KiB
Go

/*
* Minio Client (C) 2015 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cmd
import "github.com/minio/minio/pkg/probe"
// URLs contains source and target urls
type URLs struct {
SourceAlias string
SourceContent *clientContent
TargetAlias string
TargetContent *clientContent
TotalCount int64
TotalSize int64
Error *probe.Error `json:"-"`
}
// WithError sets the error and returns object
func (m URLs) WithError(err *probe.Error) URLs {
m.Error = err
return m
}
// Equal tests if both urls are equal
func (m URLs) Equal(n URLs) bool {
if m.SourceContent == nil && n.SourceContent == nil {
} else if m.SourceContent != nil && n.SourceContent == nil {
return false
} else if m.SourceContent == nil && n.SourceContent != nil {
return false
} else if m.SourceContent.URL != n.SourceContent.URL {
return false
}
if m.TargetContent == nil && n.TargetContent == nil {
} else if m.TargetContent != nil && n.TargetContent == nil {
return false
} else if m.TargetContent == nil && n.TargetContent != nil {
return false
} else if m.TargetContent.URL != n.TargetContent.URL {
return false
}
return true
}
func (m URLs) isEmpty() bool {
if m.SourceContent == nil && m.TargetContent == nil && m.Error == nil {
return true
}
// If remove flag is set then sourceContent is usually nil.
if m.SourceContent != nil {
if m.SourceContent.Size == 0 && m.TargetContent == nil && m.Error == nil {
return true
}
}
return false
}