Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion badger/cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ type flagOptions struct {
itemMeta bool
keyHistory bool
showInternal bool
readOnly bool
truncate bool
}

var (
Expand All @@ -67,6 +69,11 @@ func init() {
infoCmd.Flags().BoolVar(
&opt.showInternal, "show-internal", false, "Show internal keys along with other keys."+
" This option should be used along with --show-key option")
infoCmd.Flags().BoolVar(&opt.readOnly, "read-only", true, "If set to true, DB will be opened "+
"in read only mode. If DB has not been closed properly, this option can be set to false "+
"to open DB.")
infoCmd.Flags().BoolVar(&opt.truncate, "truncate", false, "If set to true, it allows "+
"truncation of value log files if they have corrupt data.")
}

var infoCmd = &cobra.Command{
Expand All @@ -89,7 +96,8 @@ func handleInfo(cmd *cobra.Command, args []string) error {
// Open DB
db, err := badger.Open(badger.DefaultOptions(sstDir).
WithValueDir(vlogDir).
WithReadOnly(true).
WithReadOnly(opt.readOnly).
WithTruncate(opt.truncate).
WithTableLoadingMode(options.MemoryMap))
if err != nil {
return errors.Wrap(err, "failed to open database")
Expand Down