Move Stat() into LocalPackagePool

The contents of `os.Stat` are rather fitted towards local package pools,
but the method is in the generic PackagePool interface. This moves it to
LocalPackagePool, and the use case of simply finding a file's size is
delegated to a new, more generic PackagePool.Size() method.

Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
This commit is contained in:
Ryan Gonzalez
2022-05-16 14:07:03 -05:00
committed by André Roth
parent 8e37813129
commit 1ebd37f9ad
3 changed files with 25 additions and 2 deletions
+9
View File
@@ -379,6 +379,15 @@ func (pool *PackagePool) Import(srcPath, basename string, checksums *utils.Check
return poolPath, err
}
func (pool *PackagePool) Size(path string) (size int64, err error) {
stat, err := pool.Stat(path)
if err != nil {
return 0, err
}
return stat.Size(), nil
}
// Open returns io.ReadCloser to access the file
func (pool *PackagePool) Open(path string) (aptly.ReadSeekerCloser, error) {
return os.Open(filepath.Join(pool.rootPath, path))