Fix temporary file uploads
This commit is contained in:
parent
e624bce8f1
commit
bb991a538d
|
@ -14,6 +14,7 @@ import (
|
|||
|
||||
func InspectPackage(filename string) (string, error) {
|
||||
f, err := os.Open(filename)
|
||||
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error opening package file %s: %s", filename, err)
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) {
|
|||
dst.Close()
|
||||
|
||||
// Get package name, if it already exists remove the old file.
|
||||
f, err := newPackageFile(tempFile, part.FileName())
|
||||
f, err := newPackageFile(tempFile)
|
||||
|
||||
if err != nil {
|
||||
httpErrorf(w, "error loading package info: %s", err)
|
||||
|
|
|
@ -132,7 +132,7 @@ func scanRecursive(base string, m map[string]*PackageFile) error {
|
|||
continue
|
||||
}
|
||||
|
||||
p, err := newPackageFile(base, file.Name())
|
||||
p, err := newPackageFile(path.Join(base, file.Name()))
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -154,17 +154,15 @@ func scanRecursive(base string, m map[string]*PackageFile) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func newPackageFile(base, name string) (*PackageFile, error) {
|
||||
func newPackageFile(filePath string) (*PackageFile, error) {
|
||||
p := &PackageFile{
|
||||
Name: name,
|
||||
Path: path.Join(stripPrefix(base, conf.Repo.Root), name),
|
||||
Name: path.Base(filePath),
|
||||
Path: stripPrefix(filePath, conf.Repo.Root),
|
||||
}
|
||||
|
||||
debPath := path.Join(base, name)
|
||||
|
||||
var err error
|
||||
|
||||
p.ControlData, err = archive.InspectPackage(debPath)
|
||||
p.ControlData, err = archive.InspectPackage(filePath)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -172,11 +170,11 @@ func newPackageFile(base, name string) (*PackageFile, error) {
|
|||
|
||||
p.Info = parsePackageData(p.ControlData)
|
||||
|
||||
if stat, err := os.Stat(debPath); err == nil {
|
||||
if stat, err := os.Stat(filePath); err == nil {
|
||||
p.Size = stat.Size()
|
||||
}
|
||||
|
||||
f, err := os.Open(debPath)
|
||||
f, err := os.Open(filePath)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
"github.com/go-ini/ini"
|
||||
)
|
||||
|
||||
var VERSION string = "1.3.1"
|
||||
var VERSION string = "1.3.2"
|
||||
|
||||
func packageName(name string) string {
|
||||
if index := strings.Index(name, "_"); index != -1 {
|
||||
|
|
Loading…
Reference in New Issue