From 91e9985fb977ed63345a657bc698157a3a8243a1 Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch Date: Mon, 25 Dec 2023 12:20:50 +0100 Subject: Give sync Tx a real context --- main.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 811a2c6..ac2d894 100644 --- a/main.go +++ b/main.go @@ -1829,9 +1829,8 @@ func cmdSync(args []string) error { return err } - // TODO: See if the SQLite can cancel anything in a useful manner. - // If using this, beware that a cancel prevents commiting transactions. - ctx := context.Background() + ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt) + defer stop() // In case of a failure during processing, the only retained side effects // on the filesystem tree are: @@ -1850,11 +1849,6 @@ func cmdSync(args []string) error { return err } - // XXX: By not using the context for the transaction, - // interrupts can get ignored around the Commit. - ctxSignal, stop := signal.NotifyContext(ctx, os.Interrupt) - defer stop() - // Normalize arguments. // At least for now, turn all roots into absolute paths. roots := args[1:] @@ -1875,7 +1869,7 @@ func cmdSync(args []string) error { return true }) - if err := syncRun(ctxSignal, tx, roots); err != nil { + if err := syncRun(ctx, tx, roots); err != nil { return err } return tx.Commit() -- cgit v1.2.3-70-g09d2