mirror of https://github.com/mvdan/fdroidcl.git
4 changed files with 42 additions and 6 deletions
@ -0,0 +1,40 @@
|
||||
// Copyright (c) 2015, Daniel Martí <mvdan@mvdan.cc>
|
||||
// See LICENSE for licensing information
|
||||
|
||||
package main |
||||
|
||||
import ( |
||||
"fmt" |
||||
"log" |
||||
"path/filepath" |
||||
) |
||||
|
||||
var cmdDownload = &Command{ |
||||
UsageLine: "download <appid...>", |
||||
Short: "Download an app", |
||||
} |
||||
|
||||
func init() { |
||||
cmdDownload.Run = runDownload |
||||
} |
||||
|
||||
func runDownload(args []string) { |
||||
if len(args) < 1 { |
||||
log.Fatalf("No package names given") |
||||
} |
||||
apps := findApps(args) |
||||
for _, app := range apps { |
||||
apk := app.CurApk |
||||
url := fmt.Sprintf("%s/%s", apk.Repo.URL, apk.ApkName) |
||||
path := apkPath(apk.ApkName) |
||||
if err := downloadEtag(url, path, apk.Hash.Data); err != nil { |
||||
log.Fatalf("Could not download '%s': %v", app.ID, err) |
||||
} |
||||
fmt.Printf("APK available in %s\n", path) |
||||
} |
||||
} |
||||
|
||||
func apkPath(apkname string) string { |
||||
apksDir := subdir(mustCache(), "apks") |
||||
return filepath.Join(apksDir, apkname) |
||||
} |
||||
Loading…
Reference in new issue