From 24469f2886f6df1480a936a9c39b1f1ab885f8aa Mon Sep 17 00:00:00 2001 From: shawn Date: Mon, 25 Sep 2023 11:25:45 +0800 Subject: [PATCH] fix: backup should run in offline mode --- core/commands/backup.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/commands/backup.go b/core/commands/backup.go index 1de94bf16..340a0f5e1 100644 --- a/core/commands/backup.go +++ b/core/commands/backup.go @@ -14,6 +14,7 @@ import ( cmds "github.com/bittorrent/go-btfs-cmds" commands "github.com/bittorrent/go-btfs/commands" + "github.com/bittorrent/go-btfs/core/commands/cmdenv" fsrepo "github.com/bittorrent/go-btfs/repo/fsrepo" ) @@ -40,6 +41,14 @@ This command will create a backup of the data from the current BTFS node. cmds.StringsOption(excludeOption, "exclude backup output file path"), }, Run: func(req *cmds.Request, resp cmds.ResponseEmitter, env cmds.Environment) error { + nd, err := cmdenv.GetNode(env) + if err != nil { + return err + } + + if nd.IsOnline { + return errors.New("this action must be run in offline mode, please stop your 'btfs daemon' first") + } r, err := fsrepo.Open(env.(*commands.Context).ConfigRoot) if err != nil { return err