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
+13 -1
View File
@@ -2,7 +2,10 @@ package api
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"sort"
"strings"
"sync"
@@ -482,7 +485,16 @@ func apiMirrorsUpdate(c *gin.Context) {
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