mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-12 06:30:35 +00:00
mirror: increase logging for easier debugging
This commit is contained in:
@@ -99,13 +99,13 @@ func apiDbCleanup(c *gin.Context) {
|
|||||||
db, _ := context.Database()
|
db, _ := context.Database()
|
||||||
|
|
||||||
if toDelete.Len() > 0 {
|
if toDelete.Len() > 0 {
|
||||||
batch := db.StartBatch()
|
batch := db.CreateBatch()
|
||||||
toDelete.ForEach(func(ref []byte) error {
|
toDelete.ForEach(func(ref []byte) error {
|
||||||
collectionFactory.PackageCollection().DeleteByKey(ref, batch)
|
collectionFactory.PackageCollection().DeleteByKey(ref, batch)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
err = db.FinishBatch(batch)
|
err = batch.Write()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to write to DB: %s", err)
|
return fmt.Errorf("unable to write to DB: %s", err)
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-5
@@ -146,8 +146,8 @@ func retryableError(err error) bool {
|
|||||||
case net.Error:
|
case net.Error:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
// Note: make all errors retryable
|
||||||
return false
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (downloader *downloaderImpl) newRequest(ctx context.Context, method, url string) (*http.Request, error) {
|
func (downloader *downloaderImpl) newRequest(ctx context.Context, method, url string) (*http.Request, error) {
|
||||||
@@ -182,17 +182,35 @@ func (downloader *downloaderImpl) DownloadWithChecksum(ctx context.Context, url
|
|||||||
for maxTries > 0 {
|
for maxTries > 0 {
|
||||||
temppath, err = downloader.download(req, url, destination, expected, ignoreMismatch)
|
temppath, err = downloader.download(req, url, destination, expected, ignoreMismatch)
|
||||||
|
|
||||||
if err != nil && retryableError(err) {
|
if err != nil {
|
||||||
maxTries--
|
if retryableError(err) {
|
||||||
|
if downloader.progress != nil {
|
||||||
|
downloader.progress.Printf("Error downloading %s: %s retrying...\n", url, err)
|
||||||
|
}
|
||||||
|
maxTries--
|
||||||
|
} else {
|
||||||
|
if downloader.progress != nil {
|
||||||
|
downloader.progress.Printf("Error downloading %s: %s cannot retry...\n", url, err)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// get out of the loop
|
// get out of the loop
|
||||||
|
if downloader.progress != nil {
|
||||||
|
downloader.progress.Printf("Success downloading %s\n", url)
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
downloader.progress.Printf("Retrying %s...\n", url)
|
if downloader.progress != nil {
|
||||||
|
downloader.progress.Printf("Retrying %d %s...\n", maxTries, url)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// still an error after retrying, giving up
|
// still an error after retrying, giving up
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if downloader.progress != nil {
|
||||||
|
downloader.progress.Printf("Giving up on %s...\n", url)
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user