Merge pull request #673 from AgNO3/s3-removal

S3 backend: include path prefix in removal requests.
This commit is contained in:
Andrey Smirnov
2017-11-19 19:24:04 +03:00
committed by GitHub
2 changed files with 9 additions and 2 deletions
+2 -2
View File
@@ -183,12 +183,12 @@ func (storage *PublishedStorage) putFile(path string, source io.ReadSeeker) erro
func (storage *PublishedStorage) Remove(path string) error {
params := &s3.DeleteObjectInput{
Bucket: aws.String(storage.bucket),
Key: aws.String(path),
Key: aws.String(filepath.Join(storage.prefix,path)),
}
_, err := storage.s3.DeleteObject(params)
if err != nil {
return errors.Wrap(err, fmt.Sprintf("error deleting %s from %s", path, storage))
}
}
if storage.plusWorkaround && strings.Contains(path, "+") {
// try to remove workaround version, but don't care about result
+7
View File
@@ -160,6 +160,13 @@ func (s *PublishedStorageSuite) TestRemove(c *C) {
c.Check(err, IsNil)
s.AssertNoFile(c, "a/b")
s.PutFile(c, "lala/xyz", []byte("test"))
errp := s.prefixedStorage.Remove("xyz")
c.Check(errp, IsNil)
s.AssertNoFile(c, "lala/xyz")
}
func (s *PublishedStorageSuite) TestRemovePlusWorkaround(c *C) {