From 9fed6b37355148930263135d0dd805920a6e6e90 Mon Sep 17 00:00:00 2001 From: metonym <127705169+metonyms@users.noreply.github.com> Date: Sun, 19 Mar 2023 13:25:53 -0700 Subject: [PATCH] feat(actions): rtorrent add folder rename toggle (#756) * feat(actions): rtorrent add folder rename toggle * refactor: use content layout --- internal/action/rtorrent.go | 30 ++++++++++++++++++++++-------- web/src/domain/constants.ts | 5 +++++ web/src/screens/filters/action.tsx | 12 +++++++++++- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/internal/action/rtorrent.go b/internal/action/rtorrent.go index de8b30b..87caf10 100644 --- a/internal/action/rtorrent.go +++ b/internal/action/rtorrent.go @@ -41,10 +41,17 @@ func (s *service) rtorrent(ctx context.Context, action *domain.Action, release d }) } if action.SavePath != "" { - args = append(args, &rtorrent.FieldValue{ - Field: rtorrent.DDirectory, - Value: action.SavePath, - }) + if action.ContentLayout == domain.ActionContentLayoutSubfolderNone { + args = append(args, &rtorrent.FieldValue{ + Field: "d.directory_base", + Value: action.SavePath, + }) + } else { + args = append(args, &rtorrent.FieldValue{ + Field: rtorrent.DDirectory, + Value: action.SavePath, + }) + } } if err := rt.Add(release.MagnetURI, args...); err != nil { @@ -77,10 +84,17 @@ func (s *service) rtorrent(ctx context.Context, action *domain.Action, release d }) } if action.SavePath != "" { - args = append(args, &rtorrent.FieldValue{ - Field: rtorrent.DDirectory, - Value: action.SavePath, - }) + if action.ContentLayout == domain.ActionContentLayoutSubfolderNone { + args = append(args, &rtorrent.FieldValue{ + Field: "d.directory_base", + Value: action.SavePath, + }) + } else { + args = append(args, &rtorrent.FieldValue{ + Field: rtorrent.DDirectory, + Value: action.SavePath, + }) + } } if err := rt.AddTorrent(tmpFile, args...); err != nil { diff --git a/web/src/domain/constants.ts b/web/src/domain/constants.ts index 7ac996d..7e95397 100644 --- a/web/src/domain/constants.ts +++ b/web/src/domain/constants.ts @@ -343,6 +343,11 @@ export const ActionContentLayoutOptions: SelectGenericOption[] = [ + { label: "No", description: "No", value: "ORIGINAL" }, + { label: "Yes", description: "Yes", value: "SUBFOLDER_NONE" } +]; + export interface OptionBasic { label: string; value: string; diff --git a/web/src/screens/filters/action.tsx b/web/src/screens/filters/action.tsx index 8954bc6..1eb25e4 100644 --- a/web/src/screens/filters/action.tsx +++ b/web/src/screens/filters/action.tsx @@ -1,6 +1,6 @@ import { AlertWarning } from "../../components/alerts"; import { DownloadClientSelect, NumberField, Select, SwitchGroup, TextField } from "../../components/inputs"; -import { ActionContentLayoutOptions, ActionTypeNameMap, ActionTypeOptions } from "../../domain/constants"; +import { ActionContentLayoutOptions, ActionRtorrentRenameOptions, ActionTypeNameMap, ActionTypeOptions } from "../../domain/constants"; import React, { Fragment, useRef } from "react"; import { useQuery } from "react-query"; import { APIClient } from "../../api/APIClient"; @@ -359,6 +359,16 @@ const TypeForm = ({ action, idx, clients }: TypeFormProps) => { placeholder="eg. /full/path/to/download_folder" /> +
+
+