Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ package cmd

import (
"fmt"
"github.com/khorevaa/logos"
server "github.com/v8platform/oneget/http-server"
"github.com/v8platform/oneget/unpacker"
"go.uber.org/multierr"
"io/ioutil"
"os"
"path"
"path/filepath"
"regexp"
"strings"
"time"

"github.com/khorevaa/logos"
server "github.com/v8platform/oneget/http-server"
"github.com/v8platform/oneget/unpacker"
"go.uber.org/multierr"

"github.com/urfave/cli/v2"
dloader "github.com/v8platform/oneget/downloader"
)
Expand Down Expand Up @@ -291,7 +291,7 @@ func (c *getCmd) extractFiles(files []string) error {
}

func renameFiles(dir string) error {
files, err := ioutil.ReadDir(dir)
files, err := os.ReadDir(dir)
if err != nil {
log.Errorf("Error find files in dir <%s> to rename: %s", dir, err.Error())
return err
Expand Down
12 changes: 0 additions & 12 deletions downloader/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@ import (

func TestMatchFilter_Match(t *testing.T) {

type args struct {
filters string
project string
}

type want struct {
source string
want bool
}

tests := []struct {
filters string
project string
Expand Down Expand Up @@ -263,8 +253,6 @@ func TestLatestVersionFilter_Filter(t *testing.T) {
}

func Test_compareVersion(t *testing.T) {
type args struct {
}
tests := []struct {
v1 string
v2 string
Expand Down
11 changes: 3 additions & 8 deletions downloader/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package downloader

import (
"fmt"
"github.com/PuerkitoBio/goquery"
"io"
"strings"
"time"

"github.com/PuerkitoBio/goquery"
)

type HtmlParser struct {
Expand Down Expand Up @@ -52,13 +53,8 @@ func (p *HtmlParser) ParseTotalReleases(body io.Reader) (rows []ProjectInfo, err

doc.Find(p.ReleaseTableSelector).Each(func(i int, html *goquery.Selection) {
tableHtml = html
return
})

if tableHtml == nil {
return
}

return parseReleasesTable(tableHtml), nil

}
Expand All @@ -74,7 +70,6 @@ func (p *HtmlParser) ParseProjectReleases(body io.Reader) (rows []*ProjectVersio

doc.Find(p.ProjectTableSelector).Each(func(i int, html *goquery.Selection) {
tableHtml = html
return
})

if tableHtml == nil {
Expand Down Expand Up @@ -165,7 +160,7 @@ func parseReleasesTable(s *goquery.Selection) (rows []ProjectInfo) {

info.Name = strings.TrimSpace(releaseRow.Find(".nameColumn").Text())
info.Url, _ = releaseRow.Find(".nameColumn a").Attr("href")
info.ID = strings.TrimLeft(info.Url, "/project/")
info.ID = strings.TrimSuffix(info.Url, "/project/")

releaseRow.Find("td").Each(func(i int, rowHtml *goquery.Selection) {

Expand Down
21 changes: 3 additions & 18 deletions downloader/oneDownloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ package downloader

import (
"fmt"
"go.uber.org/multierr"
"io"
"net/http"
"net/http/cookiejar"
"net/url"
"os"
"path/filepath"
"strings"
"sync"

"go.uber.org/multierr"
)

type GetConfig struct {
Expand All @@ -34,8 +34,7 @@ type OnegetDownloader struct {

client *Client

urlCh chan *FileToDownload
wg *sync.WaitGroup
wg *sync.WaitGroup

parser *HtmlParser
}
Expand Down Expand Up @@ -223,13 +222,6 @@ func filterProjectVersionInfo(list []*ProjectVersionInfo, filter VersionFilter)

}

func (dr *OnegetDownloader) getClient() *http.Client {
return &http.Client{
Jar: dr.cookie,
Transport: nil,
}
}

func (dr *OnegetDownloader) addFileToChannel(href string, config GetConfig, downloadCh chan *FileToDownload) (err error) {

downloadHref := []string{releasesURL + href}
Expand Down Expand Up @@ -368,13 +360,6 @@ func SaveToFile(reader io.ReadCloser, fileName string) error {
return nil
}

func (dr *OnegetDownloader) handleError(err error) {
if err == nil {
return
}
log.Error(err.Error())
}

func (dr *OnegetDownloader) getDownloadFileLinks(href string, _ GetConfig) ([]string, error) {

client := dr.client
Expand Down
10 changes: 5 additions & 5 deletions unpacker/unpacker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package unpacker

import (
"fmt"
"github.com/stretchr/testify/assert"
"io/ioutil"
"os"
"path/filepath"
"regexp"
"testing"

"github.com/stretchr/testify/assert"
)

func TestUnpackTarGz(t *testing.T) {
Expand All @@ -16,7 +16,7 @@ func TestUnpackTarGz(t *testing.T) {
defer os.RemoveAll(tempDir)

path := filepath.Join("fixtures", "linux", "client")
files, err := ioutil.ReadDir(path)
files, err := os.ReadDir(path)
if err != nil {
log.Error(err.Error())
}
Expand All @@ -28,7 +28,7 @@ func TestUnpackTarGz(t *testing.T) {
fileGZ := fileName[:len(fileName)-len(filepath.Ext(fileName))]
dirName := fileGZ[:len(fileGZ)-len(filepath.Ext(fileGZ))]

files, err := ioutil.ReadDir(filepath.Join(tempDir, dirName))
files, err := os.ReadDir(filepath.Join(tempDir, dirName))
if err != nil {
log.Error(err.Error())
}
Expand Down Expand Up @@ -100,7 +100,7 @@ func getExpectedName() map[string]string {
}

func getTempDir() (string, error) {
dir, err := ioutil.TempDir("", "oneget")
dir, err := os.MkdirTemp("", "oneget")
if err != nil {
log.Error(err.Error())
}
Expand Down