backend: don't regenerate files if config doesn't change
authorPierre-Olivier Mercier <nemunaire@nemunai.re>
Mon, 16 Jan 2017 12:12:57 +0000 (13:12 +0100)
committerPierre-Olivier Mercier <nemunaire@nemunai.re>
Wed, 17 Jan 2018 17:52:30 +0000 (18:52 +0100)
backend/main.go

index bd3306504a343a30c3a4542f8c635621e8a7367d..b0d660ee6c01da6bc7a081932eb07f2c02309542 100644 (file)
@@ -44,17 +44,21 @@ func watchsubdir(watcher *fsnotify.Watcher, pathname string) error {
 }
 
 func reloadSettings(config settings.FICSettings) {
-       fic.PartialValidation = config.PartialValidation
-       fic.UnlockedChallenges = !config.EnableExerciceDepend
-
-       fic.FirstBlood = config.FirstBlood
-       fic.SubmissionCostBase = config.SubmissionCostBase
-
-       log.Println("Generating files...")
-       go func() {
-               genAll()
-               log.Println("Full generation done")
-       }()
+       if fic.PartialValidation != config.PartialValidation || fic.UnlockedChallenges != !config.EnableExerciceDepend || fic.FirstBlood != config.FirstBlood || fic.SubmissionCostBase != config.SubmissionCostBase {
+               fic.PartialValidation = config.PartialValidation
+               fic.UnlockedChallenges = !config.EnableExerciceDepend
+
+               fic.FirstBlood = config.FirstBlood
+               fic.SubmissionCostBase = config.SubmissionCostBase
+
+               log.Println("Generating files...")
+               go func() {
+                       genAll()
+                       log.Println("Full generation done")
+               }()
+       } else {
+               log.Println("No change found. Skipping regeneration.")
+       }
 }
 
 func main() {