Skip to content

Commit

Permalink
feat: deprecate ipfs repo fsck command
Browse files Browse the repository at this point in the history
This command is no longer necessary and is quite dangerous:

1. All lockfiles are now released by the OS when the daemon stops.
2. The API file is ignored when (a) the repo is initialized and (b) daemon is
off.

fixes #6435
  • Loading branch information
Stebalien committed Jul 3, 2019
1 parent e96416d commit 288a83c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 227 deletions.
39 changes: 2 additions & 37 deletions core/commands/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"io"
"os"
"path/filepath"
"runtime"
"strings"
"sync"
Expand All @@ -20,7 +19,6 @@ import (
cid "github.com/ipfs/go-cid"
bstore "github.com/ipfs/go-ipfs-blockstore"
cmds "github.com/ipfs/go-ipfs-cmds"
config "github.com/ipfs/go-ipfs-config"
)

type RepoVersion struct {
Expand Down Expand Up @@ -216,44 +214,11 @@ var repoFsckCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Remove repo lockfiles.",
ShortDescription: `
'ipfs repo fsck' is a plumbing command that will remove repo and level db
lockfiles, as well as the api file. This command can only run when no ipfs
daemons are running.
'ipfs repo fsck' is now a no-op.
`,
},
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
configRoot, err := cmdenv.GetConfigRoot(env)
if err != nil {
return err
}

dsPath, err := config.DataStorePath(configRoot)
if err != nil {
return err
}

dsLockFile := filepath.Join(dsPath, "LOCK") // TODO: get this lockfile programmatically
repoLockFile := filepath.Join(configRoot, fsrepo.LockFile)
apiFile := filepath.Join(configRoot, "api") // TODO: get this programmatically

log.Infof("Removing repo lockfile: %s", repoLockFile)
log.Infof("Removing datastore lockfile: %s", dsLockFile)
log.Infof("Removing api file: %s", apiFile)

err = os.Remove(repoLockFile)
if err != nil && !os.IsNotExist(err) {
return err
}
err = os.Remove(dsLockFile)
if err != nil && !os.IsNotExist(err) {
return err
}
err = os.Remove(apiFile)
if err != nil && !os.IsNotExist(err) {
return err
}

return cmds.EmitOnce(res, &MessageOutput{"Lockfiles have been removed.\n"})
return cmds.EmitOnce(res, &MessageOutput{"`ipfs repo fsck` is deprecated and does nothing.\n"})
},
Type: MessageOutput{},
Encoders: cmds.EncoderMap{
Expand Down
190 changes: 0 additions & 190 deletions test/sharness/t0083-repo-fsck.sh

This file was deleted.

0 comments on commit 288a83c

Please sign in to comment.