diff options
| -rw-r--r-- | account.go | 3 | ||||
| -rw-r--r-- | bulk.go | 4 | ||||
| -rw-r--r-- | container.go | 5 | ||||
| -rw-r--r-- | largeobject.go | 8 | ||||
| -rw-r--r-- | object.go | 7 |
5 files changed, 17 insertions, 10 deletions
@@ -38,7 +38,8 @@ type Account struct { caps *Capabilities } -func (a *Account) isEqualTo(other *Account) bool { +//IsEqualTo returns true if both Account instances refer to the same account. +func (a *Account) IsEqualTo(other *Account) bool { return other.baseURL == a.baseURL && other.name == a.name } @@ -145,12 +145,12 @@ func makeBulkObjectError(fullName string, statusCode int) BulkObjectError { func (a *Account) BulkDelete(objects []*Object, containers []*Container, opts *RequestOptions) (numDeleted int, numNotFound int, deleteError error) { //validate that all given objects are in this account for _, obj := range objects { - if !a.isEqualTo(obj.Container().Account()) { + if !a.IsEqualTo(obj.Container().Account()) { return 0, 0, ErrAccountMismatch } } for _, container := range containers { - if !a.isEqualTo(container.Account()) { + if !a.IsEqualTo(container.Account()) { return 0, 0, ErrAccountMismatch } } diff --git a/container.go b/container.go index 6982efe..147400d 100644 --- a/container.go +++ b/container.go @@ -32,8 +32,9 @@ type Container struct { headers *ContainerHeaders } -func (c *Container) isEqualTo(other *Container) bool { - return other.name == c.name && other.a.isEqualTo(c.a) +//IsEqualTo returns true if both Container instances refer to the same container. +func (c *Container) IsEqualTo(other *Container) bool { + return other.name == c.name && other.a.IsEqualTo(c.a) } //Container returns a handle to the container with the given name within this diff --git a/largeobject.go b/largeobject.go index 6628279..0d22734 100644 --- a/largeobject.go +++ b/largeobject.go @@ -435,7 +435,7 @@ func (o *Object) AsNewLargeObject(sopts SegmentingOptions, topts *TruncateOption if sopts.SegmentContainer == nil { panic("missing value for sopts.SegmentingContainer") } - if !sopts.SegmentContainer.a.isEqualTo(o.c.a) { + if !sopts.SegmentContainer.a.IsEqualTo(o.c.a) { return nil, ErrAccountMismatch } @@ -520,7 +520,7 @@ func (lo *LargeObject) NextSegmentObject() *Object { if o == nil { //can happen for data segments continue } - if lo.segmentContainer.isEqualTo(o.c) && strings.HasPrefix(o.Name(), lo.segmentPrefix) { + if lo.segmentContainer.IsEqualTo(o.c) && strings.HasPrefix(o.Name(), lo.segmentPrefix) { prevSegmentName = s.Object.Name() //keep going, we want to find the last such segment } @@ -596,7 +596,7 @@ func (lo *LargeObject) AddSegment(segment SegmentInfo) error { //required attributes return ErrSegmentInvalid } - if !o.c.a.isEqualTo(lo.segmentContainer.a) { + if !o.c.a.IsEqualTo(lo.segmentContainer.a) { return ErrAccountMismatch } @@ -607,7 +607,7 @@ func (lo *LargeObject) AddSegment(segment SegmentInfo) error { return ErrSegmentInvalid } - if !o.c.isEqualTo(lo.segmentContainer) { + if !o.c.IsEqualTo(lo.segmentContainer) { return ErrContainerMismatch } if !strings.HasPrefix(o.name, lo.segmentPrefix) { @@ -41,6 +41,11 @@ type Object struct { symlinkHeaders *ObjectHeaders //from HEAD/GET with ?symlink=get } +//IsEqualTo returns true if both Object instances refer to the same object. +func (o *Object) IsEqualTo(other *Object) bool { + return other.name == o.name && other.c.IsEqualTo(o.c) +} + //Object returns a handle to the object with the given name within this //container. This function does not issue any HTTP requests, and therefore cannot //ensure that the object exists. Use the Exists() function to check for the @@ -507,7 +512,7 @@ type SymlinkOptions struct { func (o *Object) SymlinkTo(target *Object, opts *SymlinkOptions, ropts *RequestOptions) error { ropts = cloneRequestOptions(ropts, nil) ropts.Headers.Set("X-Symlink-Target", target.FullName()) - if !target.c.a.isEqualTo(o.c.a) { + if !target.c.a.IsEqualTo(o.c.a) { ropts.Headers.Set("X-Symlink-Target-Account", target.c.a.Name()) } if ropts.Headers.Get("Content-Type") == "" { |
