diff --git a/console.go b/console.go index 6a47cd4..2b8af09 100644 --- a/console.go +++ b/console.go @@ -136,7 +136,7 @@ func (c *Console) Start() { if settingsObj.CheckForMissingUpdates { fmt.Printf("\nChecking for missing updates\n") - c.processMissingUpdates(localDB, titlesDB) + c.processMissingUpdates(localDB, titlesDB, settingsObj) } if settingsObj.CheckForMissingDLC { @@ -166,8 +166,8 @@ func (c *Console) processIssues(localDB *db.LocalSwitchFilesDB) { t.Render() } -func (c *Console) processMissingUpdates(localDB *db.LocalSwitchFilesDB, titlesDB *db.SwitchTitlesDB) { - incompleteTitles := process.ScanForMissingUpdates(localDB.TitlesMap, titlesDB.TitlesMap) +func (c *Console) processMissingUpdates(localDB *db.LocalSwitchFilesDB, titlesDB *db.SwitchTitlesDB, settingsObj *settings.AppSettings) { + incompleteTitles := process.ScanForMissingUpdates(localDB.TitlesMap, titlesDB.TitlesMap, settingsObj.IgnoreDLCUpdates) if len(incompleteTitles) != 0 { fmt.Print("\nFound available updates:\n\n") } else { diff --git a/gui.go b/gui.go index 7033a0a..45a9662 100644 --- a/gui.go +++ b/gui.go @@ -358,7 +358,8 @@ func (g *GUI) getMissingDLC() string { } func (g *GUI) getMissingUpdates() string { - missingUpdates := process.ScanForMissingUpdates(g.state.localDB.TitlesMap, g.state.switchDB.TitlesMap) + settingsObj := settings.ReadSettings(g.baseFolder) + missingUpdates := process.ScanForMissingUpdates(g.state.localDB.TitlesMap, g.state.switchDB.TitlesMap, settingsObj.IgnoreDLCUpdates) values := make([]process.IncompleteTitle, len(missingUpdates)) i := 0 for _, missingUpdate := range missingUpdates { diff --git a/process/incompleteTitleProcessor.go b/process/incompleteTitleProcessor.go index 9d23cc4..21965ad 100644 --- a/process/incompleteTitleProcessor.go +++ b/process/incompleteTitleProcessor.go @@ -2,11 +2,12 @@ package process import ( "fmt" + "sort" + "strconv" + "github.com/giwty/switch-library-manager/db" "github.com/giwty/switch-library-manager/switchfs" "go.uber.org/zap" - "sort" - "strconv" ) type IncompleteTitle struct { @@ -19,14 +20,14 @@ type IncompleteTitle struct { } func ScanForMissingUpdates(localDB map[string]*db.SwitchGameFiles, - switchDB map[string]*db.SwitchTitle) map[string]IncompleteTitle { + switchDB map[string]*db.SwitchTitle, ignoreDLCupdates bool) map[string]IncompleteTitle { result := map[string]IncompleteTitle{} //iterate over local files, and compare to remote versions for idPrefix, switchFile := range localDB { - if switchFile.BaseExist == false { + if !switchFile.BaseExist { zap.S().Infof("missing base for game %v", idPrefix) continue } @@ -36,6 +37,7 @@ func ScanForMissingUpdates(localDB map[string]*db.SwitchGameFiles, } switchTitle := IncompleteTitle{Attributes: switchDB[idPrefix].Attributes, Meta: switchFile.File.Metadata} + //sort the available local versions localVersions := make([]int, len(switchFile.Updates)) i := 0 @@ -73,32 +75,34 @@ func ScanForMissingUpdates(localDB map[string]*db.SwitchGameFiles, } //process dlc - for k, availableDlc := range switchDB[idPrefix].Dlc { + if !ignoreDLCupdates { + for k, availableDlc := range switchDB[idPrefix].Dlc { - if localDlc, ok := switchFile.Dlc[k]; ok { - latestDlcVersion, err := availableDlc.Version.Int64() - if err != nil { - continue - } + if localDlc, ok := switchFile.Dlc[k]; ok { + latestDlcVersion, err := availableDlc.Version.Int64() + if err != nil { + continue + } - if localDlc.Metadata == nil { - continue - } - if localDlc.Metadata.Version < int(latestDlcVersion) { - updateDate := "-" - if availableDlc.ReleaseDate != 0 { - updateDate = strconv.Itoa(availableDlc.ReleaseDate) - if len(updateDate) > 7 { - updateDate = updateDate[0:4] + "-" + updateDate[4:6] + "-" + updateDate[6:] - } + if localDlc.Metadata == nil { + continue } + if localDlc.Metadata.Version < int(latestDlcVersion) { + updateDate := "-" + if availableDlc.ReleaseDate != 0 { + updateDate = strconv.Itoa(availableDlc.ReleaseDate) + if len(updateDate) > 7 { + updateDate = updateDate[0:4] + "-" + updateDate[4:6] + "-" + updateDate[6:] + } + } - result[availableDlc.Id] = IncompleteTitle{ - Attributes: availableDlc, - LatestUpdate: int(latestDlcVersion), - LocalUpdate: localDlc.Metadata.Version, - LatestUpdateDate: updateDate, - Meta: localDlc.Metadata} + result[availableDlc.Id] = IncompleteTitle{ + Attributes: availableDlc, + LatestUpdate: int(latestDlcVersion), + LocalUpdate: localDlc.Metadata.Version, + LatestUpdateDate: updateDate, + Meta: localDlc.Metadata} + } } } } @@ -114,7 +118,7 @@ func ScanForMissingDLC(localDB map[string]*db.SwitchGameFiles, //iterate over local files, and compare to remote versions for idPrefix, switchFile := range localDB { - if switchFile.BaseExist == false { + if !switchFile.BaseExist { continue } @@ -148,7 +152,7 @@ func ScanForBrokenFiles(localDB map[string]*db.SwitchGameFiles) []db.SwitchFileI //iterate over local files, and compare to remote versions for _, switchFile := range localDB { - if switchFile.BaseExist == false { + if !switchFile.BaseExist { for _, f := range switchFile.Dlc { result = append(result, f) } diff --git a/settings/settings.go b/settings/settings.go index 97109fc..023c78c 100644 --- a/settings/settings.go +++ b/settings/settings.go @@ -60,6 +60,7 @@ type AppSettings struct { OrganizeOptions OrganizeOptions `json:"organize_options"` ScanRecursively bool `json:"scan_recursively"` GuiPagingSize int `json:"gui_page_size"` + IgnoreDLCUpdates bool `json:"ignore_dlc_updates"` IgnoreDLCTitleIds []string `json:"ignore_dlc_title_ids"` } @@ -99,6 +100,7 @@ func saveDefaultSettings(baseFolder string) *AppSettings { Folder: "", ScanFolders: []string{}, IgnoreDLCTitleIds: []string{}, + IgnoreDLCUpdates: false, GUI: true, GuiPagingSize: 100, CheckForMissingUpdates: true,