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 Jun 29, 2019
1 parent e96416d commit a155bf7
Show file tree
Hide file tree
Showing 3 changed files with 3 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
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ require (
go4.org v0.0.0-20190313082347-94abd6928b1d // indirect
golang.org/x/sync v0.0.0-20190423024810-112230192c58 // indirect
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb
google.golang.org/appengine v1.4.0 // indirect
gopkg.in/cheggaaa/pb.v1 v1.0.28
gotest.tools/gotestsum v0.3.4
)
Expand Down
190 changes: 0 additions & 190 deletions test/sharness/t0083-repo-fsck.sh

This file was deleted.

0 comments on commit a155bf7

Please sign in to comment.