challenge-sync-airbus: Done
This commit is contained in:
parent
268925db0d
commit
0d5b87b3f7
6 changed files with 73 additions and 68 deletions
|
|
@ -62,6 +62,12 @@ func main() {
|
|||
break
|
||||
}
|
||||
}
|
||||
|
||||
if api.SessionID == 0 {
|
||||
log.Fatal("Session ID not found")
|
||||
} else {
|
||||
log.Println("Session ID discovered: ", api.SessionID)
|
||||
}
|
||||
}
|
||||
|
||||
if v, exists := os.LookupEnv("AIRBUS_SESSIONUUID"); exists {
|
||||
|
|
@ -83,6 +89,7 @@ func main() {
|
|||
if err != nil {
|
||||
log.Fatal("Unable to open teams bindings file: ", err.Error())
|
||||
}
|
||||
log.Println("Team bindings loaded: ", len(teamsbindings))
|
||||
|
||||
w := Walker{
|
||||
LastSync: ts,
|
||||
|
|
@ -103,10 +110,9 @@ func main() {
|
|||
}
|
||||
|
||||
if !skipInitialSync {
|
||||
// Iterate over teams scores
|
||||
err = filepath.WalkDir(TeamsDir, w.WalkScoreSync)
|
||||
err = w.BalanceScores()
|
||||
if err != nil {
|
||||
log.Println("Something goes wrong during walking: ", err.Error())
|
||||
log.Println("Something goes wrong during score balance: ", err.Error())
|
||||
}
|
||||
|
||||
// save current timestamp for teams
|
||||
|
|
@ -116,6 +122,8 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
log.Println("initial sync done")
|
||||
|
||||
if daemon != nil && *daemon {
|
||||
// Watch teams.json and scores.json
|
||||
log.Println("Registering directory events...")
|
||||
|
|
@ -196,7 +204,7 @@ func main() {
|
|||
if err := watchsubdir(watcher, ev.Name); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
} else if ev.Op&watchedNotify == watchedNotify && d.Mode().IsRegular() {
|
||||
} else if err == nil && ev.Op&watchedNotify == watchedNotify && d.Mode().IsRegular() {
|
||||
if *debugINotify {
|
||||
log.Println("Treating event:", ev, "for", ev.Name)
|
||||
}
|
||||
|
|
@ -213,10 +221,10 @@ func main() {
|
|||
log.Fatal("Unable to fetch teams: ", err.Error())
|
||||
}
|
||||
}
|
||||
} else if ev.Op&fsnotify.Write == fsnotify.Write {
|
||||
} else if err == nil && ev.Op&fsnotify.Write == fsnotify.Write {
|
||||
log.Println("FSNOTIFY WRITE SEEN. Prefer looking at them, as it appears files are not atomically moved.")
|
||||
watchedNotify = fsnotify.Write
|
||||
} else if *debugINotify {
|
||||
} else if err == nil && *debugINotify {
|
||||
log.Println("Skipped event:", ev, "for", ev.Name)
|
||||
}
|
||||
case err := <-watcher.Errors:
|
||||
|
|
|
|||
Reference in a new issue