Thanks to visit codestin.com
Credit goes to github.com

Skip to content

download latest --black-list will only remove a single item #4

@h4x4g0n1337

Description

@h4x4g0n1337

the iteration in 'download_latest.go' over --black-list will break when a match is found.
This is false as multiple items should be removed.

While fixing it I changed --black-list to support a list strings delimited with ','

diff --git a/cmd/ipsw/cmd/download_latest.go b/cmd/ipsw/cmd/download_latest.go
index 21c460c..c882b7c 100644
--- a/cmd/ipsw/cmd/download_latest.go
+++ b/cmd/ipsw/cmd/download_latest.go
@@ -74,12 +74,22 @@ var latestCmd = &cobra.Command{
 		}
 
 		if len(doNotDownload) > 0 {
-			for i, v := range builds {
-				if strings.Contains(v.Identifier, doNotDownload) {
-					builds = append(builds[:i], builds[i+1:]...)
-					break
+			var validBuilds []api.Build
+			doNot := strings.Split(doNotDownload, ",")
+			for _, v := range builds {
+				valid := true
+
+				for _, doNotDownload = range doNot {
+					if strings.Contains(v.Identifier, doNotDownload) {
+						valid = false
+						break
+					}
+				}
+				if valid {
+					validBuilds = append(validBuilds, v)
 				}
 			}
+			builds = validBuilds
 		}
 
 		log.Debug("URLs to Download:")

The following will now work

ipsw download -V latest --yes --black-list AppleTV,iPhone

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions