feat: improve http download strategy to prevent speed drops near completion (#969)

This commit is contained in:
Levi authored and GitHub committed 2025-04-05 22:20:35 +08:00
1 parent bfad91dcab
commit 50bc9ab129
4 files changed
+263 -134

No files matched your search

+27
View File
@@ -246,6 +246,33 @@ func TestFetcher_ConfigUseServerCtime(t *testing.T) {
}
}
func TestFetcher_Stats(t *testing.T) {
listener := test.StartTestFileServer()
defer listener.Close()
fetcher := doDownloadReady(buildConfigFetcher(config{
Connections: 16,
}), listener, 0, t)
err := fetcher.Start()
if err != nil {
t.Fatal(err)
}
err = fetcher.Wait()
if err != nil {
t.Fatal(err)
}
stats := fetcher.Stats().(*http.Stats)
if len(stats.Connections) != 16 {
t.Errorf("Stats() got = %v, want %v", len(stats.Connections), 16)
}
totalDownloaded := int64(0)
for _, conn := range stats.Connections {
totalDownloaded += conn.Downloaded
}
if totalDownloaded != test.BuildSize {
t.Errorf("Stats() got = %v, want %v", totalDownloaded, test.BuildSize)
}
}
func TestFetcherManager_ParseName(t *testing.T) {
type args struct {
u string