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 authored and André Roth committed 2024-06-17 11:51:18 +02:00
1 parent 1ebd37f9ad
commit 19255debb9
3 files changed
+51 -11

No files matched your search

+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