Fix temporary file issues
This commit is contained in:
parent
7d59377309
commit
78171c86c0
|
@ -19,6 +19,7 @@ glide-install:
|
||||||
- mkdir -p build/i386 build/amd64 build/armv7
|
- mkdir -p build/i386 build/amd64 build/armv7
|
||||||
cache:
|
cache:
|
||||||
key: "pipeline-$CI_PIPELINE_ID"
|
key: "pipeline-$CI_PIPELINE_ID"
|
||||||
|
policy: push
|
||||||
paths:
|
paths:
|
||||||
- src/meow.tf/deb-simple/vendor
|
- src/meow.tf/deb-simple/vendor
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ func (c Conf) PoolPackagePath(distro, arch, name string) string {
|
||||||
|
|
||||||
func (c Conf) RelativePoolPackagePath(distro, arch, name string) string {
|
func (c Conf) RelativePoolPackagePath(distro, arch, name string) string {
|
||||||
name = packageName(name)
|
name = packageName(name)
|
||||||
return path.Join(c.Repo.Root, "pool/main", distro, arch, name[0:1], name)
|
return path.Join("pool/main", distro, arch, name[0:1], name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c RepoConf) DistroNames() []string {
|
func (c RepoConf) DistroNames() []string {
|
||||||
|
|
|
@ -172,8 +172,13 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
f.Path = path.Join(conf.RelativePoolPackagePath(distroName, archType, f.Info.Package), part.FileName())
|
f.Path = path.Join(conf.RelativePoolPackagePath(distroName, archType, f.Info.Package), part.FileName())
|
||||||
|
|
||||||
if err := os.Rename(tempFile, path.Join(newPath, part.FileName())); err != nil {
|
if err := copyFile(tempFile, path.Join(newPath, part.FileName())); err != nil {
|
||||||
httpErrorf(w, "error moving temporary file: %s", err)
|
httpErrorf(w, "error copying temporary file: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := os.Remove(tempFile); err != nil {
|
||||||
|
httpErrorf(w, "unable to remove temporary file: %s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -180,6 +180,8 @@ func newPackageFile(filePath string) (*PackageFile, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
var (
|
var (
|
||||||
md5hash = md5.New()
|
md5hash = md5.New()
|
||||||
sha1hash = sha1.New()
|
sha1hash = sha1.New()
|
||||||
|
|
|
@ -13,6 +13,7 @@ import (
|
||||||
"runtime"
|
"runtime"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/go-ini/ini"
|
"github.com/go-ini/ini"
|
||||||
|
"io"
|
||||||
)
|
)
|
||||||
|
|
||||||
var VERSION string = "1.3.3"
|
var VERSION string = "1.3.3"
|
||||||
|
@ -191,3 +192,25 @@ func stripPrefix(str, prefix string) string {
|
||||||
}
|
}
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func copyFile(oldPath, newPath string) error {
|
||||||
|
old, err := os.Open(oldPath)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
defer old.Close()
|
||||||
|
|
||||||
|
n, err := os.Create(newPath)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
defer n.Close()
|
||||||
|
|
||||||
|
_, err = io.Copy(n, old)
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
Loading…
Reference in New Issue