Use Go context to abort gracefully mirror updates

There are two fixes here:

1. Abort package download immediately as ^C is pressed.
2. Import all the already downloaded files into package pool,
so that next time mirror is updated, aptly won't download them
once again.
This commit is contained in:
Andrey Smirnov
2017-11-30 00:49:37 +03:00
parent a037615962
commit 15618c8ea8
12 changed files with 131 additions and 80 deletions
+3 -2
View File
@@ -3,6 +3,7 @@
package aptly
import (
"context"
"io"
"os"
@@ -116,9 +117,9 @@ type Progress interface {
// Downloader is parallel HTTP fetcher
type Downloader interface {
// Download starts new download task
Download(url string, destination string) error
Download(ctx context.Context, url string, destination string) error
// DownloadWithChecksum starts new download task with checksum verification
DownloadWithChecksum(url string, destination string, expected *utils.ChecksumInfo, ignoreMismatch bool, maxTries int) error
DownloadWithChecksum(ctx context.Context, url string, destination string, expected *utils.ChecksumInfo, ignoreMismatch bool, maxTries int) error
// GetProgress returns Progress object
GetProgress() Progress
}