Skip to content

Commit

Permalink
Fixed the build, broken by jacobsa/gcloud@8d2a8fb.
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobsa committed Jun 26, 2015
1 parent a91acaf commit 67f8851
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 21 deletions.
10 changes: 8 additions & 2 deletions fs/caching_test.go
Expand Up @@ -171,7 +171,10 @@ func (t *CachingTest) DirectoryRemovedRemotely() {
AssertEq(nil, err)

// Remove the backing object in GCS.
err = t.uncachedBucket.DeleteObject(t.ctx, name+"/")
err = t.uncachedBucket.DeleteObject(
t.ctx,
&gcs.DeleteObjectRequest{Name: name + "/"})

AssertEq(nil, err)

// Because we are caching, the directory should still appear to exist.
Expand Down Expand Up @@ -259,7 +262,10 @@ func (t *CachingTest) TypeOfNameChanges_RemoteModifier() {

// Remove the backing object in GCS, updating the bucket cache (but not the
// file system type cache)
err = t.bucket.DeleteObject(t.ctx, name+"/")
err = t.bucket.DeleteObject(
t.ctx,
&gcs.DeleteObjectRequest{Name: name + "/"})

AssertEq(nil, err)

// Create a file with the same name via GCS, again updating the bucket cache.
Expand Down
12 changes: 10 additions & 2 deletions fs/foreign_modifications_test.go
Expand Up @@ -685,7 +685,11 @@ func (t *ForeignModsTest) ObjectIsDeleted_File() {
AssertEq(nil, err)

// Delete the object.
AssertEq(nil, t.bucket.DeleteObject(t.ctx, "foo"))
AssertEq(
nil,
t.bucket.DeleteObject(
t.ctx,
&gcs.DeleteObjectRequest{Name: "foo"}))

// The file should appear to be unlinked, but with the previous contents.
fi, err := f1.Stat()
Expand Down Expand Up @@ -717,7 +721,11 @@ func (t *ForeignModsTest) ObjectIsDeleted_Directory() {
AssertEq(nil, err)

// Delete the object.
AssertEq(nil, t.bucket.DeleteObject(t.ctx, "dir/"))
AssertEq(
nil,
t.bucket.DeleteObject(
t.ctx,
&gcs.DeleteObjectRequest{Name: "dir/"}))

// The inode should still be fstat'able.
fi, err := t.f1.Stat()
Expand Down
7 changes: 6 additions & 1 deletion fs/garbage_collect.go
Expand Up @@ -72,7 +72,12 @@ func garbageCollectOnce(
// Delete those objects.
b.Add(func(ctx context.Context) (err error) {
for name := range staleNames {
err = bucket.DeleteObject(ctx, name)
err = bucket.DeleteObject(
ctx,
&gcs.DeleteObjectRequest{
Name: name,
})

if err != nil {
err = fmt.Errorf("DeleteObject(%q): %v", name, err)
return
Expand Down
7 changes: 6 additions & 1 deletion fs/implicit_dirs_test.go
Expand Up @@ -24,6 +24,7 @@ import (
"syscall"

"github.com/jacobsa/fuse/fusetesting"
"github.com/jacobsa/gcloud/gcs"
. "github.com/jacobsa/oglematchers"
. "github.com/jacobsa/ogletest"
)
Expand Down Expand Up @@ -439,7 +440,11 @@ func (t *ImplicitDirsTest) ExplicitBecomesImplicit() {
ExpectTrue(fi.IsDir())

// Remove the explicit placeholder.
AssertEq(nil, t.bucket.DeleteObject(t.ctx, "foo/"))
AssertEq(
nil,
t.bucket.DeleteObject(
t.ctx,
&gcs.DeleteObjectRequest{Name: "foo/"}))

// Stat the directory again.
fi, err = os.Stat(path.Join(t.mfs.Dir(), "foo"))
Expand Down
14 changes: 12 additions & 2 deletions fs/inode/dir.go
Expand Up @@ -785,7 +785,12 @@ func (d *dirInode) DeleteChildFile(
name string) (err error) {
d.cache.Erase(name)

err = d.bucket.DeleteObject(ctx, path.Join(d.Name(), name))
err = d.bucket.DeleteObject(
ctx,
&gcs.DeleteObjectRequest{
Name: path.Join(d.Name(), name),
})

if err != nil {
err = fmt.Errorf("DeleteObject: %v", err)
return
Expand All @@ -802,7 +807,12 @@ func (d *dirInode) DeleteChildDir(

// Delete the backing object. Unfortunately we have no way to precondition
// this on the directory being empty.
err = d.bucket.DeleteObject(ctx, path.Join(d.Name(), name)+"/")
err = d.bucket.DeleteObject(
ctx,
&gcs.DeleteObjectRequest{
Name: path.Join(d.Name(), name) + "/",
})

if err != nil {
err = fmt.Errorf("DeleteObject: %v", err)
return
Expand Down
7 changes: 6 additions & 1 deletion fs/local_modifications_test.go
Expand Up @@ -1609,7 +1609,12 @@ func (t *FileTest) UnlinkFile_NoLongerInBucket() {
AssertEq(nil, err)

// Delete it from the bucket through the back door.
err = t.bucket.DeleteObject(t.ctx, "foo")
AssertEq(
nil,
t.bucket.DeleteObject(
t.ctx,
&gcs.DeleteObjectRequest{Name: "foo"}))

AssertEq(nil, err)

// Attempt to unlink it.
Expand Down
7 changes: 6 additions & 1 deletion gcsproxy/append_object_creator.go
Expand Up @@ -114,7 +114,12 @@ func (oc *appendObjectCreator) Create(

// Attempt to delete the temporary object when we're done.
defer func() {
deleteErr := oc.bucket.DeleteObject(ctx, tmp.Name)
deleteErr := oc.bucket.DeleteObject(
ctx,
&gcs.DeleteObjectRequest{
Name: tmp.Name,
})

if err == nil && deleteErr != nil {
err = fmt.Errorf("DeleteObject: %v", deleteErr)
}
Expand Down
36 changes: 31 additions & 5 deletions gcsproxy/append_object_creator_test.go
Expand Up @@ -16,6 +16,7 @@ package gcsproxy

import (
"errors"
"fmt"
"io/ioutil"
"strings"
"testing"
Expand All @@ -30,6 +31,31 @@ import (

func TestAppendObjectCreator(t *testing.T) { RunTests(t) }

////////////////////////////////////////////////////////////////////////
// Helpers
////////////////////////////////////////////////////////////////////////

func deleteReqName(expected string) (m Matcher) {
m = NewMatcher(
func(c interface{}) (err error) {
req, ok := c.(*gcs.DeleteObjectRequest)
if !ok {
err = fmt.Errorf("which has type %T", c)
return
}

if req.Name != expected {
err = fmt.Errorf("which is for name %q", req.Name)
return
}

return
},
fmt.Sprintf("Delete request for name %q", expected))

return
}

////////////////////////////////////////////////////////////////////////
// Boilerplate
////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -140,7 +166,7 @@ func (t *AppendObjectCreatorTest) CallsComposeObjects() {
WillOnce(DoAll(SaveArg(1, &req), Return(nil, errors.New(""))))

// DeleteObject
ExpectCall(t.bucket, "DeleteObject")(Any(), tmpObject.Name).
ExpectCall(t.bucket, "DeleteObject")(Any(), deleteReqName(tmpObject.Name)).
WillOnce(Return(nil))

// Call
Expand Down Expand Up @@ -178,7 +204,7 @@ func (t *AppendObjectCreatorTest) ComposeObjectsFails() {
WillOnce(Return(nil, errors.New("taco")))

// DeleteObject
ExpectCall(t.bucket, "DeleteObject")(Any(), tmpObject.Name).
ExpectCall(t.bucket, "DeleteObject")(Any(), deleteReqName(tmpObject.Name)).
WillOnce(Return(errors.New("")))

// Call
Expand All @@ -202,7 +228,7 @@ func (t *AppendObjectCreatorTest) ComposeObjectsReturnsPreconditionError() {
WillOnce(Return(nil, &gcs.PreconditionError{Err: errors.New("taco")}))

// DeleteObject
ExpectCall(t.bucket, "DeleteObject")(Any(), tmpObject.Name).
ExpectCall(t.bucket, "DeleteObject")(Any(), deleteReqName(tmpObject.Name)).
WillOnce(Return(errors.New("")))

// Call
Expand All @@ -227,7 +253,7 @@ func (t *AppendObjectCreatorTest) ComposeObjectsReturnsNotFoundError() {
WillOnce(Return(nil, &gcs.NotFoundError{Err: errors.New("taco")}))

// DeleteObject
ExpectCall(t.bucket, "DeleteObject")(Any(), tmpObject.Name).
ExpectCall(t.bucket, "DeleteObject")(Any(), deleteReqName(tmpObject.Name)).
WillOnce(Return(errors.New("")))

// Call
Expand All @@ -254,7 +280,7 @@ func (t *AppendObjectCreatorTest) CallsDeleteObject() {
WillOnce(Return(composed, nil))

// DeleteObject
ExpectCall(t.bucket, "DeleteObject")(Any(), tmpObject.Name).
ExpectCall(t.bucket, "DeleteObject")(Any(), deleteReqName(tmpObject.Name)).
WillOnce(Return(errors.New("")))

// Call
Expand Down
8 changes: 4 additions & 4 deletions gcsproxy/integration_test.go
Expand Up @@ -374,7 +374,7 @@ func (t *IntegrationTest) WithinLeaserLimit() {
ExpectEq(fileLeaserLimitBytes, len(contents))

// Delete the backing object.
err = t.bucket.DeleteObject(t.ctx, o.Name)
err = t.bucket.DeleteObject(t.ctx, &gcs.DeleteObjectRequest{Name: o.Name})
AssertEq(nil, err)

// We should still be able to read the contents, because the read lease
Expand Down Expand Up @@ -409,7 +409,7 @@ func (t *IntegrationTest) LargerThanLeaserLimit() {
ExpectEq(fileLeaserLimitBytes+1, len(contents))

// Delete the backing object.
err = t.bucket.DeleteObject(t.ctx, o.Name)
err = t.bucket.DeleteObject(t.ctx, &gcs.DeleteObjectRequest{Name: o.Name})
AssertEq(nil, err)

// The contents should be lost, because the leaser should have revoked the
Expand All @@ -423,7 +423,7 @@ func (t *IntegrationTest) BackingObjectHasBeenDeleted_BeforeReading() {
o, err := gcsutil.CreateObject(t.ctx, t.bucket, "foo", "taco")
AssertEq(nil, err)

err = t.bucket.DeleteObject(t.ctx, o.Name)
err = t.bucket.DeleteObject(t.ctx, &gcs.DeleteObjectRequest{Name: o.Name})
AssertEq(nil, err)

// Create a mutable object around it.
Expand Down Expand Up @@ -459,7 +459,7 @@ func (t *IntegrationTest) BackingObjectHasBeenDeleted_AfterReading() {
AssertEq(nil, err)

// Delete the backing object.
err = t.bucket.DeleteObject(t.ctx, o.Name)
err = t.bucket.DeleteObject(t.ctx, &gcs.DeleteObjectRequest{Name: o.Name})
AssertEq(nil, err)

// Reading and modications should still work.
Expand Down
4 changes: 2 additions & 2 deletions ratelimit/throttled_bucket.go
Expand Up @@ -167,15 +167,15 @@ func (b *throttledBucket) UpdateObject(

func (b *throttledBucket) DeleteObject(
ctx context.Context,
name string) (err error) {
req *gcs.DeleteObjectRequest) (err error) {
// Wait for permission to call through.
err = b.opThrottle.Wait(ctx, 1)
if err != nil {
return
}

// Call through.
err = b.wrapped.DeleteObject(ctx, name)
err = b.wrapped.DeleteObject(ctx, req)

return
}
Expand Down

0 comments on commit 67f8851

Please sign in to comment.