From 4218912123b81d60f950b916db98866b1dd1866b Mon Sep 17 00:00:00 2001 From: Elara Musayelyan Date: Wed, 11 Oct 2023 14:16:36 -0700 Subject: [PATCH] Fix issue where the git downloader re-downloads the source after updating it --- internal/dl/dl.go | 3 ++- internal/dl/git.go | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/internal/dl/dl.go b/internal/dl/dl.go index 354a3f4..6921ecd 100644 --- a/internal/dl/dl.go +++ b/internal/dl/dl.go @@ -209,9 +209,10 @@ func Download(ctx context.Context, opts Options) (err error) { } if ok && !updated { - log.Info("Source found in cache, linked to destination").Str("source", opts.Name).Stringer("type", t).Send() + log.Info("Source found in cache and linked to destination").Str("source", opts.Name).Stringer("type", t).Send() return nil } else if ok { + log.Info("Source updated and linked to destination").Str("source", opts.Name).Stringer("type", t).Send() return nil } } else { diff --git a/internal/dl/git.go b/internal/dl/git.go index f4b3adc..f07109b 100644 --- a/internal/dl/git.go +++ b/internal/dl/git.go @@ -177,6 +177,9 @@ func (GitDownloader) Update(opts Options) (bool, error) { po.RecurseSubmodules = git.DefaultSubmoduleRecursionDepth } + m, err := getManifest(opts.Destination) + manifestOK := err == nil + err = w.Pull(po) if errors.Is(err, git.NoErrAlreadyUpToDate) { return false, nil @@ -184,5 +187,12 @@ func (GitDownloader) Update(opts Options) (bool, error) { return false, err } + if manifestOK { + err = writeManifest(opts.Destination, m) + if err != nil { + return true, err + } + } + return true, nil }