Switch to new download system
ci/woodpecker/push/woodpecker Pipeline was successful Details

This commit is contained in:
Elara 2023-01-28 20:53:06 -08:00
parent e785c6b53d
commit d26b288cde
4 changed files with 14 additions and 12 deletions

View File

@ -22,6 +22,7 @@ import (
"bytes"
"context"
"encoding/hex"
"fmt"
"io"
"os"
"path/filepath"
@ -40,10 +41,10 @@ import (
"github.com/goreleaser/nfpm/v2/files"
"go.arsenm.dev/logger/log"
"go.arsenm.dev/lure/distro"
"go.arsenm.dev/lure/download"
"go.arsenm.dev/lure/internal/cliutils"
"go.arsenm.dev/lure/internal/config"
"go.arsenm.dev/lure/internal/cpu"
"go.arsenm.dev/lure/internal/dl"
"go.arsenm.dev/lure/internal/repos"
"go.arsenm.dev/lure/internal/shutils"
"go.arsenm.dev/lure/internal/shutils/decoder"
@ -548,10 +549,11 @@ func getSources(ctx context.Context, srcdir string, bv *BuildVars) error {
}
for i, src := range bv.Sources {
opts := download.GetOptions{
SourceURL: src,
opts := dl.Options{
Name: fmt.Sprintf("%s[%d]", bv.Name, i),
URL: src,
Destination: srcdir,
EncloseGit: true,
Progress: os.Stderr,
}
if !strings.EqualFold(bv.Checksums[i], "SKIP") {
@ -559,10 +561,10 @@ func getSources(ctx context.Context, srcdir string, bv *BuildVars) error {
if err != nil {
return err
}
opts.SHA256Sum = checksum
opts.SHA256 = checksum
}
err := download.Get(ctx, opts)
err := dl.Download(ctx, opts)
if err != nil {
return err
}

View File

@ -212,7 +212,7 @@ func linkDir(src, dest string) error {
newPath := filepath.Join(dest, rel)
if info.IsDir() {
return os.Mkdir(newPath, info.Mode())
return os.MkdirAll(newPath, info.Mode())
}
return os.Link(path, newPath)

View File

@ -91,7 +91,7 @@ func (FileDownloader) Download(opts Options) (Type, string, error) {
}
if opts.PostprocDisabled {
return TypeFile, name, nil
return TypeFile, "", nil
}
_, err = fl.Seek(0, io.SeekStart)
@ -101,7 +101,7 @@ func (FileDownloader) Download(opts Options) (Type, string, error) {
format, r, err := archiver.Identify(name, fl)
if err == archiver.ErrNoMatch {
return TypeFile, name, nil
return TypeFile, "", nil
} else if err != nil {
return 0, "", err
}
@ -112,7 +112,7 @@ func (FileDownloader) Download(opts Options) (Type, string, error) {
}
err = os.Remove(path)
return TypeDir, strings.TrimSuffix(name, format.Name()), err
return TypeDir, "", err
}
func extractFile(r io.Reader, format archiver.Format, name string, opts Options) (err error) {

View File

@ -46,8 +46,8 @@ func (NopRWC) Read([]byte) (int, error) {
return 0, io.EOF
}
func (NopRWC) Write([]byte) (int, error) {
return 0, nil
func (NopRWC) Write(b []byte) (int, error) {
return len(b), nil
}
func (NopRWC) Close() error {