Skip to content

Commit

Permalink
used checkSourceDBPath func
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy shem committed Nov 18, 2024
1 parent f7987c0 commit 0c84aa2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions cmd/bbolt/command_buckets.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"fmt"
"os"

"github.com/spf13/cobra"
bolt "go.etcd.io/bbolt"
Expand All @@ -20,17 +19,17 @@ func newBucketsCommand() *cobra.Command {
return bucketsCmd
}

func bucketsFunc(cmd *cobra.Command, path string) error {
func bucketsFunc(cmd *cobra.Command, srcDBPath string) error {
// Required database path.
if path == "" {
if srcDBPath == "" {
return ErrPathRequired
// Verify if the specified database file exists.
} else if _, err := os.Stat(path); os.IsNotExist(err) {
return ErrFileNotFound
} else if _, err := checkSourceDBPath(srcDBPath); err != nil {
return err
}

// Open database.
db, err := bolt.Open(path, 0600, &bolt.Options{ReadOnly: true})
db, err := bolt.Open(srcDBPath, 0600, &bolt.Options{ReadOnly: true})
if err != nil {
return err
}
Expand Down

0 comments on commit 0c84aa2

Please sign in to comment.