MCPcopy Create free account
hub / github.com/cph6/zsync / getZsyncControlFile

Function getZsyncControlFile

cmd/zsync/main.go:288–301  ·  view source on GitHub ↗

getZsyncControlFile wraps zsync.GetControlFile giving the option to use a local file instead of fetching remotely.

(client zsync.HTTPRequester, source, keepZsync, referer string)

Source from the content-addressed store, hash-verified

286// getZsyncControlFile wraps zsync.GetControlFile giving the option to use a
287// local file instead of fetching remotely.
288func getZsyncControlFile(client zsync.HTTPRequester, source, keepZsync, referer string) (io.ReadCloser, string, error) {
289 // First try to read from local file.
290 if _, err := os.Stat(source); err == nil {
291 f, err := os.Open(source)
292 if err != nil {
293 return nil, "", fmt.Errorf("failed to open .zsync: %w", err)
294 }
295 // If the control file is local, we use the supplied referer URL as the
296 // referer for the target file requests.
297 return f, referer, nil
298 }
299
300 return zsync.GetControlFile(client, source, keepZsync, referer)
301}
302
303func readSeedFile(zs *zsync.Syncer, filename string, noProgress bool) error {
304 if !noProgress {

Callers 1

mainFunction · 0.85

Calls 1

GetControlFileFunction · 0.92

Tested by

no test coverage detected