Skip to content
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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TM2500
Copy link
Contributor

@TM2500 TM2500 commented Jan 6, 2025

  • [bugfix] Don't check for autosync on manual triggered sync

Fixes #3026

@TM2500
Copy link
Contributor Author

TM2500 commented Jan 6, 2025

Additional Tests are needed to verify this bugfix.
As soon as they are created, the draft state is removed from the PR.

…3026)

* [bugfix] Don't check for autosync on manual triggered sync

Fixes gopasspw#3026

Signed-off-by: Ing. Thomas Mantl <thomas.mantl@redgears.net>
@TM2500 TM2500 force-pushed the 3026-autosync-disables-sync branch from 27bce73 to e876920 Compare January 6, 2025 14:13
@@ -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)
Copy link
Member

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?

Copy link
Member

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

Suggested change
ctx = ctxutil.WithInteractive(ctx, true)
ctx = ctxutil.WithAutoSync(ctx, true)

there, no?

Comment on lines +493 to +507

// 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
}
Copy link
Member

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) {
Copy link
Member

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?

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

autosync = false breaks manual sync
2 participants