(key string, versions []string)
| 18 | } |
| 19 | |
| 20 | func SaveRepoData(key string, versions []string) { |
| 21 | location := env.GetCacheDir() |
| 22 | data := &RepoInfo{} |
| 23 | data.Key = key |
| 24 | data.LastUpdate = time.Now() |
| 25 | data.Versions = versions |
| 26 | d, err := json.Marshal(data) |
| 27 | if err != nil { |
| 28 | msg.Err(err.Error()) |
| 29 | } |
| 30 | |
| 31 | pp := filepath.Join(location, "info") |
| 32 | err = os.MkdirAll(pp, 0755) |
| 33 | if err != nil { |
| 34 | msg.Err(err.Error()) |
| 35 | } |
| 36 | |
| 37 | p := filepath.Join(pp, key+".json") |
| 38 | f, err := os.Create(p) |
| 39 | if err != nil { |
| 40 | msg.Err(err.Error()) |
| 41 | return |
| 42 | } |
| 43 | defer f.Close() |
| 44 | |
| 45 | _, err = f.Write(d) |
| 46 | if err != nil { |
| 47 | msg.Err(err.Error()) |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | // RepoData retrieves cached information about a repo. |
| 52 | func RepoData(key string) (*RepoInfo, error) { |
no test coverage detected