Skip to content

Commit

Permalink
bugfix: Skip synchronization if IPs are up-to-date.
Browse files Browse the repository at this point in the history
  • Loading branch information
jharshman committed Jun 16, 2023
1 parent 8163144 commit 8aae6f9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func Update() *cobra.Command {

// Local variable shared between the closures.
var local *user.Config
var skipSync bool

return &cobra.Command{
Use: "update",
Expand All @@ -36,6 +37,7 @@ func Update() *cobra.Command {
currentIP, _ := user.PublicIP()
_, ipExists := cfg.HasIP(currentIP)
if ipExists {
skipSync = true
return nil
}

Expand All @@ -53,6 +55,10 @@ func Update() *cobra.Command {
return cfg.Write(f)
},
PostRunE: func(cmd *cobra.Command, args []string) error {
if skipSync {
fmt.Println("IPs are up-to-date, skipping sync.")
return nil
}
fmt.Println("syncing firewall rule")
return synchronize(local)
},
Expand Down

0 comments on commit 8aae6f9

Please sign in to comment.