From 34a8ab8a7341d019cc615ff8621aca5fa9ef0ecf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Thu, 8 Sep 2016 08:21:09 +0200 Subject: [PATCH] Remove *App from Apk type This circular data flow was preventing serialization, useful for caching into disk. --- cmd/fdroidcl/download.go | 2 +- cmd/fdroidcl/install.go | 4 ++-- cmd/fdroidcl/upgrade.go | 4 ++-- index.go | 14 +++++++------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cmd/fdroidcl/download.go b/cmd/fdroidcl/download.go index de59518..91dbf6e 100644 --- a/cmd/fdroidcl/download.go +++ b/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 } diff --git a/cmd/fdroidcl/install.go b/cmd/fdroidcl/install.go index 5dae09c..49ac11c 100644 --- a/cmd/fdroidcl/install.go +++ b/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") } diff --git a/cmd/fdroidcl/upgrade.go b/cmd/fdroidcl/upgrade.go index cf63fba..8442070 100644 --- a/cmd/fdroidcl/upgrade.go +++ b/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") } diff --git a/index.go b/index.go index 311bec9..fcce635 100644 --- a/index.go +++ b/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