Skip to content

Commit e7453d7

Browse files
committed
Add sequential download support in session settings and add torrent
Also fix same parameter in torrent settings
1 parent a8faee4 commit e7453d7

7 files changed

Lines changed: 42 additions & 17 deletions

File tree

src/components/modals/add.tsx

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ interface AddCommonProps extends React.PropsWithChildren {
4444
setLabels: React.Dispatch<string[]>,
4545
start: boolean,
4646
setStart: (b: boolean) => void,
47+
sequential: boolean,
48+
setSequential: (b: boolean) => void,
4749
priority: PriorityNumberType,
4850
setPriority: (p: PriorityNumberType) => void,
4951
disabled?: boolean,
@@ -64,6 +66,14 @@ function AddCommon(props: AddCommonProps) {
6466
onChange={(e) => { props.setStart(e.currentTarget.checked); }}
6567
my="xl"
6668
styles={{ root: { flexGrow: 1 } }} />
69+
{rpcVersion >= 18 &&
70+
<Checkbox
71+
label="Sequential download"
72+
checked={props.sequential}
73+
disabled={props.disabled}
74+
onChange={(e) => { props.setSequential(e.currentTarget.checked); }}
75+
my="xl"
76+
styles={{ root: { flexGrow: 1 } }} />}
6777
{props.children}
6878
<SegmentedControl
6979
color={PriorityColors.get(props.priority)}
@@ -89,6 +99,7 @@ function useCommonProps(opened: boolean) {
8999
const location = useTorrentLocation();
90100
const [labels, setLabels] = useState<string[]>([]);
91101
const [start, setStart] = useState<boolean>(true);
102+
const [sequential, setSequential] = useState<boolean>(false);
92103
const [priority, setPriority] = useState<PriorityNumberType>(0);
93104

94105
useEffect(() => {
@@ -104,6 +115,7 @@ function useCommonProps(opened: boolean) {
104115
setPriority((AddTorrentPriorityOptions.indexOf(
105116
config.values.interface.addTorrentPriority) - 1) as PriorityNumberType);
106117
}
118+
setSequential(config.values.interface.addTorrentSequential);
107119
}
108120
}, [config, opened]);
109121

@@ -114,20 +126,20 @@ function useCommonProps(opened: boolean) {
114126
setLabels,
115127
start,
116128
setStart,
129+
sequential,
130+
setSequential,
117131
priority,
118132
setPriority,
119-
}), [opened, location, labels, start, priority]);
133+
}), [opened, location, labels, start, sequential, priority]);
120134

121135
return useMemo(() => ({
122-
location,
123-
start,
124-
priority,
125136
props,
126137
onAdd: () => {
127138
config.values.interface.addTorrentStartSelection = start;
128139
config.values.interface.addTorrentPrioritySelection = priority;
140+
config.values.interface.addTorrentSequential = sequential;
129141
},
130-
}), [config, location, priority, props, start]);
142+
}), [config, props, start, priority, sequential]);
131143
}
132144

133145
function TabSwitchDropdown({ tabsRef }: { tabsRef: React.RefObject<ServerTabsRef> }) {
@@ -233,13 +245,14 @@ export function AddMagnet(props: AddCommonModalProps) {
233245
addMutation.mutate(
234246
{
235247
url: magnet,
236-
downloadDir: common.location.path,
248+
downloadDir: common.props.location.path,
237249
labels: common.props.labels,
238-
paused: !common.start,
239-
bandwidthPriority: common.priority,
250+
paused: !common.props.start,
251+
sequential_download: common.props.sequential,
252+
bandwidthPriority: common.props.priority,
240253
},
241254
);
242-
common.location.addPath(common.location.path);
255+
common.props.location.addPath(common.props.location.path);
243256
} else {
244257
mutateAddTrackers(
245258
{ torrentId: existingTorrent.id, trackers: magnetData?.trackers ?? [] },
@@ -549,17 +562,18 @@ export function AddTorrent(props: AddCommonModalProps) {
549562
return await addMutation.mutateAsync(
550563
{
551564
metainfo: td.metadata,
552-
downloadDir: common.location.path,
565+
downloadDir: common.props.location.path,
553566
labels: common.props.labels,
554-
paused: !common.start,
555-
bandwidthPriority: common.priority,
567+
paused: !common.props.start,
568+
sequential_download: common.props.sequential,
569+
bandwidthPriority: common.props.priority,
556570
unwanted: (td.files == null || torrentData.length > 1) ? undefined : fileTree.getUnwanted(),
557571
filePath: td.torrentPath,
558572
},
559573
);
560574
}));
561575

562-
common.location.addPath(common.location.path);
576+
common.props.location.addPath(common.props.location.path);
563577
} else {
564578
mutateAddTrackers(
565579
{ torrentId: existingTorrent.id, trackers: torrentData[0].trackers },

src/components/modals/daemon.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ function DownloadPanel({ form, session }: { form: UseFormReturnType<FormValues>,
114114
</Box>}
115115
{...form.getInputProps("session.start-added-torrents", { type: "checkbox" })} />
116116
</Grid.Col>
117+
{session["rpc-version"] as number >= 18 &&
118+
<Grid.Col>
119+
<Checkbox mt="lg"
120+
label="Download torrents sequentially"
121+
{...form.getInputProps("session.sequential_download", { type: "checkbox" })} />
122+
</Grid.Col>}
117123
<Grid.Col>
118124
<Checkbox mt="lg"
119125
label="Add .part extension to incomplete files"

src/components/modals/edittorrent.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export function EditTorrent(props: ModalState) {
7070
seedIdleMode: torrent.seedIdleMode,
7171
seedIdleLimit: torrent.seedIdleLimit,
7272
honorsSessionLimits: torrent.honorsSessionLimits,
73-
sequentialDownload: torrent.sequentialDownload,
73+
sequentialDownload: torrent.sequential_download,
7474
});
7575
}, [setValues, torrent]);
7676

@@ -85,6 +85,7 @@ export function EditTorrent(props: ModalState) {
8585
fields: {
8686
...form.values,
8787
"peer-limit": form.values.peerLimit,
88+
"sequential_download": form.values.sequentialDownload,
8889
},
8990
},
9091
{

src/components/tables/torrenttable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ export function StatusField(props: TableFieldProps) {
315315
let status: string = StatusStrings[props.torrent.status];
316316
if (props.torrent.status === Status.downloading && props.torrent.pieceCount === 0) status = "Magnetizing";
317317

318-
const sequential = (props.torrent.status === Status.downloading && props.torrent.sequentialDownload === true) ? " sequentially" : "";
318+
const sequential = (props.torrent.status === Status.downloading && props.torrent.sequential_download === true) ? " sequentially" : "";
319319
return <div>{status + sequential}</div>;
320320
}
321321

src/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ interface Settings {
170170
skipAddDialog: boolean,
171171
addTorrentStart: AddTorrentStartOption,
172172
addTorrentStartSelection: boolean,
173+
addTorrentSequential: boolean,
173174
addTorrentPriority: AddTorrentPriorityOption,
174175
addTorrentPrioritySelection: PriorityNumberType, // normal priority
175176
deleteTorrentData: DeleteTorrentDataOption,
@@ -303,6 +304,7 @@ const DefaultSettings: Settings = {
303304
skipAddDialog: false,
304305
addTorrentStart: "default on",
305306
addTorrentStartSelection: true,
307+
addTorrentSequential: false,
306308
addTorrentPriority: "default normal",
307309
addTorrentPrioritySelection: 0, // normal priority
308310
deleteTorrentData: "default off",

src/rpc/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export interface TorrentAddParams {
6161
downloadDir: string,
6262
labels: string[],
6363
paused: boolean,
64+
sequential_download: boolean,
6465
bandwidthPriority: PriorityNumberType,
6566
unwanted?: number[],
6667
}

src/rpc/transmission.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export const TorrentFields = [
124124
"seedIdleMode", // number tr_inactvelimit
125125
"seedRatioLimit", // double tr_torrent
126126
"seedRatioMode", // number tr_ratiolimit
127-
"sequentialDownload", // boolean download torrent pieces sequentially
127+
"sequential_download", // boolean download torrent pieces sequentially
128128
"startDate", // number tr_stat
129129
"totalSize", // number tr_torrent_view
130130
"torrentFile", // string tr_info
@@ -176,7 +176,7 @@ export const TorrentMutableFields = [
176176
"seedIdleMode", // number which seeding inactivity to use. See tr_idlelimit
177177
"seedRatioLimit", // double torrent-level seeding ratio
178178
"seedRatioMode", // number which ratio to use. See tr_ratiolimit
179-
"sequentialDownload", // boolean download torrent pieces sequentially
179+
"sequential_download", // boolean download torrent pieces sequentially
180180
"trackerAdd", // array DEPRECATED use trackerList instead
181181
"trackerList", // string string of announce URLs, one per line, and a blank line between tiers.
182182
"trackerRemove", // array DEPRECATED use trackerList instead
@@ -254,6 +254,7 @@ export const SessionAllFields = [
254254
"seed-queue-size", // number: max number of torrents to uploaded at once (see seed-queue-enabled)
255255
"seedRatioLimit", // double: the default seed ratio for torrents to use
256256
"seedRatioLimited", // boolean: true if seedRatioLimit is honored by default
257+
"sequential_download", // boolean download torrent pieces sequentially
257258
"start-added-torrents", // boolean: true means added torrents will be started right away
258259
"trash-original-torrent-files", // boolean: true means the .torrent file of added torrents will be deleted
259260
"units", // object: see below

0 commit comments

Comments
 (0)