Explorar o código

style(cmd): remove useless filtering

jguer %!s(int64=4) %!d(string=hai) anos
pai
achega
520dd58999
Modificáronse 1 ficheiros con 11 adicións e 7 borrados
  1. 11 7
      cmd.go

+ 11 - 7
cmd.go

@@ -197,18 +197,22 @@ func handleVersion() {
 }
 
 func lastBuildTime(alpmHandle *alpm.Handle) time.Time {
-	pkgs, _, _, _, err := query.FilterPackages(alpmHandle)
+	dbList, err := alpmHandle.SyncDBs()
 	if err != nil {
 		return time.Now()
 	}
 
 	var lastTime time.Time
-	for _, pkg := range pkgs {
-		thisTime := pkg.BuildDate()
-		if thisTime.After(lastTime) {
-			lastTime = thisTime
-		}
-	}
+	_ = dbList.ForEach(func(db alpm.DB) error {
+		_ = db.PkgCache().ForEach(func(pkg alpm.Package) error {
+			thisTime := pkg.BuildDate()
+			if thisTime.After(lastTime) {
+				lastTime = thisTime
+			}
+			return nil
+		})
+		return nil
+	})
 
 	return lastTime
 }