// GetBundleSize gets the full size of all bundles in a given version
GetBundleSize gets the full size of all bundles in a given version
// GetBundleSize gets the full size of all bundles in a given version
func GetBundleSize(u diva.UInfo, bundlePath string) (map[string]int64, error) {
	manifests, err := getManifests(u)
	var wg sync.WaitGroup
	bundleWorkers := len(manifests)
	mChan := make(chan *swupd.Manifest)
	errChan := make(chan error, bundleWorkers)
	wg.Add(bundleWorkers)
	var bundleSizes = make(map[string]int64)
	baseCache := filepath.Join(u.CacheLoc, "update")
	momPath := filepath.Join(baseCache, fmt.Sprint(u.Ver), "Manifest.MoM")
	mom, err := swupd.ParseManifestFile(momPath)
	if err != nil {
		return nil, err
	}
	sort.Slice(mom.Files, func(i, j int) bool {
		return mom.Files[i].Name < mom.Files[j].Name
	})
	for i := 0; i < bundleWorkers; i++ {
		go func() {
			defer wg.Done()
			for m := range mChan {
				err = getSizes(u, m, mom, bundleSizes, bundlePath)
				if err != nil {
					errChan <- err
				}
			}
		}()
	}
	for _, m := range manifests {
		select {
		case mChan <- m:
		case err = <-errChan:
			break
		}
	}
	close(mChan)
	wg.Wait()
	chanLen := len(errChan)
	for i := 0; i < chanLen; i++ {
		<-errChan
	}
	return bundleSizes, err
}
func GetBundleSize ( u diva . UInfo , bundlePath string ) ( map [ string ] int64 , error ) { manifests , err := getManifests ( u ) var wg sync . WaitGroup bundleWorkers := len ( manifests ) mChan := make ( chan * swupd . Manifest ) errChan := make ( chan error , bundleWorkers ) wg . Add ( bundleWorkers ) var bundleSizes = make ( map [ string ] int64 ) baseCache := filepath . Join ( u . CacheLoc , " " ) momPath := filepath . Join ( baseCache , fmt . Sprint ( u . Ver ) , " " ) mom , err := swupd . ParseManifestFile ( momPath ) if err != nil { return nil , err } sort . Slice ( mom . Files , func ( i , j int ) bool { return mom . Files [ i ] . Name < mom . Files [ j ] . Name } ) for i := 0 ; i < bundleWorkers ; i ++ { go func ( ) { defer wg . Done ( ) for m := range mChan { err = getSizes ( u , m , mom , bundleSizes , bundlePath ) if err != nil { errChan <- err } } } ( ) } for _ , m := range manifests { select { case mChan <- m : case err = <- errChan : break } } close ( mChan ) wg . Wait ( ) chanLen := len ( errChan ) for i := 0 ; i < chanLen ; i ++ { <- errChan } return bundleSizes , err }
GetBundleSize gets the full size of all bundles in a given version
GetBundleSize gets the full size of all bundles in a given version
// Get the total size for each bundle (without accounting for overlap between them)