Browse Source

Don't export the config repo structure

pull/8/head
Daniel Martí 11 years ago
parent
commit
96add147b9
  1. 8
      cmd/fdroidcl/main.go
  2. 14
      cmd/fdroidcl/update.go

8
cmd/fdroidcl/main.go

@ -47,17 +47,17 @@ func configPath() string {
return filepath.Join(mustConfig(), "config.json")
}
type Repo struct {
type repo struct {
ID string `json:"id"`
URL string `json:"url"`
}
type userConfig struct {
Repos []Repo `json:"repos"`
Repos []repo `json:"repos"`
}
var config = userConfig{
Repos: []Repo{
Repos: []repo{
{
ID: "f-droid",
URL: "https://f-droid.org/repo",
@ -80,7 +80,7 @@ func readConfig() error {
return nil
}
func mustOneRepo() *Repo {
func mustOneRepo() *repo {
if len(config.Repos) != 1 {
log.Fatalf("Exactly one repo is needed")
}

14
cmd/fdroidcl/update.go

@ -28,15 +28,15 @@ func init() {
}
func runUpdate(args []string) {
if err := updateIndex(); err != nil {
r := mustOneRepo()
if err := updateRepo(r); err != nil {
log.Fatalf("Could not update index: %v", err)
}
}
func updateIndex() error {
repo := mustOneRepo()
url := fmt.Sprintf("%s/%s", repo.URL, "index.jar")
if err := downloadEtag(url, indexPath(repo.ID), nil); err != nil {
func updateRepo(r *repo) error {
url := fmt.Sprintf("%s/%s", r.URL, "index.jar")
if err := downloadEtag(url, indexPath(r.ID), nil); err != nil {
return err
}
return nil
@ -106,8 +106,8 @@ func indexPath(name string) string {
}
func mustLoadIndex() *fdroidcl.Index {
repo := mustOneRepo()
p := indexPath(repo.ID)
r := mustOneRepo()
p := indexPath(r.ID)
f, err := os.Open(p)
if err != nil {
log.Fatalf("Could not open index file: %v", err)

Loading…
Cancel
Save