From 27bce736a5bba97555088617945cd7a71c610553 Mon Sep 17 00:00:00 2001 From: "Ing. Thomas Mantl" Date: Mon, 6 Jan 2025 14:32:22 +0100 Subject: [PATCH] [bugfix] Don't check for autosync on manual triggered sync (#3026) * [bugfix] Don't check for autosync on manual triggered sync Fixes #3026 Signed-off-by: Ing. Thomas Mantl --- internal/action/sync.go | 10 +++++++--- pkg/ctxutil/ctxutil.go | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/internal/action/sync.go b/internal/action/sync.go index fe6252b767..9a4540b601 100644 --- a/internal/action/sync.go +++ b/internal/action/sync.go @@ -85,11 +85,13 @@ func (s *Action) autoSync(ctx context.Context) error { debug.Log("autosync - interval: %s", syncInterval) if time.Since(ls) > syncInterval { + ctx = ctxutil.WithInteractive(ctx, true) err := s.sync(ctx, "") if err != nil { autosyncLastRun = time.Now() } + ctx = ctxutil.WithAutoSync(ctx, false) return err } @@ -161,10 +163,12 @@ func (s *Action) sync(ctx context.Context, store string) error { func (s *Action) syncMount(ctx context.Context, mp string) error { // using GetM here to get the value for this mount, it might be different // than the global value - if as := s.cfg.GetM(mp, "core.autosync"); as == "false" { - debug.Log("not syncing %s, autosync is disabled for this mount", mp) + if as_ctx := ctxutil.HasAutoSync(ctx); as_ctx == true { + if as := s.cfg.GetM(mp, "core.autosync"); as == "false" { + debug.Log("not syncing %s, autosync is disabled for this mount", mp) - return nil + return nil + } } ctxno := out.WithNewline(ctx, false) diff --git a/pkg/ctxutil/ctxutil.go b/pkg/ctxutil/ctxutil.go index 5208209125..cbd65c1d56 100644 --- a/pkg/ctxutil/ctxutil.go +++ b/pkg/ctxutil/ctxutil.go @@ -31,6 +31,7 @@ const ( ctxKeyCommitTimestamp ctxKeyShowParsing ctxKeyHidden + ctxKeyAutoSync ) // ErrNoCallback is returned when no callback is set in the context. @@ -489,3 +490,17 @@ func IsHidden(ctx context.Context) bool { return bv } + +// WithAutoSync returns a context with the autosync flag set +func WithAutoSync(ctx context.Context, autosync bool) context.Context { + return context.WithValue(ctx, ctxKeyAutoSync, autosync) +} + +func HasAutoSync(ctx context.Context) bool { + bv, ok := ctx.Value(ctxKeyAutoSync).(bool) + if !ok { + return false + } + + return bv +}