diff options
| -rw-r--r-- | account.go | 4 | ||||
| -rw-r--r-- | bulk.go | 6 | ||||
| -rw-r--r-- | container.go | 4 |
3 files changed, 10 insertions, 4 deletions
@@ -36,6 +36,10 @@ type Account struct { caps *Capabilities } +func (a *Account) isEqualTo(other *Account) bool { + return other.baseURL == a.baseURL && other.name == a.name +} + var endpointURLRegexp = regexp.MustCompile(`^(.*/)v1/(.*)/$`) //InitializeAccount takes something that implements the Backend interface, and @@ -145,14 +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 { - other := obj.Container().Account() - if other.baseURL != a.baseURL || other.name != a.name { + if !a.isEqualTo(obj.Container().Account()) { return 0, 0, ErrAccountMismatch } } for _, container := range containers { - other := container.Account() - if other.baseURL != a.baseURL || other.name != a.name { + if !a.isEqualTo(container.Account()) { return 0, 0, ErrAccountMismatch } } diff --git a/container.go b/container.go index 1d310aa..80aeca3 100644 --- a/container.go +++ b/container.go @@ -30,6 +30,10 @@ type Container struct { headers *ContainerHeaders } +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 //account. This function does not issue any HTTP requests, and therefore cannot //ensure that the container exists. Use the Exists() function to check for the |
