From e876920e7437b892dfea63bdf378be6bb5570d72 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 | 9 ++++++--- pkg/ctxutil/ctxutil.go | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/internal/action/sync.go b/internal/action/sync.go index fe6252b767..0078ff6372 100644 --- a/internal/action/sync.go +++ b/internal/action/sync.go @@ -85,6 +85,7 @@ 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() @@ -161,10 +162,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 ctxutil.HasAutoSync(ctx) { + 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..f433f014fa 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,18 @@ 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) +} + +// HasAutoSync returns true if syncs are triggered by autosync. +func HasAutoSync(ctx context.Context) bool { + bv, ok := ctx.Value(ctxKeyAutoSync).(bool) + if !ok { + return false + } + + return bv +}