Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
36a4ba32
Commit
36a4ba32
authored
May 18, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add user confirmation for removedb
parent
fe41bd6f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
5 deletions
+40
-5
main.go
cmd/geth/main.go
+40
-5
No files found.
cmd/geth/main.go
View file @
36a4ba32
...
...
@@ -549,6 +549,12 @@ func exportchain(ctx *cli.Context) {
}
func
removeDb
(
ctx
*
cli
.
Context
)
{
confirm
,
err
:=
readConfirm
(
"Remove local databases?"
)
if
err
!=
nil
{
utils
.
Fatalf
(
"%v"
,
err
)
}
if
confirm
{
fmt
.
Println
(
"Removing chain and state databases..."
)
start
:=
time
.
Now
()
...
...
@@ -556,6 +562,9 @@ func removeDb(ctx *cli.Context) {
os
.
RemoveAll
(
filepath
.
Join
(
ctx
.
GlobalString
(
utils
.
DataDirFlag
.
Name
),
"state"
))
fmt
.
Printf
(
"Removed in %v
\n
"
,
time
.
Since
(
start
))
}
else
{
fmt
.
Println
(
"Operation aborted"
)
}
}
func
upgradeDb
(
ctx
*
cli
.
Context
)
{
...
...
@@ -682,6 +691,32 @@ func hashish(x string) bool {
return
err
!=
nil
}
func
readConfirm
(
prompt
string
)
(
bool
,
error
)
{
var
(
input
string
err
error
)
prompt
=
prompt
+
" [y/N] "
if
liner
.
TerminalSupported
()
{
lr
:=
liner
.
NewLiner
()
defer
lr
.
Close
()
input
,
err
=
lr
.
Prompt
(
prompt
)
}
else
{
fmt
.
Print
(
prompt
)
input
,
err
=
bufio
.
NewReader
(
os
.
Stdin
)
.
ReadString
(
'\n'
)
fmt
.
Println
()
}
if
len
(
input
)
>
0
&&
strings
.
ToUpper
(
input
[
:
1
])
==
"Y"
{
return
true
,
nil
}
else
{
return
false
,
nil
}
return
false
,
err
}
func
readPassword
(
prompt
string
,
warnTerm
bool
)
(
string
,
error
)
{
if
liner
.
TerminalSupported
()
{
lr
:=
liner
.
NewLiner
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment