From 4dd8a44ff152c8bb891d6a0cf5ed582c117015af Mon Sep 17 00:00:00 2001 From: Sam Coe Date: Mon, 12 Apr 2021 16:27:51 -0700 Subject: [PATCH] make run log cache key unique --- pkg/cmd/run/view/view.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/cmd/run/view/view.go b/pkg/cmd/run/view/view.go index 01fc8b3ab..cd7f54e6e 100644 --- a/pkg/cmd/run/view/view.go +++ b/pkg/cmd/run/view/view.go @@ -256,7 +256,7 @@ func runView(opts *ViewOptions) error { } opts.IO.StartProgressIndicator() - runLogZip, err := getRunLog(opts.RunLogCache, httpClient, repo, run.ID) + runLogZip, err := getRunLog(opts.RunLogCache, httpClient, repo, run) opts.IO.StopProgressIndicator() if err != nil { return fmt.Errorf("failed to get run log: %w", err) @@ -408,13 +408,13 @@ func getLog(httpClient *http.Client, logURL string) (io.ReadCloser, error) { return resp.Body, nil } -func getRunLog(cache runLogCache, httpClient *http.Client, repo ghrepo.Interface, runID int) (*zip.ReadCloser, error) { - filename := fmt.Sprintf("run-log-%d.zip", runID) +func getRunLog(cache runLogCache, httpClient *http.Client, repo ghrepo.Interface, run *shared.Run) (*zip.ReadCloser, error) { + filename := fmt.Sprintf("run-log-%d-%d.zip", run.ID, run.CreatedAt.Unix()) filepath := filepath.Join(os.TempDir(), "gh-cli-cache", filename) if !cache.Exists(filepath) { // Run log does not exist in cache so retrieve and store it logURL := fmt.Sprintf("%srepos/%s/actions/runs/%d/logs", - ghinstance.RESTPrefix(repo.RepoHost()), ghrepo.FullName(repo), runID) + ghinstance.RESTPrefix(repo.RepoHost()), ghrepo.FullName(repo), run.ID) resp, err := getLog(httpClient, logURL) if err != nil {