Browse Source

Remove *App from Apk type

This circular data flow was preventing serialization, useful for caching
into disk.
pull/16/head
Daniel Martí 10 years ago
parent
commit
34a8ab8a73
  1. 2
      cmd/fdroidcl/download.go
  2. 4
      cmd/fdroidcl/install.go
  3. 4
      cmd/fdroidcl/upgrade.go
  4. 14
      index.go

2
cmd/fdroidcl/download.go

@ -40,7 +40,7 @@ func downloadApk(apk *fdroidcl.Apk) string {
url := apk.URL()
path := apkPath(apk.ApkName)
if err := downloadEtag(url, path, apk.Hash.Data); err != nil {
log.Fatalf("Could not download %s: %v", apk.App.ID, err)
log.Fatalf("Could not download %s: %v", apk.AppID, err)
}
return path
}

4
cmd/fdroidcl/install.go

@ -55,10 +55,10 @@ func downloadAndDo(apps []*fdroidcl.App, device *adb.Device, doApk func(*adb.Dev
}
func installApk(device *adb.Device, apk *fdroidcl.Apk, path string) {
fmt.Printf("Installing %s... ", apk.App.ID)
fmt.Printf("Installing %s... ", apk.AppID)
if err := device.Install(path); err != nil {
fmt.Println()
log.Fatalf("Could not install %s: %v", apk.App.ID, err)
log.Fatalf("Could not install %s: %v", apk.AppID, err)
}
fmt.Println("done")
}

4
cmd/fdroidcl/upgrade.go

@ -44,10 +44,10 @@ func runUpgrade(args []string) {
}
func upgradeApk(device *adb.Device, apk *fdroidcl.Apk, path string) {
fmt.Printf("Upgrading %s... ", apk.App.ID)
fmt.Printf("Upgrading %s... ", apk.AppID)
if err := device.Upgrade(path); err != nil {
fmt.Println()
log.Fatalf("Could not upgrade %s: %v", apk.App.ID, err)
log.Fatalf("Could not upgrade %s: %v", apk.AppID, err)
}
fmt.Println("done")
}

14
index.go

@ -86,7 +86,7 @@ func (a *App) IconURLForDensity(density IconDensity) string {
if len(a.Apks) == 0 {
return ""
}
return fmt.Sprintf("%s/%s/%s", a.Apks[0].Repo.URL,
return fmt.Sprintf("%s/%s/%s", a.Apks[0].repo.URL,
getIconsDir(density), a.Icon)
}
@ -195,16 +195,16 @@ type Apk struct {
Feats CommaList `xml:"features"`
Hash HexHash `xml:"hash"`
App *App `xml:"-"`
Repo *Repo `xml:"-"`
AppID string `xml:"-"`
repo *Repo `xml:"-"`
}
func (a *Apk) URL() string {
return fmt.Sprintf("%s/%s", a.Repo.URL, a.ApkName)
return fmt.Sprintf("%s/%s", a.repo.URL, a.ApkName)
}
func (a *Apk) SrcURL() string {
return fmt.Sprintf("%s/%s", a.Repo.URL, a.SrcName)
return fmt.Sprintf("%s/%s", a.repo.URL, a.SrcName)
}
func (a *Apk) IsCompatibleABI(ABIs []string) bool {
@ -259,8 +259,8 @@ func LoadIndexXML(r io.Reader) (*Index, error) {
sort.Sort(ApkList(app.Apks))
for j := range app.Apks {
apk := &app.Apks[j]
apk.App = app
apk.Repo = &index.Repo
apk.AppID = app.ID
apk.repo = &index.Repo
}
}
return &index, nil

Loading…
Cancel
Save