Reduce required usage of LocalPackagePool

Several sections of the code *required* a LocalPackagePool, but they
could still perform their operations with a standard PackagePool.

Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
This commit is contained in:
Ryan Gonzalez
2022-05-16 14:14:45 -05:00
committed by André Roth
parent 1ebd37f9ad
commit 19255debb9
3 changed files with 51 additions and 11 deletions
+12 -1
View File
@@ -2,6 +2,8 @@ package cmd
import (
"fmt"
"io/ioutil"
"os"
"strings"
"sync"
@@ -161,7 +163,16 @@ func aptlyMirrorUpdate(cmd *commander.Command, args []string) error {
var e error
// provision download location
task.TempDownPath, e = context.PackagePool().(aptly.LocalPackagePool).GenerateTempPath(task.File.Filename)
if pp, ok := context.PackagePool().(aptly.LocalPackagePool); ok {
task.TempDownPath, e = pp.GenerateTempPath(task.File.Filename)
} else {
var file *os.File
file, e = ioutil.TempFile("", task.File.Filename)
if e == nil {
task.TempDownPath = file.Name()
file.Close()
}
}
if e != nil {
pushError(e)
continue