From 7b86de2736c8b68e158533ef934efc54e239ad39 Mon Sep 17 00:00:00 2001 From: Paul Gellai Date: Wed, 30 Oct 2024 00:09:28 -0700 Subject: [PATCH] function --- pkg/actions/download.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pkg/actions/download.go b/pkg/actions/download.go index 68ace91..9f929b5 100644 --- a/pkg/actions/download.go +++ b/pkg/actions/download.go @@ -53,6 +53,17 @@ func Download(c *cli.Context) error { return err } } + + err = checkForDeletedKeys(data.Keys, directory) + + if err != nil { + return err + } + fmt.Println("Successfully downloaded keys.") + return nil +} + +func checkForDeletedKeys(keys []dto.KeyDto, directory string) error { sshDir, err := utils.GetAndCreateSshDirectory(directory) if err != nil { return err @@ -67,7 +78,7 @@ func Download(c *cli.Context) error { if d.Name() == "config" { return nil } - _, exists := lo.Find(data.Keys, func(key dto.KeyDto) bool { + _, exists := lo.Find(keys, func(key dto.KeyDto) bool { return key.Filename == d.Name() }) if exists { @@ -89,7 +100,5 @@ func Download(c *cli.Context) error { if err != nil { return err } - - fmt.Println("Successfully downloaded keys.") return nil }