[#1415] lens/explorer: Add timeout for opening database
All checks were successful
DCO action / DCO (pull_request) Successful in 1m14s
Tests and linters / Run gofumpt (pull_request) Successful in 1m21s
Vulncheck / Vulncheck (pull_request) Successful in 2m6s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m22s
Build / Build Components (pull_request) Successful in 2m32s
Tests and linters / Staticcheck (pull_request) Successful in 2m50s
Tests and linters / gopls check (pull_request) Successful in 2m50s
Tests and linters / Lint (pull_request) Successful in 3m24s
Tests and linters / Tests (pull_request) Successful in 4m27s
Tests and linters / Tests with -race (pull_request) Successful in 6m2s

Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
This commit is contained in:
Aleksey Savchuk 2024-10-07 18:32:26 +03:00
parent 5fbb2657ca
commit 0c49bca19c
4 changed files with 16 additions and 36 deletions

View file

@ -3,12 +3,25 @@ package tui
import (
"errors"
"strings"
"time"
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
"github.com/mr-tron/base58"
"go.etcd.io/bbolt"
)
func OpenDB(path string, writable bool) (*bbolt.DB, error) {
db, err := bbolt.Open(path, 0o600, &bbolt.Options{
ReadOnly: !writable,
Timeout: 100 * time.Millisecond,
})
if err != nil {
return nil, err
}
return db, nil
}
func CIDParser(s string) (any, error) {
data, err := base58.Decode(s)
if err != nil {