Documentation
¶
Index ¶
- Variables
- func DebugProbe(url string, skipTLS bool, proxyServer string, timeout time.Duration)
- func DownloadSigFile(sigURL, destPath string, skipTLS bool, proxyServer string, ...) error
- func Execute(ctx context.Context, url string, st *state.State, conn int, skiptls bool, ...) error
- func PartCalculate(par int64, length int64, url string) []state.Part
- func ProxyAwareHTTPClient(proxyServer string, skipTLS bool, timeout time.Duration) *http.Client
- func ReconstructStateFromParts(url string, skiptls bool, proxyServer string, timeout time.Duration) (*state.State, error)
- func RunVerify(url string, skipTLS bool, proxyServer string, timeout time.Duration) (ok bool, detail string)
- func VerifyGPGSignature(sigPath, filePath string) (string, error)
- type HTTPDownloader
Constants ¶
This section is empty.
Variables ¶
var ( // ErrSkipCurrent — user requested to skip the current download // (state is discarded, batch continues). ErrSkipCurrent = errors.New("skip current item") // ErrAbortBatch — user wants the entire batch to stop immediately // (state is saved when resumable, no further items are started). ErrAbortBatch = errors.New("abort batch") // ErrUserQuit — single-download equivalent of ErrAbortBatch. // State is saved when resumable. ErrUserQuit = errors.New("user quit") )
Cancellation causes used as the second argument to context.CancelCauseFunc. Execute and the batch loop use these to distinguish user intent.
Functions ¶
func DebugProbe ¶
DebugProbe performs HEAD and a 0-0 Range GET to print diagnostics without downloading.
func DownloadSigFile ¶
func DownloadSigFile(sigURL, destPath string, skipTLS bool, proxyServer string, timeout time.Duration) error
DownloadSigFile fetches the detached GPG signature file at sigURL and writes it to destPath. It reuses the same proxy/TLS settings as the main download.
func Execute ¶
func Execute(ctx context.Context, url string, st *state.State, conn int, skiptls bool, proxyServer string, bwLimit string, timeout time.Duration) error
Execute downloads url, observing ctx for cancellation. Returns:
- nil on success;
- context.Cause(ctx) (one of ErrSkipCurrent, ErrAbortBatch, ErrUserQuit, or context.Canceled) when ctx was cancelled;
- the underlying download/IO error on failure.
Execute always waits for every part goroutine to exit before returning, guaranteeing that no orphaned goroutines from the previous run can write into a future TUI session's ui.Program handle.
func PartCalculate ¶
PartCalculate splits the download into parts.
func ProxyAwareHTTPClient ¶
ProxyAwareHTTPClient returns an HTTP client that may use an HTTP or SOCKS5 proxy.
func ReconstructStateFromParts ¶
func ReconstructStateFromParts(url string, skiptls bool, proxyServer string, timeout time.Duration) (*state.State, error)
ReconstructStateFromParts rebuilds a *State for a URL that has existing part files in the download folder but no state.json (e.g. killed with SIGKILL). It probes the server for the total content length, recalculates the original part boundaries, then advances RangeFrom by each part file's current size.
func RunVerify ¶
func RunVerify(url string, skipTLS bool, proxyServer string, timeout time.Duration) (ok bool, detail string)
RunVerify downloads the .sig file for url and runs gpg --verify. It sends TUI messages when ui.Program is active (during the TUI alt-screen). It always returns (ok, detail) so the caller can print a post-TUI summary.
func VerifyGPGSignature ¶
VerifyGPGSignature runs `gpg --verify sigPath filePath` and returns an error (including gpg's stderr output) when verification fails.
It passes --keyserver-options auto-key-retrieve so missing public keys are fetched automatically from the default keyserver. When the key still cannot be found (e.g. the keyserver is unreachable), the key fingerprint parsed from gpg output is included in the error so the caller can surface a manual hint.
Types ¶
type HTTPDownloader ¶
type HTTPDownloader struct {
// contains filtered or unexported fields
}
HTTPDownloader holds the required configurations.
func NewHTTPDownloader ¶
func NewHTTPDownloader(url string, par int, skipTLS bool, proxyServer string, bwLimit string, timeout time.Duration) *HTTPDownloader
NewHTTPDownloader returns a configured HTTPDownloader ready to download url.
func NewHTTPDownloaderFromState ¶
func NewHTTPDownloaderFromState(st *state.State, client *http.Client, proxyServer string, skipTLS bool, timeout time.Duration) *HTTPDownloader
NewHTTPDownloaderFromState rebuilds an HTTPDownloader from a saved State, applying the given connection settings. Used when resuming a download.
func (*HTTPDownloader) Do ¶
func (d *HTTPDownloader) Do(doneChan chan bool, fileChan chan string, errorChan chan error, interruptChan chan bool, stateSaveChan chan state.Part)
Do is the main download entry point. It dispatches the download to multiple parts.
func (*HTTPDownloader) IsResumable ¶
func (d *HTTPDownloader) IsResumable() bool
IsResumable reports whether this download supports resumption.
func (*HTTPDownloader) NumParts ¶
func (d *HTTPDownloader) NumParts() int
NumParts returns the number of download parts.