-
-
Notifications
You must be signed in to change notification settings - Fork 499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bugfix] Don't check for autosync on manual triggered sync (#3026) #3029
base: master
Are you sure you want to change the base?
Conversation
Additional Tests are needed to verify this bugfix. |
…3026) * [bugfix] Don't check for autosync on manual triggered sync Fixes gopasspw#3026 Signed-off-by: Ing. Thomas Mantl <thomas.mantl@redgears.net>
27bce73
to
e876920
Compare
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you're relying on the interactive context key in the end, instead of the newly added autosync one, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might mean to use
ctx = ctxutil.WithInteractive(ctx, true) | |
ctx = ctxutil.WithAutoSync(ctx, true) |
there, no?
|
||
// 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 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you really need these?
It looks like you're relying on the interactive context key above, instead of that newly added autosync one, no?
@@ -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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, you're setting the interactive key above, not the autosync one, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propably mixed something up. I need to take a look at it again.
I hope to include meaningful tests as well, as there are none for sync.
Fixes #3026