MCPcopy Index your code
hub / github.com/aptly-dev/aptly / DownloadTempWithChecksum

Function DownloadTempWithChecksum

http/temp.go:22–47  ·  view source on GitHub ↗

DownloadTempWithChecksum is a DownloadTemp with checksum verification Temporary file would be already removed, so no need to cleanup

(ctx context.Context, downloader aptly.Downloader, url string, expected *utils.ChecksumInfo, ignoreMismatch bool)

Source from the content-addressed store, hash-verified

20//
21// Temporary file would be already removed, so no need to cleanup
22func DownloadTempWithChecksum(ctx context.Context, downloader aptly.Downloader, url string, expected *utils.ChecksumInfo, ignoreMismatch bool) (*os.File, error) {
23 tempdir, err := os.MkdirTemp(os.TempDir(), "aptly")
24 if err != nil {
25 return nil, err
26 }
27 defer func() { _ = os.RemoveAll(tempdir) }()
28
29 tempfile := filepath.Join(tempdir, "buffer")
30
31 if expected != nil && downloader.GetProgress() != nil {
32 downloader.GetProgress().InitBar(expected.Size, true, aptly.BarMirrorUpdateDownloadIndexes)
33 defer downloader.GetProgress().ShutdownBar()
34 }
35
36 err = downloader.DownloadWithChecksum(ctx, url, tempfile, expected, ignoreMismatch)
37 if err != nil {
38 return nil, err
39 }
40
41 file, err := os.Open(tempfile)
42 if err != nil {
43 return nil, err
44 }
45
46 return file, nil
47}

Callers 3

DownloadTryCompressionFunction · 0.85
DownloadTempFunction · 0.85

Calls 5

GetProgressMethod · 0.65
InitBarMethod · 0.65
ShutdownBarMethod · 0.65
DownloadWithChecksumMethod · 0.65
OpenMethod · 0.65

Tested by 1