sync: add logs on stderr when doing deepsync

This commit is contained in:
nemunaire 2019-11-25 15:08:50 +01:00
parent d97ecde3fb
commit 9693940d8c

View File

@ -24,12 +24,18 @@ var DeepSyncProgress uint8
// SyncDeep performs a recursive synchronisation: from themes to challenge items.
func SyncDeep(i Importer) (errs map[string][]string) {
oneDeepSync.Lock()
defer oneDeepSync.Unlock()
defer func(){
oneDeepSync.Unlock()
if DeepSyncProgress != 255 {
log.Printf("Full synchronization terminated at step %d/255", DeepSyncProgress)
}
}()
DeepSyncProgress = 1
errs = map[string][]string{}
errs["_date"] = []string{fmt.Sprintf("%v", time.Now())}
startTime := time.Now()
errs["_date"] = []string{fmt.Sprintf("%v", startTime)}
errs["_themes"] = SyncThemes(i)
if themes, err := fic.GetThemes(); err == nil {
@ -43,6 +49,8 @@ func SyncDeep(i Importer) (errs map[string][]string) {
if exercices, err := theme.GetExercices(); err == nil {
var exerciceStep uint8 = themeStep / uint8(len(exercices))
for eid, exercice := range exercices {
log.Printf("Full synchronization in progress: %d/255 - doing Theme %q, Exercice %q: %q\n", DeepSyncProgress, theme.Name, exercice.Title, exercice.Path)
DeepSyncProgress = 3 + uint8(tid) * themeStep + uint8(eid) * exerciceStep
errs[theme.Name] = append(errs[theme.Name], SyncExerciceFiles(i, exercice)...)
@ -82,5 +90,6 @@ func SyncDeep(i Importer) (errs map[string][]string) {
}
DeepSyncProgress = 255
log.Println("Full synchronization done in", time.Since(startTime))
return
}