Documentation
¶
Index ¶
- Constants
- func GetDownloadErrors(results []FileDownloadResult) map[string]error
- func GetSuccessfulDownloads(results []FileDownloadResult) int
- func HasDownloadErrors(results []FileDownloadResult) bool
- func IsWithinDest(destDir, registryPath string) bool
- func ResolveDestPath(destDir, registryPath string) string
- type BaseFileDownloadJob
- type FileDownloadEngine
- type FileDownloadJob
- type FileDownloadResult
- type URLDownloadJob
Constants ¶
const (
DefaultDownloadWorker = 5
)
Variables ¶
This section is empty.
Functions ¶
func GetDownloadErrors ¶
func GetDownloadErrors(results []FileDownloadResult) map[string]error
returns a map of failed downloads
func GetSuccessfulDownloads ¶
func GetSuccessfulDownloads(results []FileDownloadResult) int
returns count of successful downloads
func HasDownloadErrors ¶
func HasDownloadErrors(results []FileDownloadResult) bool
checks if any results contain errors
func IsWithinDest ¶
IsWithinDest reports whether a registry path resolves to a location inside destDir. Used to reject crafted paths like "../../evil.txt" before they can escape the download destination.
func ResolveDestPath ¶
ResolveDestPath returns the OS-native filesystem path where a file with the given registry path would be written under destDir.
Types ¶
type BaseFileDownloadJob ¶
BaseFileDownloadJob provides common fields for download jobs.
func (*BaseFileDownloadJob) GetFilePath ¶
func (b *BaseFileDownloadJob) GetFilePath() string
func (*BaseFileDownloadJob) GetFileSize ¶
func (b *BaseFileDownloadJob) GetFileSize() int64
func (*BaseFileDownloadJob) GetID ¶
func (b *BaseFileDownloadJob) GetID() string
type FileDownloadEngine ¶
type FileDownloadEngine struct {
// contains filtered or unexported fields
}
manages concurrent file downloads
func NewFileDownloadEngine ¶
func NewFileDownloadEngine(maxWorkers int, progress p.Reporter) *FileDownloadEngine
creating a new download engine, to perform downloads concurrently
func (*FileDownloadEngine) Execute ¶
func (e *FileDownloadEngine) Execute(ctx context.Context, jobs []FileDownloadJob) []FileDownloadResult
Execute runs all download jobs concurrently.
type FileDownloadJob ¶
type FileDownloadJob interface {
GetID() string
GetFilePath() string
GetFileSize() int64
Download(ctx context.Context) error
}
FileDownloadJob represents a single file download operation.
type FileDownloadResult ¶
type FileDownloadResult struct {
JobID string
FilePath string
FileSize int64
Error error
Success bool
}
FileDownloadResult holds the outcome of one download job.
type URLDownloadJob ¶
type URLDownloadJob struct {
BaseFileDownloadJob
RegistryPath string
DestDir string
DownloadURL string
HTTPClient *http.Client
}
URLDownloadJob downloads a single file from a direct URL. It works for any artifact type since it uses the downloadUrl returned by the search API rather than a type-specific client.
func NewURLDownloadJob ¶
func NewURLDownloadJob(id, registryPath, destDir, downloadURL string, fileSize int64) *URLDownloadJob