Skip to content

Commit

Permalink
Remove .md5 files on deletion
Browse files Browse the repository at this point in the history
/.md5/<path>.md5 files created by s3gof3r are now deleted on file
deletion, if they exist.
Fixes #38
  • Loading branch information
rlmcpherson committed Oct 21, 2014
1 parent c06d9b2 commit 7ca1367
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions s3gof3r.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,21 @@ func (b *Bucket) conf() *Config {
}

// Delete deletes the key at path
// If the path does not exist, Delete returns nil (no error).
func (b *Bucket) Delete(path string) error {
if err := b.delete(path); err != nil {
return err
}
// try to delete md5 file
if err := b.delete(fmt.Sprintf("/.md5/%s.md5", path)); err != nil {
return err
}

logger.Printf("%s deleted from %s\n", path, b.Name)
return nil
}

func (b *Bucket) delete(path string) error {
u, err := b.url(path, b.conf())
if err != nil {
return err
Expand All @@ -159,8 +173,6 @@ func (b *Bucket) Delete(path string) error {
if resp.StatusCode != 204 {
return newRespError(resp)
}
logger.Printf("%s deleted\n", u.String())

return nil
}

Expand Down

0 comments on commit 7ca1367

Please sign in to comment.