aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2023-12-25 12:20:50 +0100
committerPřemysl Eric Janouch <p@janouch.name>2023-12-25 12:20:50 +0100
commit91e9985fb977ed63345a657bc698157a3a8243a1 (patch)
treea0578c916df58064c612f3f3f0900a81d36a6099 /main.go
parentccf9aa8512e46261cca0df3e27f71904c22234d8 (diff)
downloadgallery-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.go12
1 files changed, 3 insertions, 9 deletions
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()