mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-06 22:18:28 +00:00
This commit is contained in:
@@ -90,6 +90,8 @@ type Downloader interface {
|
|||||||
// Shutdown stops downloader after current tasks are finished,
|
// Shutdown stops downloader after current tasks are finished,
|
||||||
// but doesn't process rest of queue
|
// but doesn't process rest of queue
|
||||||
Shutdown()
|
Shutdown()
|
||||||
|
// Abort stops downloader without waiting for shutdown
|
||||||
|
Abort()
|
||||||
// GetProgress returns Progress object
|
// GetProgress returns Progress object
|
||||||
GetProgress() Progress
|
GetProgress() Progress
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -289,7 +289,7 @@ func ShutdownContext() {
|
|||||||
context.database = nil
|
context.database = nil
|
||||||
}
|
}
|
||||||
if context.downloader != nil {
|
if context.downloader != nil {
|
||||||
context.downloader.Shutdown()
|
context.downloader.Abort()
|
||||||
context.downloader = nil
|
context.downloader = nil
|
||||||
}
|
}
|
||||||
if context.progress != nil {
|
if context.progress != nil {
|
||||||
|
|||||||
+9
-2
@@ -52,8 +52,8 @@ func NewDownloader(threads int, downLimit int64, progress aptly.Progress) aptly.
|
|||||||
|
|
||||||
downloader := &downloaderImpl{
|
downloader := &downloaderImpl{
|
||||||
queue: make(chan *downloadTask, 1000),
|
queue: make(chan *downloadTask, 1000),
|
||||||
stop: make(chan struct{}),
|
stop: make(chan struct{}, threads),
|
||||||
stopped: make(chan struct{}),
|
stopped: make(chan struct{}, threads),
|
||||||
pause: make(chan struct{}),
|
pause: make(chan struct{}),
|
||||||
unpause: make(chan struct{}),
|
unpause: make(chan struct{}),
|
||||||
threads: threads,
|
threads: threads,
|
||||||
@@ -88,6 +88,13 @@ func (downloader *downloaderImpl) Shutdown() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Abort stops downloader but doesn't wait for downloader to stop
|
||||||
|
func (downloader *downloaderImpl) Abort() {
|
||||||
|
for i := 0; i < downloader.threads; i++ {
|
||||||
|
downloader.stop <- struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Pause pauses task processing
|
// Pause pauses task processing
|
||||||
func (downloader *downloaderImpl) Pause() {
|
func (downloader *downloaderImpl) Pause() {
|
||||||
for i := 0; i < downloader.threads; i++ {
|
for i := 0; i < downloader.threads; i++ {
|
||||||
|
|||||||
@@ -123,6 +123,10 @@ func (f *FakeDownloader) Download(url string, filename string, result chan<- err
|
|||||||
func (f *FakeDownloader) Shutdown() {
|
func (f *FakeDownloader) Shutdown() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Abort does nothing
|
||||||
|
func (f *FakeDownloader) Abort() {
|
||||||
|
}
|
||||||
|
|
||||||
// Pause does nothing
|
// Pause does nothing
|
||||||
func (f *FakeDownloader) Pause() {
|
func (f *FakeDownloader) Pause() {
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user