Skip to content

Commit

Permalink
s3: call s3.ListFiles only on publish path in LinkFromPool
Browse files Browse the repository at this point in the history
instead of caching the whole s3 bucket, cache only the pool path. this
requires an additional parameter, and since this is an interface, all
implementations need to follow. might help in other backends too.

closes #1181
  • Loading branch information
neolynx committed Jan 6, 2024
1 parent 1e74e54 commit c530bf8
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion aptly/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type PublishedStorage interface {
// Remove removes single file under public path
Remove(path string) error
// LinkFromPool links package file from pool to dist's pool location
LinkFromPool(publishedDirectory, fileName string, sourcePool PackagePool, sourcePath string, sourceChecksums utils.ChecksumInfo, force bool) error
LinkFromPool(prefix string, path string, fileName string, sourcePool PackagePool, sourcePath string, sourceChecksums utils.ChecksumInfo, force bool) error
// Filelist returns list of files under prefix
Filelist(prefix string) ([]string, error)
// RenameFile renames (moves) file
Expand Down
3 changes: 2 additions & 1 deletion azure/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,10 @@ func (storage *PublishedStorage) Remove(path string) error {
// sourcePath is filepath to package file in package pool
//
// LinkFromPool returns relative path for the published file to be included in package index
func (storage *PublishedStorage) LinkFromPool(publishedDirectory, fileName string, sourcePool aptly.PackagePool,
func (storage *PublishedStorage) LinkFromPool(prefix string, path string, fileName string, sourcePool aptly.PackagePool,
sourcePath string, sourceChecksums utils.ChecksumInfo, force bool) error {

publishedDirectory := filepath.Join(prefix, path)
relPath := filepath.Join(publishedDirectory, fileName)
poolPath := filepath.Join(storage.prefix, relPath)

Expand Down
4 changes: 1 addition & 3 deletions deb/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,7 @@ func (p *Package) LinkFromPool(publishedStorage aptly.PublishedStorage, packageP
return err
}

publishedDirectory := filepath.Join(prefix, relPath)

err = publishedStorage.LinkFromPool(publishedDirectory, f.Filename, packagePool, sourcePoolPath, f.Checksums, force)
err = publishedStorage.LinkFromPool(prefix, relPath, f.Filename, packagePool, sourcePoolPath, f.Checksums, force)
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion files/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,10 @@ func (storage *PublishedStorage) RemoveDirs(path string, progress aptly.Progress
// sourcePath is a relative path to package file in package pool
//
// LinkFromPool returns relative path for the published file to be included in package index
func (storage *PublishedStorage) LinkFromPool(publishedDirectory, fileName string, sourcePool aptly.PackagePool,
func (storage *PublishedStorage) LinkFromPool(prefix string, path string, fileName string, sourcePool aptly.PackagePool,
sourcePath string, sourceChecksums utils.ChecksumInfo, force bool) error {

publishedDirectory := filepath.Join(prefix, path)
baseName := filepath.Base(fileName)
poolPath := filepath.Join(storage.rootPath, publishedDirectory, filepath.Dir(fileName))

Expand Down
5 changes: 3 additions & 2 deletions s3/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,14 +310,15 @@ func (storage *PublishedStorage) RemoveDirs(path string, _ aptly.Progress) error
// sourcePath is filepath to package file in package pool
//
// LinkFromPool returns relative path for the published file to be included in package index
func (storage *PublishedStorage) LinkFromPool(publishedDirectory, fileName string, sourcePool aptly.PackagePool,
func (storage *PublishedStorage) LinkFromPool(prefix string, path string, fileName string, sourcePool aptly.PackagePool,
sourcePath string, sourceChecksums utils.ChecksumInfo, force bool) error {

publishedDirectory := filepath.Join(prefix, path)
relPath := filepath.Join(publishedDirectory, fileName)
poolPath := filepath.Join(storage.prefix, relPath)

if storage.pathCache == nil {
paths, md5s, err := storage.internalFilelist("", true)
paths, md5s, err := storage.internalFilelist(filepath.Join(storage.prefix, prefix, "pool"), true)
if err != nil {
return errors.Wrap(err, "error caching paths under prefix")
}
Expand Down
3 changes: 2 additions & 1 deletion swift/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,10 @@ func (storage *PublishedStorage) RemoveDirs(path string, _ aptly.Progress) error
// sourcePath is filepath to package file in package pool
//
// LinkFromPool returns relative path for the published file to be included in package index
func (storage *PublishedStorage) LinkFromPool(publishedDirectory, fileName string, sourcePool aptly.PackagePool,
func (storage *PublishedStorage) LinkFromPool(prefix string, path string, fileName string, sourcePool aptly.PackagePool,
sourcePath string, sourceChecksums utils.ChecksumInfo, force bool) error {

publishedDirectory := filepath.Join(prefix, path)
relPath := filepath.Join(publishedDirectory, fileName)
poolPath := filepath.Join(storage.prefix, relPath)

Expand Down

0 comments on commit c530bf8

Please sign in to comment.