Skip to content

Commit f3dc4fd

Browse files
committed
Handle errors in rules folder removal and git clone process
Previously, errors during the removal of the rules folder or cloning from the repository were ignored. This update adds error handling to log failures and exit the program when these operations fail, ensuring more robust error management.
1 parent b8c4ce1 commit f3dc4fd

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

correlation/rules/update.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package rules
22

33
import (
44
"log"
5+
"os"
56
"os/exec"
67
"time"
78

@@ -15,10 +16,18 @@ func Update(updateReady chan bool) {
1516
cnf := utils.GetConfig()
1617

1718
rm := exec.Command("rm", "-R", cnf.RulesFolder+"system")
18-
_ = rm.Run()
19+
err := rm.Run()
20+
if err != nil {
21+
log.Printf("Could not remove rules folder: %v", err)
22+
os.Exit(1)
23+
}
1924

2025
clone := exec.Command("git", "clone", "https://github.com/utmstack/rules.git", cnf.RulesFolder+"system")
21-
_ = clone.Run()
26+
err = clone.Run()
27+
if err != nil {
28+
log.Printf("Could not clone rules: %v", err)
29+
os.Exit(1)
30+
}
2231

2332
if first {
2433
first = false

0 commit comments

Comments
 (0)