diff --git a/cmd/lotus-miner/storage.go b/cmd/lotus-miner/storage.go index 761f070f0..fdd5b5696 100644 --- a/cmd/lotus-miner/storage.go +++ b/cmd/lotus-miner/storage.go @@ -225,6 +225,7 @@ var storageRedeclareCmd = &cli.Command{ &cli.BoolFlag{ Name: "drop-missing", Usage: "Drop index entries with missing files", + Value: true, }, }, Action: func(cctx *cli.Context) error { @@ -264,13 +265,17 @@ var storageRedeclareCmd = &cli.Command{ var meta storiface.LocalStorageMeta metaFile, err := os.Open(metaFilePath) if err != nil { - return xerrors.Errorf("Failed to open meta file: %w", err) + return xerrors.Errorf("Failed to open file: %w", err) } - defer metaFile.Close() + defer func() { + if closeErr := metaFile.Close(); closeErr != nil { + log.Error("Failed to close the file: %v", closeErr) + } + }() err = json.NewDecoder(metaFile).Decode(&meta) if err != nil { - return xerrors.Errorf("Failed to decode meta file: %w", err) + return xerrors.Errorf("Failed to decode file: %w", err) } id := meta.ID diff --git a/documentation/en/cli-lotus-miner.md b/documentation/en/cli-lotus-miner.md index 7c646a3b4..1446a36a9 100644 --- a/documentation/en/cli-lotus-miner.md +++ b/documentation/en/cli-lotus-miner.md @@ -1285,7 +1285,7 @@ USAGE: OPTIONS: --all redeclare all storage paths (default: false) - --drop-missing Drop index entries with missing files (default: false) + --drop-missing Drop index entries with missing files (default: true) --id value storage path ID ```