swift, s3, googlecloudstorage: Don't delete the container/bucket if fs wasn't at root - fixes #172

This commit is contained in:
Nick Craig-Wood 2015-11-07 15:31:04 +00:00
parent 5df04cb763
commit a795d93bc3
3 changed files with 12 additions and 3 deletions

View file

@ -407,11 +407,14 @@ func (f *Fs) Mkdir() error {
return err return err
} }
// Rmdir deletes the bucket // Rmdir deletes the bucket if the fs is at the root
// //
// Returns an error if it isn't empty: Error 409: The bucket you tried // Returns an error if it isn't empty: Error 409: The bucket you tried
// to delete was not empty. // to delete was not empty.
func (f *Fs) Rmdir() error { func (f *Fs) Rmdir() error {
if f.root != "" {
return nil
}
return f.svc.Buckets.Delete(f.bucket).Do() return f.svc.Buckets.Delete(f.bucket).Do()
} }

View file

@ -487,10 +487,13 @@ func (f *Fs) Mkdir() error {
return err return err
} }
// Rmdir deletes the bucket // Rmdir deletes the bucket if the fs is at the root
// //
// Returns an error if it isn't empty // Returns an error if it isn't empty
func (f *Fs) Rmdir() error { func (f *Fs) Rmdir() error {
if f.root != "" {
return nil
}
req := s3.DeleteBucketInput{ req := s3.DeleteBucketInput{
Bucket: &f.bucket, Bucket: &f.bucket,
} }

View file

@ -371,10 +371,13 @@ func (f *Fs) Mkdir() error {
return f.c.ContainerCreate(f.container, nil) return f.c.ContainerCreate(f.container, nil)
} }
// Rmdir deletes the container // Rmdir deletes the container if the fs is at the root
// //
// Returns an error if it isn't empty // Returns an error if it isn't empty
func (f *Fs) Rmdir() error { func (f *Fs) Rmdir() error {
if f.root != "" {
return nil
}
return f.c.ContainerDelete(f.container) return f.c.ContainerDelete(f.container)
} }