From a8b4232e38e9ef047efdbd741a7cb8f36b83424b Mon Sep 17 00:00:00 2001 From: s0up4200 Date: Wed, 17 Apr 2024 20:09:32 +0200 Subject: [PATCH 1/5] add(methods): ToggleFirstLastPiecePrio --- methods.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/methods.go b/methods.go index 832ae94..028cff9 100644 --- a/methods.go +++ b/methods.go @@ -1102,6 +1102,33 @@ func (c *Client) IncreasePriorityCtx(ctx context.Context, hashes []string) error return nil } +// ToggleFirstLastPiecePrio toggles the priority of the first and last pieces of torrents specified by hashes +func (c *Client) ToggleFirstLastPiecePrio(hashes []string) error { + return c.ToggleFirstLastPiecePrioCtx(context.Background(), hashes) +} + +// ToggleFirstLastPiecePrioCtx toggles the priority of the first and last pieces of torrents specified by hashes +func (c *Client) ToggleFirstLastPiecePrioCtx(ctx context.Context, hashes []string) error { + hv := strings.Join(hashes, "|") + + opts := map[string]string{ + "hashes": hv, + } + + resp, err := c.postCtx(ctx, "torrents/toggleFirstLastPiecePrio", opts) + if err != nil { + return errors.Wrap(err, "could not toggle first/last piece priority for torrents: %v", hashes) + } + + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + return errors.New("unexpected status while toggling first/last piece priority for torrents: %v, status: %d", hashes, resp.StatusCode) + } + + return nil +} + func (c *Client) GetAppVersion() (string, error) { return c.GetAppVersionCtx(context.Background()) } From 51c7e05e1f689b7954077cd2107a842130592622 Mon Sep 17 00:00:00 2001 From: s0up4200 Date: Wed, 17 Apr 2024 20:10:25 +0200 Subject: [PATCH 2/5] add(domain): ToggleFirstLastPiecePrio --- domain.go | 32 +++++--- domain_test.go | 197 +++++++++++++++++++++++++++++-------------------- 2 files changed, 138 insertions(+), 91 deletions(-) diff --git a/domain.go b/domain.go index 2d3cc93..ae12550 100644 --- a/domain.go +++ b/domain.go @@ -261,18 +261,19 @@ const ( ) type TorrentAddOptions struct { - Paused bool - SkipHashCheck bool - ContentLayout ContentLayout - SavePath string - AutoTMM bool - Category string - Tags string - LimitUploadSpeed int64 - LimitDownloadSpeed int64 - LimitRatio float64 - LimitSeedTime int64 - Rename string + Paused bool + SkipHashCheck bool + ContentLayout ContentLayout + SavePath string + AutoTMM bool + Category string + Tags string + LimitUploadSpeed int64 + LimitDownloadSpeed int64 + LimitRatio float64 + LimitSeedTime int64 + Rename string + ToggleFirstLastPiecePrio bool } func (o *TorrentAddOptions) Prepare() map[string]string { @@ -329,6 +330,12 @@ func (o *TorrentAddOptions) Prepare() map[string]string { options["rename"] = o.Rename } + if o.ToggleFirstLastPiecePrio { + options["firstLastPiecePrio"] = "true" + } else { + options["firstLastPiecePrio"] = "false" + } + return options } @@ -399,6 +406,7 @@ type AppPreferences struct { AsyncIoThreads int `json:"async_io_threads"` AutoDeleteMode int `json:"auto_delete_mode"` AutoTmmEnabled bool `json:"auto_tmm_enabled"` + ToggleFirstLastPiecePrio bool `json:"toggle_first_last_piece_prio"` AutorunEnabled bool `json:"autorun_enabled"` AutorunOnTorrentAddedEnabled bool `json:"autorun_on_torrent_added_enabled"` AutorunOnTorrentAddedProgram string `json:"autorun_on_torrent_added_program"` diff --git a/domain_test.go b/domain_test.go index 7782f1c..a10cec1 100644 --- a/domain_test.go +++ b/domain_test.go @@ -8,18 +8,19 @@ import ( func TestTorrentAddOptions_Prepare(t *testing.T) { type fields struct { - Paused bool - SkipHashCheck bool - ContentLayout ContentLayout - SavePath string - AutoTMM bool - Category string - Tags string - LimitUploadSpeed int64 - LimitDownloadSpeed int64 - LimitRatio float64 - LimitSeedTime int64 - Rename string + Paused bool + SkipHashCheck bool + ContentLayout ContentLayout + SavePath string + AutoTMM bool + Category string + Tags string + LimitUploadSpeed int64 + LimitDownloadSpeed int64 + LimitRatio float64 + LimitSeedTime int64 + Rename string + ToggleFirstLastPiecePrio bool } tests := []struct { name string @@ -42,16 +43,17 @@ func TestTorrentAddOptions_Prepare(t *testing.T) { LimitSeedTime: 100, }, want: map[string]string{ - "paused": "false", - "skip_checking": "true", - "autoTMM": "false", - "ratioLimit": "2.00", - "savepath": "/home/test/torrents", - "seedingTimeLimit": "100", - "category": "test", - "tags": "limited,slow", - "upLimit": "102400000", - "dlLimit": "102400000", + "paused": "false", + "skip_checking": "true", + "autoTMM": "false", + "firstLastPiecePrio": "false", + "ratioLimit": "2.00", + "savepath": "/home/test/torrents", + "seedingTimeLimit": "100", + "category": "test", + "tags": "limited,slow", + "upLimit": "102400000", + "dlLimit": "102400000", }, }, { @@ -70,18 +72,19 @@ func TestTorrentAddOptions_Prepare(t *testing.T) { LimitSeedTime: 100, }, want: map[string]string{ - "paused": "false", - "skip_checking": "true", - "root_folder": "true", - "contentLayout": "Subfolder", - "autoTMM": "false", - "ratioLimit": "2.00", - "savepath": "/home/test/torrents", - "seedingTimeLimit": "100", - "category": "test", - "tags": "limited,slow", - "upLimit": "102400000", - "dlLimit": "102400000", + "paused": "false", + "skip_checking": "true", + "root_folder": "true", + "contentLayout": "Subfolder", + "autoTMM": "false", + "firstLastPiecePrio": "false", + "ratioLimit": "2.00", + "savepath": "/home/test/torrents", + "seedingTimeLimit": "100", + "category": "test", + "tags": "limited,slow", + "upLimit": "102400000", + "dlLimit": "102400000", }, }, { @@ -100,18 +103,19 @@ func TestTorrentAddOptions_Prepare(t *testing.T) { LimitSeedTime: 100, }, want: map[string]string{ - "paused": "false", - "skip_checking": "true", - "root_folder": "false", - "contentLayout": "NoSubfolder", - "autoTMM": "false", - "ratioLimit": "2.00", - "savepath": "/home/test/torrents", - "seedingTimeLimit": "100", - "category": "test", - "tags": "limited,slow", - "upLimit": "102400000", - "dlLimit": "102400000", + "paused": "false", + "skip_checking": "true", + "root_folder": "false", + "contentLayout": "NoSubfolder", + "autoTMM": "false", + "firstLastPiecePrio": "false", + "ratioLimit": "2.00", + "savepath": "/home/test/torrents", + "seedingTimeLimit": "100", + "category": "test", + "tags": "limited,slow", + "upLimit": "102400000", + "dlLimit": "102400000", }, }, { @@ -130,16 +134,17 @@ func TestTorrentAddOptions_Prepare(t *testing.T) { LimitSeedTime: 100, }, want: map[string]string{ - "paused": "false", - "skip_checking": "true", - "autoTMM": "false", - "ratioLimit": "2.00", - "savepath": "/home/test/torrents", - "seedingTimeLimit": "100", - "category": "test", - "tags": "limited,slow", - "upLimit": "102400000", - "dlLimit": "102400000", + "paused": "false", + "skip_checking": "true", + "autoTMM": "false", + "firstLastPiecePrio": "false", + "ratioLimit": "2.00", + "savepath": "/home/test/torrents", + "seedingTimeLimit": "100", + "category": "test", + "tags": "limited,slow", + "upLimit": "102400000", + "dlLimit": "102400000", }, }, { @@ -159,35 +164,69 @@ func TestTorrentAddOptions_Prepare(t *testing.T) { Rename: "test-torrent-rename", }, want: map[string]string{ - "paused": "false", - "skip_checking": "true", - "autoTMM": "false", - "ratioLimit": "2.00", - "savepath": "/home/test/torrents", - "seedingTimeLimit": "100", - "category": "test", - "tags": "limited,slow", - "upLimit": "102400000", - "dlLimit": "102400000", - "rename": "test-torrent-rename", + "paused": "false", + "skip_checking": "true", + "autoTMM": "false", + "firstLastPiecePrio": "false", + "ratioLimit": "2.00", + "savepath": "/home/test/torrents", + "seedingTimeLimit": "100", + "category": "test", + "tags": "limited,slow", + "upLimit": "102400000", + "dlLimit": "102400000", + "rename": "test-torrent-rename", + }, + }, + { + name: "test_06", + fields: fields{ + Paused: false, + SkipHashCheck: true, + ContentLayout: ContentLayoutOriginal, + SavePath: "/home/test/torrents", + AutoTMM: false, + ToggleFirstLastPiecePrio: true, + Category: "test", + Tags: "limited,slow", + LimitUploadSpeed: 100000, + LimitDownloadSpeed: 100000, + LimitRatio: 2.0, + LimitSeedTime: 100, + Rename: "test-torrent-rename", + }, + want: map[string]string{ + "paused": "false", + "skip_checking": "true", + "autoTMM": "false", + "firstLastPiecePrio": "true", + "ratioLimit": "2.00", + "savepath": "/home/test/torrents", + "seedingTimeLimit": "100", + "category": "test", + "tags": "limited,slow", + "upLimit": "102400000", + "dlLimit": "102400000", + "rename": "test-torrent-rename", }, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { o := &TorrentAddOptions{ - Paused: tt.fields.Paused, - SkipHashCheck: tt.fields.SkipHashCheck, - ContentLayout: tt.fields.ContentLayout, - SavePath: tt.fields.SavePath, - AutoTMM: tt.fields.AutoTMM, - Category: tt.fields.Category, - Tags: tt.fields.Tags, - LimitUploadSpeed: tt.fields.LimitUploadSpeed, - LimitDownloadSpeed: tt.fields.LimitDownloadSpeed, - LimitRatio: tt.fields.LimitRatio, - LimitSeedTime: tt.fields.LimitSeedTime, - Rename: tt.fields.Rename, + Paused: tt.fields.Paused, + SkipHashCheck: tt.fields.SkipHashCheck, + ContentLayout: tt.fields.ContentLayout, + SavePath: tt.fields.SavePath, + AutoTMM: tt.fields.AutoTMM, + Category: tt.fields.Category, + Tags: tt.fields.Tags, + LimitUploadSpeed: tt.fields.LimitUploadSpeed, + LimitDownloadSpeed: tt.fields.LimitDownloadSpeed, + LimitRatio: tt.fields.LimitRatio, + LimitSeedTime: tt.fields.LimitSeedTime, + Rename: tt.fields.Rename, + ToggleFirstLastPiecePrio: tt.fields.ToggleFirstLastPiecePrio, } got := o.Prepare() From 665e8aa7d207d363f7f2438e9f0e255c7d496840 Mon Sep 17 00:00:00 2001 From: s0up4200 Date: Wed, 17 Apr 2024 20:49:45 +0200 Subject: [PATCH 3/5] fix(domain): use correct property name --- domain.go | 4 +- domain_test.go | 144 ++++++++++++++++++++++++------------------------- 2 files changed, 74 insertions(+), 74 deletions(-) diff --git a/domain.go b/domain.go index ae12550..2ba9ecf 100644 --- a/domain.go +++ b/domain.go @@ -331,9 +331,9 @@ func (o *TorrentAddOptions) Prepare() map[string]string { } if o.ToggleFirstLastPiecePrio { - options["firstLastPiecePrio"] = "true" + options["toggleFirstLastPiecePrio"] = "true" } else { - options["firstLastPiecePrio"] = "false" + options["toggleFirstLastPiecePrio"] = "false" } return options diff --git a/domain_test.go b/domain_test.go index a10cec1..85971ee 100644 --- a/domain_test.go +++ b/domain_test.go @@ -43,17 +43,17 @@ func TestTorrentAddOptions_Prepare(t *testing.T) { LimitSeedTime: 100, }, want: map[string]string{ - "paused": "false", - "skip_checking": "true", - "autoTMM": "false", - "firstLastPiecePrio": "false", - "ratioLimit": "2.00", - "savepath": "/home/test/torrents", - "seedingTimeLimit": "100", - "category": "test", - "tags": "limited,slow", - "upLimit": "102400000", - "dlLimit": "102400000", + "paused": "false", + "skip_checking": "true", + "autoTMM": "false", + "toggleFirstLastPiecePrio": "false", + "ratioLimit": "2.00", + "savepath": "/home/test/torrents", + "seedingTimeLimit": "100", + "category": "test", + "tags": "limited,slow", + "upLimit": "102400000", + "dlLimit": "102400000", }, }, { @@ -72,19 +72,19 @@ func TestTorrentAddOptions_Prepare(t *testing.T) { LimitSeedTime: 100, }, want: map[string]string{ - "paused": "false", - "skip_checking": "true", - "root_folder": "true", - "contentLayout": "Subfolder", - "autoTMM": "false", - "firstLastPiecePrio": "false", - "ratioLimit": "2.00", - "savepath": "/home/test/torrents", - "seedingTimeLimit": "100", - "category": "test", - "tags": "limited,slow", - "upLimit": "102400000", - "dlLimit": "102400000", + "paused": "false", + "skip_checking": "true", + "root_folder": "true", + "contentLayout": "Subfolder", + "autoTMM": "false", + "toggleFirstLastPiecePrio": "false", + "ratioLimit": "2.00", + "savepath": "/home/test/torrents", + "seedingTimeLimit": "100", + "category": "test", + "tags": "limited,slow", + "upLimit": "102400000", + "dlLimit": "102400000", }, }, { @@ -103,19 +103,19 @@ func TestTorrentAddOptions_Prepare(t *testing.T) { LimitSeedTime: 100, }, want: map[string]string{ - "paused": "false", - "skip_checking": "true", - "root_folder": "false", - "contentLayout": "NoSubfolder", - "autoTMM": "false", - "firstLastPiecePrio": "false", - "ratioLimit": "2.00", - "savepath": "/home/test/torrents", - "seedingTimeLimit": "100", - "category": "test", - "tags": "limited,slow", - "upLimit": "102400000", - "dlLimit": "102400000", + "paused": "false", + "skip_checking": "true", + "root_folder": "false", + "contentLayout": "NoSubfolder", + "autoTMM": "false", + "toggleFirstLastPiecePrio": "false", + "ratioLimit": "2.00", + "savepath": "/home/test/torrents", + "seedingTimeLimit": "100", + "category": "test", + "tags": "limited,slow", + "upLimit": "102400000", + "dlLimit": "102400000", }, }, { @@ -134,17 +134,17 @@ func TestTorrentAddOptions_Prepare(t *testing.T) { LimitSeedTime: 100, }, want: map[string]string{ - "paused": "false", - "skip_checking": "true", - "autoTMM": "false", - "firstLastPiecePrio": "false", - "ratioLimit": "2.00", - "savepath": "/home/test/torrents", - "seedingTimeLimit": "100", - "category": "test", - "tags": "limited,slow", - "upLimit": "102400000", - "dlLimit": "102400000", + "paused": "false", + "skip_checking": "true", + "autoTMM": "false", + "toggleFirstLastPiecePrio": "false", + "ratioLimit": "2.00", + "savepath": "/home/test/torrents", + "seedingTimeLimit": "100", + "category": "test", + "tags": "limited,slow", + "upLimit": "102400000", + "dlLimit": "102400000", }, }, { @@ -164,18 +164,18 @@ func TestTorrentAddOptions_Prepare(t *testing.T) { Rename: "test-torrent-rename", }, want: map[string]string{ - "paused": "false", - "skip_checking": "true", - "autoTMM": "false", - "firstLastPiecePrio": "false", - "ratioLimit": "2.00", - "savepath": "/home/test/torrents", - "seedingTimeLimit": "100", - "category": "test", - "tags": "limited,slow", - "upLimit": "102400000", - "dlLimit": "102400000", - "rename": "test-torrent-rename", + "paused": "false", + "skip_checking": "true", + "autoTMM": "false", + "toggleFirstLastPiecePrio": "false", + "ratioLimit": "2.00", + "savepath": "/home/test/torrents", + "seedingTimeLimit": "100", + "category": "test", + "tags": "limited,slow", + "upLimit": "102400000", + "dlLimit": "102400000", + "rename": "test-torrent-rename", }, }, { @@ -196,18 +196,18 @@ func TestTorrentAddOptions_Prepare(t *testing.T) { Rename: "test-torrent-rename", }, want: map[string]string{ - "paused": "false", - "skip_checking": "true", - "autoTMM": "false", - "firstLastPiecePrio": "true", - "ratioLimit": "2.00", - "savepath": "/home/test/torrents", - "seedingTimeLimit": "100", - "category": "test", - "tags": "limited,slow", - "upLimit": "102400000", - "dlLimit": "102400000", - "rename": "test-torrent-rename", + "paused": "false", + "skip_checking": "true", + "autoTMM": "false", + "toggleFirstLastPiecePrio": "true", + "ratioLimit": "2.00", + "savepath": "/home/test/torrents", + "seedingTimeLimit": "100", + "category": "test", + "tags": "limited,slow", + "upLimit": "102400000", + "dlLimit": "102400000", + "rename": "test-torrent-rename", }, }, } From b048d2b63310dca6006c10e42df071d9a9253ad5 Mon Sep 17 00:00:00 2001 From: s0up4200 Date: Thu, 18 Apr 2024 08:17:20 +0200 Subject: [PATCH 4/5] fix(domain): change from toggleFirstLastPiecePrio to firstLastPiecePrio --- domain.go | 34 ++++---- domain_test.go | 222 ++++++++++++++++++++++++------------------------- 2 files changed, 126 insertions(+), 130 deletions(-) diff --git a/domain.go b/domain.go index 2ba9ecf..273459e 100644 --- a/domain.go +++ b/domain.go @@ -261,19 +261,19 @@ const ( ) type TorrentAddOptions struct { - Paused bool - SkipHashCheck bool - ContentLayout ContentLayout - SavePath string - AutoTMM bool - Category string - Tags string - LimitUploadSpeed int64 - LimitDownloadSpeed int64 - LimitRatio float64 - LimitSeedTime int64 - Rename string - ToggleFirstLastPiecePrio bool + Paused bool + SkipHashCheck bool + ContentLayout ContentLayout + SavePath string + AutoTMM bool + Category string + Tags string + LimitUploadSpeed int64 + LimitDownloadSpeed int64 + LimitRatio float64 + LimitSeedTime int64 + Rename string + FirstLastPiecePrio bool } func (o *TorrentAddOptions) Prepare() map[string]string { @@ -330,11 +330,7 @@ func (o *TorrentAddOptions) Prepare() map[string]string { options["rename"] = o.Rename } - if o.ToggleFirstLastPiecePrio { - options["toggleFirstLastPiecePrio"] = "true" - } else { - options["toggleFirstLastPiecePrio"] = "false" - } + options["firstLastPiecePrio"] = strconv.FormatBool(o.FirstLastPiecePrio) return options } @@ -406,7 +402,7 @@ type AppPreferences struct { AsyncIoThreads int `json:"async_io_threads"` AutoDeleteMode int `json:"auto_delete_mode"` AutoTmmEnabled bool `json:"auto_tmm_enabled"` - ToggleFirstLastPiecePrio bool `json:"toggle_first_last_piece_prio"` + FirstLastPiecePrioEnabled bool `json:"first_last_piece_prio_enabled"` AutorunEnabled bool `json:"autorun_enabled"` AutorunOnTorrentAddedEnabled bool `json:"autorun_on_torrent_added_enabled"` AutorunOnTorrentAddedProgram string `json:"autorun_on_torrent_added_program"` diff --git a/domain_test.go b/domain_test.go index 85971ee..8c03a57 100644 --- a/domain_test.go +++ b/domain_test.go @@ -8,19 +8,19 @@ import ( func TestTorrentAddOptions_Prepare(t *testing.T) { type fields struct { - Paused bool - SkipHashCheck bool - ContentLayout ContentLayout - SavePath string - AutoTMM bool - Category string - Tags string - LimitUploadSpeed int64 - LimitDownloadSpeed int64 - LimitRatio float64 - LimitSeedTime int64 - Rename string - ToggleFirstLastPiecePrio bool + Paused bool + SkipHashCheck bool + ContentLayout ContentLayout + SavePath string + AutoTMM bool + Category string + Tags string + LimitUploadSpeed int64 + LimitDownloadSpeed int64 + LimitRatio float64 + LimitSeedTime int64 + Rename string + FirstLastPiecePrio bool } tests := []struct { name string @@ -43,17 +43,17 @@ func TestTorrentAddOptions_Prepare(t *testing.T) { LimitSeedTime: 100, }, want: map[string]string{ - "paused": "false", - "skip_checking": "true", - "autoTMM": "false", - "toggleFirstLastPiecePrio": "false", - "ratioLimit": "2.00", - "savepath": "/home/test/torrents", - "seedingTimeLimit": "100", - "category": "test", - "tags": "limited,slow", - "upLimit": "102400000", - "dlLimit": "102400000", + "paused": "false", + "skip_checking": "true", + "autoTMM": "false", + "firstLastPiecePrio": "false", + "ratioLimit": "2.00", + "savepath": "/home/test/torrents", + "seedingTimeLimit": "100", + "category": "test", + "tags": "limited,slow", + "upLimit": "102400000", + "dlLimit": "102400000", }, }, { @@ -72,19 +72,19 @@ func TestTorrentAddOptions_Prepare(t *testing.T) { LimitSeedTime: 100, }, want: map[string]string{ - "paused": "false", - "skip_checking": "true", - "root_folder": "true", - "contentLayout": "Subfolder", - "autoTMM": "false", - "toggleFirstLastPiecePrio": "false", - "ratioLimit": "2.00", - "savepath": "/home/test/torrents", - "seedingTimeLimit": "100", - "category": "test", - "tags": "limited,slow", - "upLimit": "102400000", - "dlLimit": "102400000", + "paused": "false", + "skip_checking": "true", + "root_folder": "true", + "contentLayout": "Subfolder", + "autoTMM": "false", + "firstLastPiecePrio": "false", + "ratioLimit": "2.00", + "savepath": "/home/test/torrents", + "seedingTimeLimit": "100", + "category": "test", + "tags": "limited,slow", + "upLimit": "102400000", + "dlLimit": "102400000", }, }, { @@ -103,19 +103,19 @@ func TestTorrentAddOptions_Prepare(t *testing.T) { LimitSeedTime: 100, }, want: map[string]string{ - "paused": "false", - "skip_checking": "true", - "root_folder": "false", - "contentLayout": "NoSubfolder", - "autoTMM": "false", - "toggleFirstLastPiecePrio": "false", - "ratioLimit": "2.00", - "savepath": "/home/test/torrents", - "seedingTimeLimit": "100", - "category": "test", - "tags": "limited,slow", - "upLimit": "102400000", - "dlLimit": "102400000", + "paused": "false", + "skip_checking": "true", + "root_folder": "false", + "contentLayout": "NoSubfolder", + "autoTMM": "false", + "firstLastPiecePrio": "false", + "ratioLimit": "2.00", + "savepath": "/home/test/torrents", + "seedingTimeLimit": "100", + "category": "test", + "tags": "limited,slow", + "upLimit": "102400000", + "dlLimit": "102400000", }, }, { @@ -134,17 +134,17 @@ func TestTorrentAddOptions_Prepare(t *testing.T) { LimitSeedTime: 100, }, want: map[string]string{ - "paused": "false", - "skip_checking": "true", - "autoTMM": "false", - "toggleFirstLastPiecePrio": "false", - "ratioLimit": "2.00", - "savepath": "/home/test/torrents", - "seedingTimeLimit": "100", - "category": "test", - "tags": "limited,slow", - "upLimit": "102400000", - "dlLimit": "102400000", + "paused": "false", + "skip_checking": "true", + "autoTMM": "false", + "firstLastPiecePrio": "false", + "ratioLimit": "2.00", + "savepath": "/home/test/torrents", + "seedingTimeLimit": "100", + "category": "test", + "tags": "limited,slow", + "upLimit": "102400000", + "dlLimit": "102400000", }, }, { @@ -164,69 +164,69 @@ func TestTorrentAddOptions_Prepare(t *testing.T) { Rename: "test-torrent-rename", }, want: map[string]string{ - "paused": "false", - "skip_checking": "true", - "autoTMM": "false", - "toggleFirstLastPiecePrio": "false", - "ratioLimit": "2.00", - "savepath": "/home/test/torrents", - "seedingTimeLimit": "100", - "category": "test", - "tags": "limited,slow", - "upLimit": "102400000", - "dlLimit": "102400000", - "rename": "test-torrent-rename", + "paused": "false", + "skip_checking": "true", + "autoTMM": "false", + "firstLastPiecePrio": "false", + "ratioLimit": "2.00", + "savepath": "/home/test/torrents", + "seedingTimeLimit": "100", + "category": "test", + "tags": "limited,slow", + "upLimit": "102400000", + "dlLimit": "102400000", + "rename": "test-torrent-rename", }, }, { name: "test_06", fields: fields{ - Paused: false, - SkipHashCheck: true, - ContentLayout: ContentLayoutOriginal, - SavePath: "/home/test/torrents", - AutoTMM: false, - ToggleFirstLastPiecePrio: true, - Category: "test", - Tags: "limited,slow", - LimitUploadSpeed: 100000, - LimitDownloadSpeed: 100000, - LimitRatio: 2.0, - LimitSeedTime: 100, - Rename: "test-torrent-rename", + Paused: false, + SkipHashCheck: true, + ContentLayout: ContentLayoutOriginal, + SavePath: "/home/test/torrents", + AutoTMM: false, + FirstLastPiecePrio: true, + Category: "test", + Tags: "limited,slow", + LimitUploadSpeed: 100000, + LimitDownloadSpeed: 100000, + LimitRatio: 2.0, + LimitSeedTime: 100, + Rename: "test-torrent-rename", }, want: map[string]string{ - "paused": "false", - "skip_checking": "true", - "autoTMM": "false", - "toggleFirstLastPiecePrio": "true", - "ratioLimit": "2.00", - "savepath": "/home/test/torrents", - "seedingTimeLimit": "100", - "category": "test", - "tags": "limited,slow", - "upLimit": "102400000", - "dlLimit": "102400000", - "rename": "test-torrent-rename", + "paused": "false", + "skip_checking": "true", + "autoTMM": "false", + "firstLastPiecePrio": "true", + "ratioLimit": "2.00", + "savepath": "/home/test/torrents", + "seedingTimeLimit": "100", + "category": "test", + "tags": "limited,slow", + "upLimit": "102400000", + "dlLimit": "102400000", + "rename": "test-torrent-rename", }, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { o := &TorrentAddOptions{ - Paused: tt.fields.Paused, - SkipHashCheck: tt.fields.SkipHashCheck, - ContentLayout: tt.fields.ContentLayout, - SavePath: tt.fields.SavePath, - AutoTMM: tt.fields.AutoTMM, - Category: tt.fields.Category, - Tags: tt.fields.Tags, - LimitUploadSpeed: tt.fields.LimitUploadSpeed, - LimitDownloadSpeed: tt.fields.LimitDownloadSpeed, - LimitRatio: tt.fields.LimitRatio, - LimitSeedTime: tt.fields.LimitSeedTime, - Rename: tt.fields.Rename, - ToggleFirstLastPiecePrio: tt.fields.ToggleFirstLastPiecePrio, + Paused: tt.fields.Paused, + SkipHashCheck: tt.fields.SkipHashCheck, + ContentLayout: tt.fields.ContentLayout, + SavePath: tt.fields.SavePath, + AutoTMM: tt.fields.AutoTMM, + Category: tt.fields.Category, + Tags: tt.fields.Tags, + LimitUploadSpeed: tt.fields.LimitUploadSpeed, + LimitDownloadSpeed: tt.fields.LimitDownloadSpeed, + LimitRatio: tt.fields.LimitRatio, + LimitSeedTime: tt.fields.LimitSeedTime, + Rename: tt.fields.Rename, + FirstLastPiecePrio: tt.fields.FirstLastPiecePrio, } got := o.Prepare() From 0a0794a3747d70bcded291dfb2c8ab64071a9a36 Mon Sep 17 00:00:00 2001 From: s0up4200 Date: Thu, 18 Apr 2024 12:22:31 +0200 Subject: [PATCH 5/5] remove from AppPreferences couldnt find info about it being present --- domain.go | 1 - 1 file changed, 1 deletion(-) diff --git a/domain.go b/domain.go index 273459e..7b83a5f 100644 --- a/domain.go +++ b/domain.go @@ -402,7 +402,6 @@ type AppPreferences struct { AsyncIoThreads int `json:"async_io_threads"` AutoDeleteMode int `json:"auto_delete_mode"` AutoTmmEnabled bool `json:"auto_tmm_enabled"` - FirstLastPiecePrioEnabled bool `json:"first_last_piece_prio_enabled"` AutorunEnabled bool `json:"autorun_enabled"` AutorunOnTorrentAddedEnabled bool `json:"autorun_on_torrent_added_enabled"` AutorunOnTorrentAddedProgram string `json:"autorun_on_torrent_added_program"`