From c131adc02b47ea02b97b2e16e1a4259701e0c536 Mon Sep 17 00:00:00 2001 From: Brian McGee Date: Sat, 14 Sep 2024 22:48:18 +0100 Subject: [PATCH] feat: add connect timeout to bolt db Closes #406 Signed-off-by: Brian McGee --- cache/cache.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cache/cache.go b/cache/cache.go index fe1c1ac2..46496007 100644 --- a/cache/cache.go +++ b/cache/cache.go @@ -58,7 +58,8 @@ func Open(treeRoot string, clean bool, formatters map[string]*format.Formatter) return fmt.Errorf("could not resolve local path for the cache: %w", err) } - db, err = bolt.Open(path, 0o600, nil) + // attempt to open the db, but timeout after 1 second + db, err = bolt.Open(path, 0o600, &bolt.Options{Timeout: 1 * time.Second}) if err != nil { return fmt.Errorf("failed to open cache at %v: %w", path, err) }