copy files instead of moving them
This commit is contained in:
31
utils.go
31
utils.go
@@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/gobwas/glob"
|
"github.com/gobwas/glob"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
@@ -200,7 +201,7 @@ func movePackagesLive(fullRepo string) error {
|
|||||||
filepath.Join(conf.Basedir.Debug, march, filepath.Base(file)))
|
filepath.Join(conf.Basedir.Debug, march, filepath.Base(file)))
|
||||||
}
|
}
|
||||||
|
|
||||||
err = os.Rename(file, filepath.Join(conf.Basedir.Debug, march, filepath.Base(file)))
|
err = Copy(file, filepath.Join(conf.Basedir.Debug, march, filepath.Base(file)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -230,11 +231,11 @@ func movePackagesLive(fullRepo string) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
err = os.Rename(file, filepath.Join(conf.Basedir.Repo, fullRepo, "os", conf.Arch, filepath.Base(file)))
|
err = Copy(file, filepath.Join(conf.Basedir.Repo, fullRepo, "os", conf.Arch, filepath.Base(file)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = os.Rename(file+".sig", filepath.Join(conf.Basedir.Repo, fullRepo, "os", conf.Arch, filepath.Base(file)+".sig"))
|
err = Copy(file+".sig", filepath.Join(conf.Basedir.Repo, fullRepo, "os", conf.Arch, filepath.Base(file)+".sig"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -671,3 +672,27 @@ func MatchGlobList(target string, globs []string) (bool, error) {
|
|||||||
}
|
}
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Copy(srcPath, dstPath string) (err error) {
|
||||||
|
r, err := os.Open(srcPath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer func(r *os.File) {
|
||||||
|
_ = r.Close()
|
||||||
|
}(r)
|
||||||
|
|
||||||
|
w, err := os.Create(dstPath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if c := w.Close(); err == nil {
|
||||||
|
err = c
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
_, err = io.Copy(w, r)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user