fix fetcher failing in file mode
1 file changed, 16 insertions(+), 16 deletions(-)
jump to
M internal/fetcher/fetcher.go → internal/fetcher/fetcher.go
@@ -181,15 +181,10 @@ if err != nil { f.log.Warn("could not get latest run ID, using fallback", "error", err) } - current, err := f.getCurrentVersion() - if err != nil { - f.log.Warn("could not get current version", "error", err) - } - - f.log.Debug("versions", "current", current, "latest", latest) + f.log.Debug("versions", "current", f.current, "latest", latest) defer f.cleanOldRevisionsAsync() - if latest > current { + if latest > f.current { err = f.getArtefacts(latest) if err != nil { return latest, errors.WithMessage(err, "could not fetch artefacts")@@ -198,7 +193,7 @@ return latest, nil } - return current, nil + return f.current, nil } func (f *Fetcher) Subscribe() (<-chan string, error) {@@ -209,14 +204,19 @@ return nil, err } var root string - if f.options.RedisEnabled { - root = f.path("current") + f.current, err = f.getCurrentVersion() + if err != nil { + f.log.Warn("could not get current version", "error", err) + } + + if !f.options.RedisEnabled { + root = f.path(f.current) } else { runID, err := f.initialiseStorage() if err != nil { return nil, err } - root = f.path(strconv.FormatUint(runID, 10)) + root = f.path(runID) } updates, err := f.updater.Subscribe() if err != nil {@@ -228,13 +228,13 @@ ch <- root for update := range updates { if update.RunID == 0 { - if !f.options.RedisEnabled { + if f.options.RedisEnabled { f.log.Warn("got zero runID") continue } - ch <- f.path("current") + ch <- f.path(f.current) } else { err := f.getArtefacts(update.RunID) if err != nil {@@ -243,7 +243,7 @@ continue } - ch <- f.path(strconv.FormatUint(update.RunID, 10)) + ch <- f.path(update.RunID) } } }()@@ -251,6 +251,6 @@ return ch, nil } -func (f *Fetcher) path(runID string) string { - return filepath.Join(f.options.Root, runID) +func (f *Fetcher) path(runID uint64) string { + return filepath.Join(f.options.Root, strconv.FormatUint(runID, 10)) }