diff --git a/Makefile b/Makefile index 1ba26e4..ed73ede 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ NAME ?= auger PKG ?= github.com/etcd-io/$(NAME) -GO_VERSION ?= 1.23.2 +GO_VERSION ?= 1.23.3 GOOS ?= linux GOARCH ?= amd64 TEMP_DIR := $(shell mktemp -d) diff --git a/go.mod b/go.mod index d3612b8..2dadd03 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module github.com/etcd-io/auger go 1.23 -toolchain go1.23.2 +toolchain go1.23.3 require ( github.com/google/safetext v0.0.0-20220914124124-e18e3fe012bf diff --git a/pkg/data/data.go b/pkg/data/data.go index 62f0312..5527d88 100644 --- a/pkg/data/data.go +++ b/pkg/data/data.go @@ -22,6 +22,7 @@ import ( "encoding/json" "fmt" "hash/crc32" + "os" "sort" "strings" "text/template" @@ -151,7 +152,15 @@ type Checksum struct { CompactRevision int64 } +// boltOpen checks if the file exists and opens it in read-only mode. +// Returns an error if the file does not exist. func boltOpen(path string) (*bolt.DB, error) { + // Check if the file exists + if _, err := os.Stat(path); os.IsNotExist(err) { + return nil, fmt.Errorf("file does not exist: %s", path) + } + + // Open the file in read-only mode return bolt.Open(path, 0400, &bolt.Options{ ReadOnly: true, })