1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-10 05:52:20 +08:00

commands: repo fsck (#2597)

* Adds repo fsck subcommand

Fixes #2457

License: MIT
Signed-off-by: Mike Pfister <pfista@gmail.com>

* Checks for error on file deletion

License: MIT
Signed-off-by: Mike Pfister <pfista@gmail.com>

* Checks if node is online

License: MIT
Signed-off-by: Mike Pfister <pfista@gmail.com>

* Update error checking

License: MIT
Signed-off-by: Michael Pfister <pfista@gmail.com>

* Prevents command from running while daemon is running

License: MIT
Signed-off-by: Michael Pfister <pfista@gmail.com>

* Add newline to command output message

License: MIT
Signed-off-by: Michael Pfister <pfista@gmail.com>

* removing superfluous error

License: MIT
Signed-off-by: Michael Pfister <pfista@gmail.com>

* Adds sharness test for repo fsck command

License: MIT
Signed-off-by: Michael Pfister <pfista@gmail.com>

* Ignore warning if file doesn't exist

License: MIT
Signed-off-by: Michael Pfister <pfista@gmail.com>

* Updating message output

License: MIT
Signed-off-by: Michael Pfister <pfista@gmail.com>

* adding debug statements

License: MIT
Signed-off-by: Michael Pfister <pfista@gmail.com>

* update and add fsck sharness tests

License: MIT
Signed-off-by: Michael Pfister <pfista@gmail.com>

* updating comments

License: MIT
Signed-off-by: Michael Pfister <pfista@gmail.com>

* Use printf in test

Using printf prevents a newline from being printed to the api test file. When
the newline was present, multiaddr threw errors  trying to parse the api address
to an integer since the newline character was present.

License: MIT
Signed-off-by: Michael Pfister <pfista@gmail.com>

* updating tests

License: MIT
Signed-off-by: Michael Pfister <pfista@gmail.com>

* removing commented code

License: MIT
Signed-off-by: Michael Pfister <pfista@gmail.com>
This commit is contained in:
michael
2016-04-27 13:28:53 -07:00
committed by Jeromy Johnson
parent 973266ae11
commit 46bcdce15d
7 changed files with 268 additions and 5 deletions

View File

@ -51,6 +51,7 @@ at ~/.ipfs. To change the repo location, set the $IPFS_PATH environment variable
log.Info("checking if daemon is running...")
if daemonLocked {
log.Debug("Ipfs daemon is running.")
e := "ipfs daemon is running. please stop it to run this command"
return cmds.ClientError(e)
}

View File

@ -105,4 +105,5 @@ var cmdDetailsMap = map[*cmds.Command]cmdDetails{
commands.CommandsDaemonCmd: {doesNotUseRepo: true},
commands.VersionCmd: {doesNotUseConfigAsInput: true, doesNotUseRepo: true}, // must be permitted to run before init
commands.LogCmd: {cannotRunOnClient: true},
commands.RepoFsckCmd: {cannotRunOnDaemon: true},
}

View File

@ -417,9 +417,10 @@ func commandShouldRunOnDaemon(details cmdDetails, req cmds.Request, root *cmds.C
return nil, err
}
if client != nil { // api file exists
if client != nil {
if details.cannotRunOnDaemon {
// check if daemon locked. legacy error text, for now.
log.Debugf("Command cannot run on daemon. Checking if daemon is locked")
if daemonLocked, _ := fsrepo.LockedByOtherProcess(req.InvocContext().ConfigRoot); daemonLocked {
return nil, cmds.ClientError("ipfs daemon is running. please stop it to run this command")
}