mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-06 22:18:28 +00:00
Refactoring: new packages console, http, Progress is interface.
This commit is contained in:
+29
-1
@@ -4,6 +4,7 @@ package aptly
|
||||
|
||||
import (
|
||||
"github.com/smira/aptly/utils"
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
@@ -13,7 +14,7 @@ import (
|
||||
type PackagePool interface {
|
||||
Path(filename string, hashMD5 string) (string, error)
|
||||
RelativePath(filename string, hashMD5 string) (string, error)
|
||||
FilepathList(progress *utils.Progress) ([]string, error)
|
||||
FilepathList(progress Progress) ([]string, error)
|
||||
Remove(path string) (size int64, err error)
|
||||
}
|
||||
|
||||
@@ -26,3 +27,30 @@ type PublishedStorage interface {
|
||||
LinkFromPool(prefix string, component string, poolDirectory string, sourcePool PackagePool, sourcePath string) (string, error)
|
||||
ChecksumsForFile(path string) (utils.ChecksumInfo, error)
|
||||
}
|
||||
|
||||
// Progress is a progress displaying entity, it allows progress bars & simple prints
|
||||
type Progress interface {
|
||||
// Writer interface to support progress bar ticking
|
||||
io.Writer
|
||||
// Start makes progress start its work
|
||||
Start()
|
||||
// Shutdown shuts down progress display
|
||||
Shutdown()
|
||||
// InitBar starts progressbar for count bytes or count items
|
||||
InitBar(count int64, isBytes bool)
|
||||
// ShutdownBar stops progress bar and hides it
|
||||
ShutdownBar()
|
||||
// AddBar increments progress for progress bar
|
||||
AddBar(count int)
|
||||
// Printf does printf but in safe manner: not overwriting progress bar
|
||||
Printf(msg string, a ...interface{})
|
||||
}
|
||||
|
||||
// Downloader is parallel HTTP fetcher
|
||||
type Downloader interface {
|
||||
Download(url string, destination string, result chan<- error)
|
||||
DownloadWithChecksum(url string, destination string, result chan<- error, expected utils.ChecksumInfo, ignoreMismatch bool)
|
||||
Pause()
|
||||
Resume()
|
||||
Shutdown()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user