mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-12 11:24:08 +00:00
fix: move checksum to HTTP opts, fix mismatch retry, scope get_download_speed to aggregate-only
This commit is contained in:
1 parent
929e2d2d7c
commit
b5e8d61f01
16 files changed
+501
-655
No files matched your search
@@ -124,11 +124,6 @@ type FileInfo struct {
|
||||
Req *Request `json:"req"`
|
||||
}
|
||||
|
||||
type ChecksumOption struct {
|
||||
Algorithm string `json:"algorithm"` // "md5" | "sha1" | "sha256"
|
||||
Expected string `json:"expected"` // hex-encoded expected hash
|
||||
}
|
||||
|
||||
// Options for download
|
||||
type Options struct {
|
||||
// Download file name
|
||||
@@ -141,8 +136,6 @@ type Options struct {
|
||||
SelectFiles []int `json:"selectFiles"`
|
||||
// Extra info for specific fetcher
|
||||
Extra any `json:"extra"`
|
||||
// Checksum verification option
|
||||
Checksum *ChecksumOption `json:"checksum,omitempty"`
|
||||
}
|
||||
|
||||
func (o *Options) InitSelectFiles(fileSize int) {
|
||||
|
||||
@@ -435,35 +435,3 @@ func TestDownloaderStoreConfig_Merge(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestOptions_Checksum(t *testing.T) {
|
||||
opts := &Options{
|
||||
Name: "test.zip",
|
||||
Path: "/downloads",
|
||||
Checksum: &ChecksumOption{
|
||||
Algorithm: "sha256",
|
||||
Expected: "abcdef1234567890",
|
||||
},
|
||||
}
|
||||
|
||||
cloned := opts.Clone()
|
||||
if cloned.Checksum == nil {
|
||||
t.Fatal("expected cloned options to have non-nil Checksum")
|
||||
}
|
||||
if cloned.Checksum.Algorithm != "sha256" || cloned.Checksum.Expected != "abcdef1234567890" {
|
||||
t.Fatalf("cloned checksum mismatch: got %+v", cloned.Checksum)
|
||||
}
|
||||
|
||||
// Verify deep clone isolation
|
||||
cloned.Checksum.Expected = "modified"
|
||||
if opts.Checksum.Expected != "abcdef1234567890" {
|
||||
t.Fatal("modifying cloned checksum affected original options")
|
||||
}
|
||||
|
||||
// Verify nil checksum options clone
|
||||
optsNil := &Options{Name: "nil_check.zip"}
|
||||
clonedNil := optsNil.Clone()
|
||||
if clonedNil.Checksum != nil {
|
||||
t.Fatal("expected nil checksum in cloned options")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user