Fail Immediately if Importing Accounts from Empty Directory (#6915)

* fail on import from empty directory
* Merge refs/heads/master into fail-on-empty-dir
This commit is contained in:
Raul Jordan 2020-08-06 17:40:14 -05:00 committed by GitHub
parent 96fcb3a927
commit 6b4e4bcf96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -74,6 +74,9 @@ func ImportAccount(cliCtx *cli.Context) error {
if err != nil { if err != nil {
return errors.Wrap(err, "could not read dir") return errors.Wrap(err, "could not read dir")
} }
if len(files) == 0 {
return fmt.Errorf("directory %s has no files, cannot import from it", keysDir)
}
for i := 0; i < len(files); i++ { for i := 0; i < len(files); i++ {
if files[i].IsDir() { if files[i].IsDir() {
continue continue