diff --git a/cmd/main_test.go b/cmd/main_test.go index 42af976f..00747571 100644 --- a/cmd/main_test.go +++ b/cmd/main_test.go @@ -15,9 +15,11 @@ func resetSharedStateDB() error { // Reset any pre-existing global DB state (e.g. left by an init or an // isolated test cleanup) before pointing the package at the shared suite DB. state.CloseDB() - err := config.EnsureDirs() + if err := config.EnsureDirs(); err != nil { + return err + } state.Configure(filepath.Join(config.GetStateDir(), "surge.db")) - return err + return nil } func TestMain(m *testing.M) { @@ -35,6 +37,7 @@ func TestMain(m *testing.M) { if ensureErr := resetSharedStateDB(); ensureErr != nil { fmt.Fprintf(os.Stderr, "TestMain: failed to create isolated Surge test directories: %v\n", ensureErr) + _ = os.RemoveAll(tmpDir) os.Exit(1) } } diff --git a/internal/config/settings.go b/internal/config/settings.go index d2738b00..7fef40d1 100644 --- a/internal/config/settings.go +++ b/internal/config/settings.go @@ -68,19 +68,19 @@ type ExtensionSettings struct { // NetworkSettings contains network connection parameters. type NetworkSettings struct { - MaxConnectionsPerDownload int `json:"max_connections_per_host" ui_label:"Max Connections/Download" ui_desc:"Maximum concurrent connections per download (1-64)."` + MaxConnectionsPerDownload int `json:"max_connections_per_host" ui_label:"Max Connections/Download" ui_desc:"Maximum concurrent connections per download (1-64)."` // Deprecated: use MaxConnectionsPerDownload. // Kept as a non-serialized compatibility alias for older code paths and tests. - MaxConnectionsPerHost int `json:"-" ui_ignored:"true"` - MaxConcurrentDownloads int `json:"max_concurrent_downloads" ui_label:"Max Concurrent Downloads" ui_desc:"Maximum number of downloads running at once (1-10)." ui_restart:"true"` - MaxConcurrentProbes int `json:"max_concurrent_probes" ui_label:"Max Concurrent Probes" ui_desc:"Maximum number of simultaneous server probes when adding many downloads at once (1-10)." ui_restart:"true"` - UserAgent string `json:"user_agent" ui_label:"User Agent" ui_desc:"Custom User-Agent string for HTTP requests. Leave empty for default."` - ProxyURL string `json:"proxy_url" ui_label:"Proxy URL" ui_desc:"HTTP/HTTPS proxy URL (e.g. http://127.0.0.1:1700). Leave empty to use system default."` - CustomDNS string `json:"custom_dns" ui_label:"Custom DNS Server" ui_desc:"Set custom DNS (e.g., 1.1.1.1:53, 94.140.14.14:53). Leave empty for system."` - SequentialDownload bool `json:"sequential_download" ui_label:"Sequential Download" ui_desc:"Download pieces in order (Streaming Mode). May be slower."` - MinChunkSize int64 `json:"min_chunk_size" ui_label:"Min Chunk Size" ui_desc:"Minimum download chunk size in MB (e.g., 2)."` - WorkerBufferSize int `json:"worker_buffer_size" ui_label:"Worker Buffer Size" ui_desc:"I/O buffer size per worker in KB (e.g., 512)."` - DialHedgeCount int `json:"dial_hedge_count" ui_label:"Dial Hedge Count" ui_desc:"Number of extra connections to dial pre-emptively to avoid slow connects (0-16)."` + MaxConnectionsPerHost int `json:"-" ui_ignored:"true"` + MaxConcurrentDownloads int `json:"max_concurrent_downloads" ui_label:"Max Concurrent Downloads" ui_desc:"Maximum number of downloads running at once (1-10)." ui_restart:"true"` + MaxConcurrentProbes int `json:"max_concurrent_probes" ui_label:"Max Concurrent Probes" ui_desc:"Maximum number of simultaneous server probes when adding many downloads at once (1-10)." ui_restart:"true"` + UserAgent string `json:"user_agent" ui_label:"User Agent" ui_desc:"Custom User-Agent string for HTTP requests. Leave empty for default."` + ProxyURL string `json:"proxy_url" ui_label:"Proxy URL" ui_desc:"HTTP/HTTPS proxy URL (e.g. http://127.0.0.1:1700). Leave empty to use system default."` + CustomDNS string `json:"custom_dns" ui_label:"Custom DNS Server" ui_desc:"Set custom DNS (e.g., 1.1.1.1:53, 94.140.14.14:53). Leave empty for system."` + SequentialDownload bool `json:"sequential_download" ui_label:"Sequential Download" ui_desc:"Download pieces in order (Streaming Mode). May be slower."` + MinChunkSize int64 `json:"min_chunk_size" ui_label:"Min Chunk Size" ui_desc:"Minimum download chunk size in MB (e.g., 2)."` + WorkerBufferSize int `json:"worker_buffer_size" ui_label:"Worker Buffer Size" ui_desc:"I/O buffer size per worker in KB (e.g., 512)."` + DialHedgeCount int `json:"dial_hedge_count" ui_label:"Dial Hedge Count" ui_desc:"Number of extra connections to dial pre-emptively to avoid slow connects (0-16)."` } // PerformanceSettings contains performance tuning parameters. diff --git a/internal/engine/types/accuracy_test.go b/internal/engine/types/accuracy_test.go index 27c939aa..33b8f57f 100644 --- a/internal/engine/types/accuracy_test.go +++ b/internal/engine/types/accuracy_test.go @@ -94,7 +94,7 @@ func TestRestoreBitmap_ShortBitmapRecoversWithoutPanic(t *testing.T) { state := types.NewProgressState("test-short-restore", totalSize) malformed := []byte{0x02} // Too short: only enough storage for 4 chunks. - expectedBytes := 25 // 100 chunks * 2 bits = 25 bytes. + expectedBytes := 25 // 100 chunks * 2 bits = 25 bytes. defer func() { if r := recover(); r != nil {