Fix bug with PoolPath field being overwritten on mirror update

While updating mirror, if package file is already in pool path,
field `PoolPath` was left as empty which results in package file
being unavailable later on while publishing.
This commit is contained in:
Andrey Smirnov
2017-08-11 20:05:55 +03:00
parent 587bfd742f
commit a584b2e058
7 changed files with 69 additions and 24 deletions
+4 -3
View File
@@ -629,14 +629,15 @@ type PackageDownloadTask struct {
func (p *Package) DownloadList(packagePool aptly.PackagePool, checksumStorage aptly.ChecksumStorage) (result []PackageDownloadTask, err error) {
result = make([]PackageDownloadTask, 0, 1)
for idx, f := range p.Files() {
verified, err := f.Verify(packagePool, checksumStorage)
files := p.Files()
for idx := range files {
verified, err := files[idx].Verify(packagePool, checksumStorage)
if err != nil {
return nil, err
}
if !verified {
result = append(result, PackageDownloadTask{File: &p.Files()[idx]})
result = append(result, PackageDownloadTask{File: &files[idx]})
}
}
+6 -1
View File
@@ -27,7 +27,12 @@ type PackageFile struct {
// Verify that package file is present and correct
func (f *PackageFile) Verify(packagePool aptly.PackagePool, checksumStorage aptly.ChecksumStorage) (bool, error) {
return packagePool.Verify(f.PoolPath, f.Filename, &f.Checksums, checksumStorage)
generatedPoolPath, exists, err := packagePool.Verify(f.PoolPath, f.Filename, &f.Checksums, checksumStorage)
if exists && err == nil {
f.PoolPath = generatedPoolPath
}
return exists, err
}
// GetPoolPath returns path to the file in the pool