Skip to content

Commit

Permalink
Merge pull request #4 from jeffcox111/errhandling
Browse files Browse the repository at this point in the history
Errhandling
  • Loading branch information
Xpl0itU authored Jun 2, 2024
2 parents 7e650df + 5932245 commit e8d43a8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
.vscode/
dist/
output/
output/
otp.bin
28 changes: 26 additions & 2 deletions cmd/MLCRestorerDownloader/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"bufio"
"fmt"
"net"
"net/http"
Expand Down Expand Up @@ -88,6 +89,8 @@ func downloadTitles(region string, titles map[string][]string, titleType string)

allTitles := append(selectedRegionTitles, allRegionTitles...)

var failedTitles []string

commonKey, err := getCommonKey()
if err != nil {
fmt.Println("[Error]", err)
Expand Down Expand Up @@ -119,9 +122,30 @@ func downloadTitles(region string, titles map[string][]string, titleType string)
fmt.Printf("\n[Info] Downloading files for title %s on region %s for type %s\n\n", titleID, region, titleType)
if err := downloader.DownloadTitle(titleID, fmt.Sprintf("output/%s/%s/%s", titleType, region, titleID), progressReporter, client, commonKey); err != nil {
fmt.Println("[Error]", err)
os.Exit(1)
failedTitles = append(failedTitles, titleID)
continue
}
fmt.Printf("\n[Info] Download files for title %s on region %s for type %s done\n\n", titleID, region, titleType)
}
fmt.Println("\n[Info] All done!")

if len(failedTitles) == 0 {
fmt.Println("[Info] All done!")
fmt.Println("Press Enter to exit...")
bufio.NewReader(os.Stdin).ReadBytes('\n')
os.Exit(1)
} else {
fmt.Println("[Error] Some titles were not able to be downloaded. Would you like to retry?")
fmt.Println("1. Yes, retry ")
fmt.Println("2. No, not right now")
fmt.Print("Select an option: ")
var inputKey string
fmt.Scanln(&inputKey)

switch inputKey {
case "1":
downloadTitles(region, titles, titleType)
default:
os.Exit(1)
}
}
}

0 comments on commit e8d43a8

Please sign in to comment.