// CheckPacks validates the file contents of packs against manifest hashes
// using the pack check function pc
CheckPacks validates the file contents of packs against manifest hashes
using the pack check function pc
// CheckPacks validates the file contents of packs against manifest hashes // using the pack check function pc
func CheckPacks(r *diva.Results, c *config.Config, version, minVer uint, delta bool) error {
	cLoc := filepath.Join(c.Paths.CacheLocation, "update")
	momPath := filepath.Join(cLoc, fmt.Sprint(version), "Manifest.MoM")
	MoM, err := swupd.ParseManifestFile(momPath)
	if err != nil {
		return err
	}
	var wg sync.WaitGroup
	workers := 4
	wg.Add(workers)
	bCh := make(chan *swupd.File)
	eCh := make(chan error, workers)
	for i := 0; i < workers; i++ {
		go func() {
			defer wg.Done()
			for man := range bCh {
				if uint(man.Version) < minVer {
					continue
				}
				mPath := filepath.Join(cLoc, fmt.Sprint(man.Version), "Manifest."+man.Name)
				m, e := swupd.ParseManifestFile(mPath)
				if e != nil {
					eCh <- e
					break
				}
				var failures []string
				var desc string
				if delta {
					failures, e = CheckDeltaPacks(c, m)
					desc = "delta pack content correct for " + m.Name
				} else {
					failures, e = CheckZeroPack(c, m)
					desc = "zero pack content correct for " + m.Name
				}
				if e != nil {
					eCh <- e
					break
				}
				r.Ok(len(failures) == 0, desc)
				if len(failures) > 0 {
					r.Diagnostic("pack issues:\n" + strings.Join(failures, "\n"))
				}
			}
		}()
	}
	for _, b := range MoM.Files {
		select {
		case bCh <- b:
		case err = <-eCh:
			break
		}
	}
	close(bCh)
	wg.Wait()
	if err == nil && len(eCh) > 0 {
		err = <-eCh
	}
	chanLen := len(eCh)
	for i := 0; i < chanLen; i++ {
		<-eCh
	}
	return err
}
func CheckPacks ( r * diva . Results , c * config . Config , version , minVer uint , delta bool ) error { cLoc := filepath . Join ( c . Paths . CacheLocation , " " ) momPath := filepath . Join ( cLoc , fmt . Sprint ( version ) , " " ) MoM , err := swupd . ParseManifestFile ( momPath ) if err != nil { return err } var wg sync . WaitGroup workers := 4 wg . Add ( workers ) bCh := make ( chan * swupd . File ) eCh := make ( chan error , workers ) for i := 0 ; i < workers ; i ++ { go func ( ) { defer wg . Done ( ) for man := range bCh { if uint ( man . Version ) < minVer { continue } mPath := filepath . Join ( cLoc , fmt . Sprint ( man . Version ) , " " + man . Name ) m , e := swupd . ParseManifestFile ( mPath ) if e != nil { eCh <- e break } var failures [ ] string var desc string if delta { failures , e = CheckDeltaPacks ( c , m ) desc = " " + m . Name } else { failures , e = CheckZeroPack ( c , m ) desc = " " + m . Name } if e != nil { eCh <- e break } r . Ok ( len ( failures ) == 0 , desc ) if len ( failures ) > 0 { r . Diagnostic ( " \n " + strings . Join ( failures , " \n " ) ) } } } ( ) } for _ , b := range MoM . Files { select { case bCh <- b : case err = <- eCh : break } } close ( bCh ) wg . Wait ( ) if err == nil && len ( eCh ) > 0 { err = <- eCh } chanLen := len ( eCh ) for i := 0 ; i < chanLen ; i ++ { <- eCh } return err }
CheckPacks validates the file contents of packs against manifest hashes
using the pack check function pc
CheckPacks validates the file contents of packs against manifest hashes using the pack check function pc
// break on first failure