Skip to content

Commit 8bceeff

Browse files
authored
Bump github.com/cavaliergopher/grab from 1.0.0 to 3.0.1 (#462)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
1 parent 48e289d commit 8bceeff

3 files changed

Lines changed: 21 additions & 21 deletions

File tree

app/utils/netu/netu.go

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"strings"
99
"time"
1010

11-
"github.com/cavaliercoder/grab"
11+
"github.com/cavaliergopher/grab/v3"
1212
)
1313

1414
// GetCIDRFromIPRange converts IP range to CIDR
@@ -77,27 +77,30 @@ func GetIpsFromIPRange(ipRange string) ([]string, error) {
7777

7878
// DownloadFile downloads a file and display status
7979
func DownloadFile(filename string, url string) error {
80-
req, err := grab.NewRequest(url)
80+
client := grab.NewClient()
81+
req, err := grab.NewRequest(filename, url)
8182
if err != nil {
8283
return err
8384
}
84-
req.Filename = filename
8585

86-
respch := grab.DefaultClient.DoAsync(req)
87-
resp := <-respch
88-
89-
ticker := time.NewTicker(200 * time.Millisecond)
90-
for range ticker.C {
91-
if resp.IsComplete() {
92-
if resp.Error != nil {
93-
return resp.Error
94-
}
95-
break
86+
resp := client.Do(req)
87+
t := time.NewTicker(200 * time.Millisecond)
88+
defer t.Stop()
89+
90+
Loop:
91+
for {
92+
select {
93+
case <-t.C:
94+
fmt.Print(".")
95+
case <-resp.Done:
96+
break Loop
9697
}
97-
fmt.Print(".")
9898
}
9999

100-
ticker.Stop()
100+
if err := resp.Err(); err != nil {
101+
return err
102+
}
103+
101104
return nil
102105
}
103106

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ require (
66
github.com/0xrawsec/golang-evtx v1.2.9
77
github.com/PuerkitoBio/goquery v1.8.0
88
github.com/akyoto/color v1.8.12
9-
github.com/cavaliercoder/grab v1.0.0
9+
github.com/cavaliergopher/grab/v3 v3.0.1
1010
github.com/cevaris/ordered_map v0.0.0-20190319150403-3adeae072e73
11-
github.com/djherbis/times v1.5.0 // indirect
1211
github.com/go-ole/go-ole v1.2.6
1312
github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b
1413
github.com/josephspurrier/goversioninfo v1.4.0

go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@ github.com/akyoto/tty v0.1.4 h1:TELbnAmrPTIrUJyuBLhrOSCcBnklC2fh0YeCTjksiDE=
1717
github.com/akyoto/tty v0.1.4/go.mod h1:fkWwtA4F5Cq9kiQSlWdkPy5kAyySGYqalWyaRKn3zHo=
1818
github.com/andybalholm/cascadia v1.3.1 h1:nhxRkql1kdYCc8Snf7D5/D3spOX+dBgjA6u8x004T2c=
1919
github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA=
20-
github.com/cavaliercoder/grab v1.0.0 h1:H6VQ1NiLO7AvXM6ZyaInnoZrRLeo2FoUTQEcXln4bvQ=
21-
github.com/cavaliercoder/grab v1.0.0/go.mod h1:tTBkfNqSBfuMmMBFaO2phgyhdYhiZQ/+iXCZDzcDsMI=
20+
github.com/cavaliergopher/grab/v3 v3.0.1 h1:4z7TkBfmPjmLAAmkkAZNX/6QJ1nNFdv3SdIHXju0Fr4=
21+
github.com/cavaliergopher/grab/v3 v3.0.1/go.mod h1:1U/KNnD+Ft6JJiYoYBAimKH2XrYptb8Kl3DFGmsjpq4=
2222
github.com/cevaris/ordered_map v0.0.0-20190319150403-3adeae072e73 h1:q1g9lSyo/nOIC3W5E3FK3Unrz8b9LdLXCyuC+ZcpPC0=
2323
github.com/cevaris/ordered_map v0.0.0-20190319150403-3adeae072e73/go.mod h1:507vXsotcZop7NZfBWdhPmVeOse4ko2R7AagJYrpoEg=
2424
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
2525
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
26-
github.com/djherbis/times v1.5.0 h1:79myA211VwPhFTqUk8xehWrsEO+zcIZj0zT8mXPVARU=
27-
github.com/djherbis/times v1.5.0/go.mod h1:5q7FDLvbNg1L/KaBmPcWlVR9NmoKo3+ucqUA3ijQhA0=
2826
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
2927
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
3028
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=

0 commit comments

Comments
 (0)