mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-05 22:08:27 +00:00
Fix S3 path caching double-prefix
Original PR: #621 Fixes: #619 I've added unit-test to Martyn's PR. Without this fix, if `prefix` is set on S3 publish endpoint, aptly would incorrectly build path cache and re-upload every object on publish.
This commit is contained in:
1
AUTHORS
1
AUTHORS
@@ -28,3 +28,4 @@ List of contributors, in chronological order:
|
|||||||
* Charles Hsu (https://github.com/charz)
|
* Charles Hsu (https://github.com/charz)
|
||||||
* Clemens Rabe (https://github.com/seeraven)
|
* Clemens Rabe (https://github.com/seeraven)
|
||||||
* TJ Merritt (https://github.com/tjmerritt)
|
* TJ Merritt (https://github.com/tjmerritt)
|
||||||
|
* Matt Martyn (https://github.com/MMartyn)
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ func (storage *PublishedStorage) LinkFromPool(publishedDirectory, baseName strin
|
|||||||
poolPath := filepath.Join(storage.prefix, relPath)
|
poolPath := filepath.Join(storage.prefix, relPath)
|
||||||
|
|
||||||
if storage.pathCache == nil {
|
if storage.pathCache == nil {
|
||||||
paths, md5s, err := storage.internalFilelist(storage.prefix, true)
|
paths, md5s, err := storage.internalFilelist("", true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "error caching paths under prefix")
|
return errors.Wrap(err, "error caching paths under prefix")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,4 +257,19 @@ func (s *PublishedStorageSuite) TestLinkFromPool(c *C) {
|
|||||||
c.Check(err, IsNil)
|
c.Check(err, IsNil)
|
||||||
|
|
||||||
c.Check(s.GetFile(c, "pool/main/m/mars-invaders/mars-invaders_1.03.deb"), DeepEquals, []byte("Spam"))
|
c.Check(s.GetFile(c, "pool/main/m/mars-invaders/mars-invaders_1.03.deb"), DeepEquals, []byte("Spam"))
|
||||||
|
|
||||||
|
// for prefixed storage:
|
||||||
|
// first link from pool
|
||||||
|
err = s.prefixedStorage.LinkFromPool(filepath.Join("", "pool", "main", "m/mars-invaders"), "mars-invaders_1.03.deb", pool, src1, cksum1, false)
|
||||||
|
c.Check(err, IsNil)
|
||||||
|
|
||||||
|
// 2nd link from pool, providing wrong path for source file
|
||||||
|
//
|
||||||
|
// this test should check that file already exists in S3 and skip upload (which would fail if not skipped)
|
||||||
|
s.prefixedStorage.pathCache = nil
|
||||||
|
err = s.prefixedStorage.LinkFromPool(filepath.Join("", "pool", "main", "m/mars-invaders"), "mars-invaders_1.03.deb", pool, "wrong-looks-like-pathcache-doesnt-work", cksum1, false)
|
||||||
|
c.Check(err, IsNil)
|
||||||
|
|
||||||
|
c.Check(s.GetFile(c, "lala/pool/main/m/mars-invaders/mars-invaders_1.03.deb"), DeepEquals, []byte("Contents"))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user