diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2023-12-25 12:20:50 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2023-12-25 12:20:50 +0100 |
commit | 91e9985fb977ed63345a657bc698157a3a8243a1 (patch) | |
tree | a0578c916df58064c612f3f3f0900a81d36a6099 /main.go | |
parent | ccf9aa8512e46261cca0df3e27f71904c22234d8 (diff) | |
download | gallery-91e9985fb977ed63345a657bc698157a3a8243a1.tar.gz gallery-91e9985fb977ed63345a657bc698157a3a8243a1.tar.xz gallery-91e9985fb977ed63345a657bc698157a3a8243a1.zip |
Give sync Tx a real context
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 12 |
1 files changed, 3 insertions, 9 deletions
@@ -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() |