mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-04-19 19:28:22 +00:00
mirror: add more logging
This commit is contained in:
@@ -2,6 +2,7 @@ package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -310,6 +311,8 @@ func apiMirrorsUpdate(c *gin.Context) {
|
||||
b.Architectures = remote.Architectures
|
||||
b.Components = remote.Components
|
||||
|
||||
log.Printf("%s: Starting mirror update\n", b.Name)
|
||||
|
||||
if c.Bind(&b) != nil {
|
||||
return
|
||||
}
|
||||
@@ -457,6 +460,7 @@ func apiMirrorsUpdate(c *gin.Context) {
|
||||
}
|
||||
}()
|
||||
|
||||
log.Printf("%s: Spawning background processes...\n", b.Name)
|
||||
var wg sync.WaitGroup
|
||||
for i := 0; i < context.Config().DownloadConcurrency; i++ {
|
||||
wg.Add(1)
|
||||
@@ -503,7 +507,9 @@ func apiMirrorsUpdate(c *gin.Context) {
|
||||
}
|
||||
|
||||
// Wait for all download goroutines to finish
|
||||
log.Printf("%s: Waiting for background processes to finish...\n", b.Name)
|
||||
wg.Wait()
|
||||
log.Printf("%s: Background processes finished\n", b.Name)
|
||||
close(taskFinished)
|
||||
|
||||
for idx := range queue {
|
||||
@@ -535,15 +541,18 @@ func apiMirrorsUpdate(c *gin.Context) {
|
||||
}
|
||||
|
||||
if len(errors) > 0 {
|
||||
log.Printf("%s: Unable to update because of previous errors\n", b.Name)
|
||||
return fmt.Errorf("unable to update: download errors:\n %s", strings.Join(errors, "\n "))
|
||||
}
|
||||
|
||||
log.Printf("%s: Finalizing download\n", b.Name)
|
||||
remote.FinalizeDownload(collectionFactory, out)
|
||||
err = collectionFactory.RemoteRepoCollection().Update(remote)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to update: %s", err)
|
||||
}
|
||||
|
||||
log.Printf("%s: Mirror updated successfully!\n", b.Name)
|
||||
return nil
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user