From b72fc69fbedac4c532a624eb26b890f13c3a3c9c Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 14 Jul 2014 10:45:28 +0100 Subject: [PATCH] google cloud storage: Make operations on single files work --- googlecloudstorage/googlecloudstorage.go | 28 ++++++++++++------------ 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/googlecloudstorage/googlecloudstorage.go b/googlecloudstorage/googlecloudstorage.go index ec259b015..d722c84f1 100644 --- a/googlecloudstorage/googlecloudstorage.go +++ b/googlecloudstorage/googlecloudstorage.go @@ -15,6 +15,7 @@ import ( "fmt" "io" "net/http" + "path" "regexp" "strings" "time" @@ -139,20 +140,19 @@ func NewFs(name, root string) (fs.Fs, error) { if f.root != "" { f.root += "/" // Check to see if the object exists - // FIXME - // _, _, err = f.svc.Object(bucket, directory) - // if err == nil { - // remote := path.Base(directory) - // f.root = path.Dir(directory) - // if f.root == "." { - // f.root = "" - // } else { - // f.root += "/" - // } - // obj := f.NewFsObject(remote) - // // return a Fs Limited to this object - // return fs.NewLimited(f, obj), nil - // } + _, err = f.svc.Objects.Get(bucket, directory).Do() + if err == nil { + remote := path.Base(directory) + f.root = path.Dir(directory) + if f.root == "." { + f.root = "" + } else { + f.root += "/" + } + obj := f.NewFsObject(remote) + // return a Fs Limited to this object + return fs.NewLimited(f, obj), nil + } } return f, nil }