Skip to content

Commit

Permalink
feat: Add command to manually download failed downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
vegidio committed Dec 24, 2024
1 parent 691ecf5 commit 92fbf8c
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cli/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/sirupsen/logrus v1.9.3
github.com/urfave/cli/v2 v2.27.5
github.com/vegidio/shared v0.0.0-00010101000000-000000000000
github.com/vegidio/umd-lib v0.0.0-20241220121920-52096f944424
github.com/vegidio/umd-lib v0.0.0-20241224003918-03009332159f
)

require (
Expand Down
4 changes: 2 additions & 2 deletions cli/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/urfave/cli/v2 v2.27.5 h1:WoHEJLdsXr6dDWoJgMq/CboDmyY/8HMMH1fTECbih+w=
github.com/urfave/cli/v2 v2.27.5/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ=
github.com/vegidio/umd-lib v0.0.0-20241220121920-52096f944424 h1:bzJUUbK8mk3gURXBeOpyx57+t/nfCiV2YJCneIbh3uQ=
github.com/vegidio/umd-lib v0.0.0-20241220121920-52096f944424/go.mod h1:FL/zCnREdxKrt+4GUmFFJ6pgjthtjXODWG6lEu7HnJI=
github.com/vegidio/umd-lib v0.0.0-20241224003918-03009332159f h1:8FocIek3sgD6sq36NfwziVSGngqLrvmk/qjTKlQQQkU=
github.com/vegidio/umd-lib v0.0.0-20241224003918-03009332159f/go.mod h1:FL/zCnREdxKrt+4GUmFFJ6pgjthtjXODWG6lEu7HnJI=
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
Expand Down
2 changes: 1 addition & 1 deletion gui/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/sirupsen/logrus v1.9.3
github.com/spf13/afero v1.11.0
github.com/vegidio/shared v0.0.0-00010101000000-000000000000
github.com/vegidio/umd-lib v0.0.0-20241220121920-52096f944424
github.com/vegidio/umd-lib v0.0.0-20241224003918-03009332159f
github.com/wailsapp/wails/v2 v2.9.2
)

Expand Down
4 changes: 2 additions & 2 deletions gui/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyC
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
github.com/vegidio/umd-lib v0.0.0-20241220121920-52096f944424 h1:bzJUUbK8mk3gURXBeOpyx57+t/nfCiV2YJCneIbh3uQ=
github.com/vegidio/umd-lib v0.0.0-20241220121920-52096f944424/go.mod h1:FL/zCnREdxKrt+4GUmFFJ6pgjthtjXODWG6lEu7HnJI=
github.com/vegidio/umd-lib v0.0.0-20241224003918-03009332159f h1:8FocIek3sgD6sq36NfwziVSGngqLrvmk/qjTKlQQQkU=
github.com/vegidio/umd-lib v0.0.0-20241224003918-03009332159f/go.mod h1:FL/zCnREdxKrt+4GUmFFJ6pgjthtjXODWG6lEu7HnJI=
github.com/wailsapp/go-webview2 v1.0.16 h1:wffnvnkkLvhRex/aOrA3R7FP7rkvOqL/bir1br7BekU=
github.com/wailsapp/go-webview2 v1.0.16/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
Expand Down
2 changes: 1 addition & 1 deletion shared/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/go-resty/resty/v2 v2.16.2
github.com/samber/lo v1.47.0
github.com/spf13/afero v1.11.0
github.com/vegidio/umd-lib v0.0.0-20241220121920-52096f944424
github.com/vegidio/umd-lib v0.0.0-20241224003918-03009332159f
)

require (
Expand Down
2 changes: 2 additions & 0 deletions shared/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ github.com/vegidio/umd-lib v0.0.0-20241219154936-e165552cc079 h1:w4El80VkKRZu9yd
github.com/vegidio/umd-lib v0.0.0-20241219154936-e165552cc079/go.mod h1:FL/zCnREdxKrt+4GUmFFJ6pgjthtjXODWG6lEu7HnJI=
github.com/vegidio/umd-lib v0.0.0-20241220121920-52096f944424 h1:bzJUUbK8mk3gURXBeOpyx57+t/nfCiV2YJCneIbh3uQ=
github.com/vegidio/umd-lib v0.0.0-20241220121920-52096f944424/go.mod h1:FL/zCnREdxKrt+4GUmFFJ6pgjthtjXODWG6lEu7HnJI=
github.com/vegidio/umd-lib v0.0.0-20241224003918-03009332159f h1:8FocIek3sgD6sq36NfwziVSGngqLrvmk/qjTKlQQQkU=
github.com/vegidio/umd-lib v0.0.0-20241224003918-03009332159f/go.mod h1:FL/zCnREdxKrt+4GUmFFJ6pgjthtjXODWG6lEu7HnJI=
github.com/ysmood/fetchup v0.2.4 h1:2kfWr/UrdiHg4KYRrxL2Jcrqx4DZYD+OtWu7WPBZl5o=
github.com/ysmood/fetchup v0.2.4/go.mod h1:hbysoq65PXL0NQeNzUczNYIKpwpkwFL4LXMDEvIQq9A=
github.com/ysmood/goob v0.4.0 h1:HsxXhyLBeGzWXnqVKtmT9qM7EuVs/XOgkX7T6r1o1AQ=
Expand Down
3 changes: 2 additions & 1 deletion shared/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/denisbrodbeck/machineid"
"github.com/mixpanel/mixpanel-go"
"runtime"
"strings"
)

type MixPanel struct {
Expand All @@ -22,7 +23,7 @@ func NewMixPanel(distinctId string) *MixPanel {
func (m *MixPanel) Track(event string, fields map[string]any) {
// Set the computer information
id, _ := machineid.ID()
fields["machineId"] = id
fields["machineId"] = strings.ToLower(id)
fields["os"] = runtime.GOOS
fields["arch"] = runtime.GOARCH

Expand Down
31 changes: 31 additions & 0 deletions shared/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/spf13/afero"
"path/filepath"
"strconv"
"strings"
)

var fs = afero.NewOsFs()
Expand Down Expand Up @@ -56,9 +57,39 @@ func CreateReport(directory string, downloads []Download) {
fileContent += "---\n"
}

if len(failedDownloads) > 0 {
fileContent += createManualDownloadCommand(failedDownloads)
}

_, _ = file.WriteString(fileContent)
}

func createManualDownloadCommand(downloads []Download) string {
fileContent := "\n## Retry Failed Downloads\n\n"
fileContent += "You can retry the failed downloads by using either [aria2](https://aria2.github.io) (recommended) or [wget](https://www.gnu.org/software/wget):\n\n"
fileContent += "### Aria2\n\n"
fileContent += "```bash\n"

downloadList := lo.Reduce(downloads, func(acc string, d Download, _ int) string {
return acc + fmt.Sprintf(" %s", d.Url)
}, "$ aria2c --file-allocation=none --auto-file-renaming=false --always-resume=true --conditional-get=true -c -s 1 -x 5 -j 5 -m 10 -Z")

line := ""
for _, part := range strings.Split(downloadList, " ") {
if (len(line) + len(part)) >= 118 {
fileContent += line + " \\\n"
line = " "
}

line += " " + part
}

fileContent += line + "\n"
fileContent += "```\n"

return fileContent
}

func RemoveDuplicates(downloads []Download, onDuplicateDeleted func(download Download)) (int, []Download) {
numDeleted := 0
remaining := make([]Download, 0)
Expand Down

0 comments on commit 92fbf8c

Please sign in to comment.