Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions cmd/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
}
}
Expand Down
22 changes: 11 additions & 11 deletions internal/config/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion internal/engine/types/accuracy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading