Aftering importing a previously deleted key, be able to delete it again.

Co-authored-by: Aayush Rajasekaran <arajasek94@gmail.com>
This commit is contained in:
jennijuju
2021-03-09 16:43:01 +01:00
committed by Łukasz Magiera
co-authored by Aayush Rajasekaran
parent 1c62d7a40f
commit 49c44b70c2
+5 -1
View File
@@ -28,6 +28,7 @@ import (
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/wallet"
"github.com/filecoin-project/lotus/node/config"
)
@@ -555,7 +556,10 @@ func (fsr *fsLockedRepo) Put(name string, info types.KeyInfo) error {
keyPath := fsr.join(fsKeystore, encName)
_, err := os.Stat(keyPath)
if err == nil {
if err == nil && strings.HasPrefix(name, wallet.KTrashPrefix) {
// Fine to try to write the same trash-prefixed file multiple times
return nil
} else if err == nil {
return xerrors.Errorf("checking key before put '%s': %w", name, types.ErrKeyExists)
} else if !os.IsNotExist(err) {
return xerrors.Errorf("checking key before put '%s': %w", name, err)