Documentation
¶
Index ¶
- func CheckReachable(ctx context.Context, cfg *config.Config, rawURL string, ...) (bool, string)
- func ComputeRemoteSHA256(ctx context.Context, cfg *config.Config, rawURL string, ...) (string, error)
- func StagePartPath(cfg *config.Config, url, dest string) string
- type Auto
- type Chunked
- type Interface
- type ProbeMeta
- type Single
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckReachable ¶
func CheckReachable(ctx context.Context, cfg *config.Config, rawURL string, headers map[string]string) (bool, string)
CheckReachable performs a quick HEAD to determine network reachability to the resource. It returns reachable=true when an HTTP response is received regardless of status code. Only network errors (DNS failure, connect timeout, etc.) cause reachable=false.
func ComputeRemoteSHA256 ¶
func ComputeRemoteSHA256(ctx context.Context, cfg *config.Config, rawURL string, headers map[string]string) (string, error)
ComputeRemoteSHA256 streams the content at URL and computes its SHA256 without saving to disk. This fully downloads the resource, so it can be slow and bandwidth-heavy.
Types ¶
type Auto ¶
type Auto struct {
// contains filtered or unexported fields
}
Auto implements Interface by delegating to the chunked downloader which already contains robust fallback to the single-stream downloader. This centralizes the selection logic behind Interface.
type Interface ¶
type Interface interface {
Download(ctx context.Context, url, destPath, expectedSHA string, headers map[string]string, noResume bool) (finalPath string, sha256 string, err error)
}
Interface is the common downloader interface used across implementations.
type ProbeMeta ¶
type ProbeMeta struct {
FinalURL string
Filename string
Size int64
ETag string
LastModified string
AcceptRange bool
}
func ProbeURL ¶
func ProbeURL(ctx context.Context, cfg *config.Config, rawURL string, headers map[string]string) (ProbeMeta, error)
ProbeURL queries metadata for a URL using a HEAD request, with fallbacks to a small Range GET and one-step redirect resolution. It returns filename (from Content-Disposition when present), final URL after redirects, size (if known), and other useful headers.
type Single ¶
type Single struct {
// contains filtered or unexported fields
}
func (*Single) Download ¶
func (s *Single) Download(ctx context.Context, url, destPath, expectedSHA string, headers map[string]string, noResume bool) (string, string, error)
Download downloads a single file from url to destPath. If destPath is empty, it uses cfg.General.DownloadRoot + last URL segment. It resumes if a .part file exists and the server supports Range requests.