Skip to content

A full-featured download manager.

feat(settings): polish platform and download controls (#1928)

Dr_rOot62ec10025d0e
diff --git a/extra/aria2.conf b/extra/aria2.conf
index ead109b9..671e4d05 100644
--- a/extra/aria2.conf
+++ b/extra/aria2.conf
@@ -42,9 +42,9 @@ http-accept-gzip=true
# charset='UTF-8' explicitly.
content-disposition-default-utf8=true
-# Apply remote Last-Modified to local file mtime. Useful for incremental
-# sync tools and mirror integrity checks.
-remote-time=true
+# Keep the local completion time as the file mtime by default. The Downloads
+# settings can opt in to applying the remote Last-Modified timestamp instead.
+remote-time=false
# Verify TLS certificates strictly. motrix-turbo is a desktop tool, not a
# server; users wanting a self-signed mirror can disable per-task in UI
diff --git a/src/core/engine/aria2/aria2-config-builder.test.ts b/src/core/engine/aria2/aria2-config-builder.test.ts
index 1f9da08a..f8c7ad07 100644
--- a/src/core/engine/aria2/aria2-config-builder.test.ts
+++ b/src/core/engine/aria2/aria2-config-builder.test.ts
@@ -250,6 +250,7 @@ describe('Aria2ConfigBuilder', () => {
expect(args).toContain(
`--lowest-speed-limit=${DEFAULT_ENGINE_SETTINGS.lowestSpeedLimit}`
)
+ expect(args).toContain('--remote-time=false')
})
it('injects all BitTorrent flags', () => {
@@ -288,6 +289,7 @@ describe('Aria2ConfigBuilder', () => {
maxTries: 0,
retryWait: 5,
lowestSpeedLimit: 1024,
+ remoteTime: true,
btMaxPeers: 256,
btEnableLpd: false,
seedRatio: 2,
@@ -303,6 +305,7 @@ describe('Aria2ConfigBuilder', () => {
expect(args).toContain('--max-tries=0')
expect(args).toContain('--retry-wait=5')
expect(args).toContain('--lowest-speed-limit=1024')
+ expect(args).toContain('--remote-time=true')
expect(args).toContain('--bt-max-peers=256')
expect(args).toContain('--bt-enable-lpd=false')
expect(args).toContain('--seed-ratio=2')
diff --git a/src/core/engine/aria2/aria2-config-builder.ts b/src/core/engine/aria2/aria2-config-builder.ts
index 016e900c..6a3c7dfa 100644
--- a/src/core/engine/aria2/aria2-config-builder.ts
+++ b/src/core/engine/aria2/aria2-config-builder.ts
@@ -114,6 +114,7 @@ export class Aria2ConfigBuilder {
`--seed-ratio=${settings.seedRatio}`,
`--seed-time=${settings.seedTime}`,
`--file-allocation=${settings.fileAllocation}`,
+ `--remote-time=${settings.remoteTime}`,
`--disk-cache=${settings.diskCache}`,
`--save-session-interval=${settings.sessionSaveInterval}`
)
diff --git a/src/core/engine/engine-supervisor.test.ts b/src/core/engine/engine-supervisor.test.ts
index 360f049d..5053e25c 100644
--- a/src/core/engine/engine-supervisor.test.ts
+++ b/src/core/engine/engine-supervisor.test.ts
@@ -1004,6 +1004,7 @@ describe('EngineSupervisor', () => {
split: 32,
userAgent: 'Motrix/Test',
btEnableLpd: false,
+ remoteTime: true,
sessionSaveInterval: 30,
fileAllocation: 'prealloc',
diskCache: 32 * 1024 * 1024,
@@ -1013,6 +1014,7 @@ describe('EngineSupervisor', () => {
split: '32',
'user-agent': 'Motrix/Test',
'bt-enable-lpd': 'false',
+ 'remote-time': 'true',
'save-session-interval': '30',
})
})
diff --git a/src/core/engine/engine-supervisor.ts b/src/core/engine/engine-supervisor.ts
index 080e506b..49a8d083 100644
--- a/src/core/engine/engine-supervisor.ts
+++ b/src/core/engine/engine-supervisor.ts
@@ -62,6 +62,7 @@ const HOT_ENGINE_OPTIONS = {
btEnableLpd: 'bt-enable-lpd',
seedRatio: 'seed-ratio',
seedTime: 'seed-time',
+ remoteTime: 'remote-time',
sessionSaveInterval: 'save-session-interval',
} as const satisfies Partial<Record<keyof EngineSettings, string>>
diff --git a/src/main/platform/desktop-background-policy.test.ts b/src/main/platform/desktop-background-policy.test.ts
index 13c3cbc8..8ab4b579 100644
--- a/src/main/platform/desktop-background-policy.test.ts
+++ b/src/main/platform/desktop-background-policy.test.ts
@@ -48,16 +48,19 @@ describe('resolveDesktopBackgroundPolicy', () => {
}
)
- it('preserves legacy HideTray behavior when lightweight mode is disabled', () => {
- expect(
- resolveDesktopBackgroundPolicy({
- lightweightMode: false,
- platform: 'win32',
- runMode: RunMode.HideTray,
+ it.each<NodeJS.Platform>(['win32', 'linux'])(
+ 'keeps a reopen surface for unsupported HideTray on %s',
+ (platform) => {
+ expect(
+ resolveDesktopBackgroundPolicy({
+ lightweightMode: false,
+ platform,
+ runMode: RunMode.HideTray,
+ })
+ ).toEqual({
+ keepTray: true,
+ releaseMainWindowWhenHidden: false,
})
- ).toEqual({
- keepTray: false,
- releaseMainWindowWhenHidden: false,
- })
- })
+ }
+ )
})
diff --git a/src/main/platform/desktop-background-policy.ts b/src/main/platform/desktop-background-policy.ts
index 2d01a285..27cddf82 100644
--- a/src/main/platform/desktop-background-policy.ts
+++ b/src/main/platform/desktop-background-policy.ts
@@ -17,8 +17,10 @@ export function resolveDesktopBackgroundPolicy({
platform,
runMode,
}: DesktopBackgroundPolicyInput): DesktopBackgroundPolicy {
- const keepTray =
- runMode !== RunMode.HideTray || (lightweightMode && platform !== 'darwin')
+ // HideTray is a macOS-only mode because the Dock remains a reliable reopen
+ // surface there. Windows and Linux must always keep the tray, including for
+ // stale or manually edited settings that contain the unsupported value.
+ const keepTray = platform !== 'darwin' || runMode !== RunMode.HideTray
return {
keepTray,
diff --git a/src/main/platform/tray.test.ts b/src/main/platform/tray.test.ts
index 79ea96a2..773befb5 100644
--- a/src/main/platform/tray.test.ts
+++ b/src/main/platform/tray.test.ts
@@ -173,7 +173,7 @@ describe('setupTray', () => {
}
)
- it('creates and removes the forced tray as lightweight mode changes', async () => {
+ it('keeps a tray for stale Linux HideTray as lightweight mode changes', async () => {
Object.defineProperty(process, 'platform', { value: 'linux' })
const deps = createDeps({
lightweightMode: false,
@@ -181,7 +181,9 @@ describe('setupTray', () => {
traySpeedometer: false,
})
const handle = setupTray(deps)
- expect(trayConstructor).not.toHaveBeenCalled()
+ await vi.waitFor(() => {
+ expect(trayConstructor).toHaveBeenCalledOnce()
+ })
const settingsChanged = (
deps.eventBus.on as unknown as ReturnType<typeof vi.fn>
@@ -197,10 +199,6 @@ describe('setupTray', () => {
},
})
- await vi.waitFor(() => {
- expect(trayConstructor).toHaveBeenCalled()
- })
-
settingsChanged?.({
old: {
app: { lightweightMode: true, runMode: RunMode.HideTray },
@@ -209,7 +207,8 @@ describe('setupTray', () => {
app: { lightweightMode: false, runMode: RunMode.HideTray },
},
})
- expect(trayInstance.destroy).toHaveBeenCalledOnce()
+ expect(trayConstructor).toHaveBeenCalledOnce()
+ expect(trayInstance.destroy).not.toHaveBeenCalled()
handle.destroy()
})
@@ -256,32 +255,50 @@ describe('setupTray', () => {
handle.destroy()
})
- it.each(['darwin', 'linux'] as const)(
- 'preserves the tray-menu behavior on %s left click',
- async (platform) => {
- Object.defineProperty(process, 'platform', { value: platform })
+ it('opens the tray menu on macOS click', async () => {
+ Object.defineProperty(process, 'platform', { value: 'darwin' })
- const handle = setupTray(createDeps())
+ const handle = setupTray(createDeps())
- await vi.waitFor(() => {
- expect(trayInstance.on).toHaveBeenCalledWith(
- 'click',
- expect.any(Function)
- )
- })
+ await vi.waitFor(() => {
+ expect(trayInstance.on).toHaveBeenCalledWith(
+ 'click',
+ expect.any(Function)
+ )
+ })
- getTrayHandler('click')()
+ getTrayHandler('click')()
+
+ expect(trayInstance.popUpContextMenu).toHaveBeenCalledExactlyOnceWith(
+ trayMenu
+ )
+ expect(toggleMainWindow).not.toHaveBeenCalled()
- expect(trayInstance.popUpContextMenu).toHaveBeenCalledExactlyOnceWith(
- trayMenu
+ handle.destroy()
+ })
+
+ it('toggles the main window on Linux activation and uses the bound menu', async () => {
+ Object.defineProperty(process, 'platform', { value: 'linux' })
+
+ const handle = setupTray(createDeps())
+
+ await vi.waitFor(() => {
+ expect(trayInstance.on).toHaveBeenCalledWith(
+ 'click',
+ expect.any(Function)
)
- expect(toggleMainWindow).not.toHaveBeenCalled()
+ })
- if (platform === 'linux') {
- expect(trayInstance.setContextMenu).toHaveBeenCalledWith(trayMenu)
- }
+ getTrayHandler('click')()
- handle.destroy()
- }
- )
+ expect(toggleMainWindow).toHaveBeenCalledOnce()
+ expect(trayInstance.setContextMenu).toHaveBeenCalledWith(trayMenu)
+ expect(trayInstance.popUpContextMenu).not.toHaveBeenCalled()
+ expect(trayInstance.on).not.toHaveBeenCalledWith(
+ 'right-click',
+ expect.any(Function)
+ )
+
+ handle.destroy()
+ })
})
diff --git a/src/main/platform/tray.ts b/src/main/platform/tray.ts
index bbf68d87..9f37aa40 100644
--- a/src/main/platform/tray.ts
+++ b/src/main/platform/tray.ts
@@ -112,7 +112,7 @@ export function setupTray(deps: TrayDeps): TrayHandle {
// Events
tray.on('click', () => {
- if (process.platform === 'win32') {
+ if (process.platform !== 'darwin') {
toggleMainWindow()
return
}
@@ -120,9 +120,13 @@ export function setupTray(deps: TrayDeps): TrayHandle {
if (currentMenu) tray?.popUpContextMenu(currentMenu)
})
- tray.on('right-click', () => {
- if (currentMenu) tray?.popUpContextMenu(currentMenu)
- })
+ // Electron only supports right-click and popUpContextMenu on macOS and
+ // Windows. Linux delegates the context action to setContextMenu above.
+ if (process.platform !== 'linux') {
+ tray.on('right-click', () => {
+ if (currentMenu) tray?.popUpContextMenu(currentMenu)
+ })
+ }
// macOS: ignore double-click, enable drop
if (process.platform === 'darwin') {
diff --git a/src/renderer/routes/settings/cards/advanced-dialog.tsx b/src/renderer/routes/settings/cards/advanced-dialog.tsx
index 61c3e44f..7697141b 100644
--- a/src/renderer/routes/settings/cards/advanced-dialog.tsx
+++ b/src/renderer/routes/settings/cards/advanced-dialog.tsx
@@ -131,7 +131,7 @@ export function AdvancedDialog({
type="number"
min={1024}
max={65535}
- className="w-24 h-8"
+ className="w-30 h-8"
value={field.value}
onChange={(e) => {
const n = Number.parseInt(e.target.value, 10)
@@ -257,7 +257,7 @@ export function AdvancedDialog({
<Input
type="number"
min={-1}
- className="w-24 h-8"
+ className="w-30 h-8"
disabled={!persistenceOn}
value={field.value}
onChange={(e) => {
diff --git a/src/renderer/routes/settings/cards/appearance-dialog.test.tsx b/src/renderer/routes/settings/cards/appearance-dialog.test.tsx
index b0d938ef..8eb7723c 100644
--- a/src/renderer/routes/settings/cards/appearance-dialog.test.tsx
+++ b/src/renderer/routes/settings/cards/appearance-dialog.test.tsx
@@ -55,6 +55,10 @@ beforeAll(() => {
beforeEach(async () => {
await i18n.changeLanguage('en-US')
+ Object.defineProperty(transport, 'platform', {
+ configurable: true,
+ value: 'darwin',
+ })
vi.stubGlobal('ResizeObserver', MockResizeObserver)
vi.mocked(transport.invoke).mockReset()
vi.mocked(transport.invoke).mockImplementation(async (channel: string) => {
@@ -82,11 +86,91 @@ describe('<AppearanceDialog>', () => {
expect(themeTrigger).not.toHaveTextContent(/^system$/)
expect(languageTrigger).toHaveTextContent(/^English$/)
expect(languageTrigger).not.toHaveTextContent(/^en-US$/)
- expect(languageTrigger).toHaveClass('min-w-32', 'max-w-64')
+ expect(languageTrigger).toHaveClass('min-w-30', 'max-w-64')
expect(languageTrigger).not.toHaveClass('w-32')
- expect(runModeTrigger).toHaveTextContent(/^Standard application$/)
+ expect(runModeTrigger).toHaveTextContent(/^Dock & Menu Bar$/)
expect(runModeTrigger).not.toHaveTextContent(/^1$/)
})
+
+ const user = userEvent.setup({ pointerEventsCheck: 0 })
+ await user.click(
+ screen.getByRole('combobox', {
+ name: 'Show app in',
+ })
+ )
+ expect(
+ await screen.findByRole('option', { name: 'Dock & Menu Bar' })
+ ).toBeInTheDocument()
+ expect(
+ screen.getByRole('option', { name: 'Menu Bar Only' })
+ ).toBeInTheDocument()
+ expect(
+ screen.getByRole('option', { name: 'Dock Only' })
+ ).toBeInTheDocument()
+ })
+
+ it.each(['win32', 'linux'] as const)(
+ 'uses launch behavior labels on %s',
+ async (platform) => {
+ Object.defineProperty(transport, 'platform', {
+ configurable: true,
+ value: platform,
+ })
+ render(
+ <AppearanceDialog
+ open
+ onClose={vi.fn()}
+ labelKey="settings.cards.appearance.title"
+ descKey="settings.cards.appearance.desc"
+ />
+ )
+
+ const runModeTrigger = await screen.findByRole('combobox', {
+ name: 'When opening Motrix',
+ })
+ expect(runModeTrigger).toHaveTextContent(/^Open Main Window$/)
+
+ const user = userEvent.setup({ pointerEventsCheck: 0 })
+ await user.click(runModeTrigger)
+ expect(
+ await screen.findByRole('option', { name: 'Open Main Window' })
+ ).toBeInTheDocument()
+ expect(
+ screen.getByRole('option', { name: 'Start in System Tray' })
+ ).toBeInTheDocument()
+ expect(screen.queryByRole('option', { name: 'Dock Only' })).toBeNull()
+
+ if (platform === 'linux') {
+ expect(
+ screen.getByText(/depend on your desktop environment/i)
+ ).toBeInTheDocument()
+ }
+ }
+ )
+
+ it('does not show desktop run-mode settings on the web', async () => {
+ Object.defineProperty(transport, 'platform', {
+ configurable: true,
+ value: 'web',
+ })
+ render(
+ <AppearanceDialog
+ open
+ onClose={vi.fn()}
+ labelKey="settings.cards.appearance.title"
+ descKey="settings.cards.appearance.desc"
+ />
+ )
+
+ await waitFor(() => {
+ expect(
+ screen.getByRole('combobox', { name: 'Theme' })
+ ).toBeInTheDocument()
+ })
+ expect(screen.queryByRole('combobox', { name: 'Show app in' })).toBeNull()
+ expect(
+ screen.queryByRole('combobox', { name: 'When opening Motrix' })
+ ).toBeNull()
})
it('hydrates and submits dirty changes', async () => {
diff --git a/src/renderer/routes/settings/cards/appearance-dialog.tsx b/src/renderer/routes/settings/cards/appearance-dialog.tsx
index f2abfab7..bd0d3e40 100644
--- a/src/renderer/routes/settings/cards/appearance-dialog.tsx
+++ b/src/renderer/routes/settings/cards/appearance-dialog.tsx
@@ -91,7 +91,11 @@ export function AppearanceDialog({
theme: all.app.theme,
language: all.app.language,
traySpeedometer: all.app.traySpeedometer,
- runMode: all.app.runMode,
+ runMode:
+ transport.platform !== 'darwin' &&
+ all.app.runMode === RunMode.HideTray
+ ? RunMode.Standard
+ : all.app.runMode,
liquidGlassEffect: all.app.liquidGlassEffect,
lightweightMode: all.app.lightweightMode,
})
@@ -133,21 +137,34 @@ export function AppearanceDialog({
value: AppearanceFields['theme']
label: string
}>
- const runModeOptions = [
- {
- value: String(RunMode.Standard),
- label: t('settings.appearance.runModeStandard'),
- },
- {
- value: String(RunMode.TrayOnly),
- label: t('settings.appearance.runModeTray'),
- },
- {
- value: String(RunMode.HideTray),
- label: t('settings.appearance.runModeHideTray'),
- },
- ]
- const showMacOnly = transport.platform === 'darwin'
+ const isMac = transport.platform === 'darwin'
+ const isLinux = transport.platform === 'linux'
+ const showRunMode = transport.platform !== 'web'
+ const runModeOptions = isMac
+ ? [
+ {
+ value: String(RunMode.Standard),
+ label: t('settings.appearance.runModeStandard'),
+ },
+ {
+ value: String(RunMode.TrayOnly),
+ label: t('settings.appearance.runModeTray'),
+ },
+ {
+ value: String(RunMode.HideTray),
+ label: t('settings.appearance.runModeHideTray'),
+ },
+ ]
+ : [
+ {
+ value: String(RunMode.Standard),
+ label: t('settings.appearance.runModeStandardDesktop'),
+ },
+ {
+ value: String(RunMode.TrayOnly),
+ label: t('settings.appearance.runModeTrayDesktop'),
+ },
+ ]
return (
<Dialog open={open} onOpenChange={(v) => !v && onClose()}>
@@ -177,7 +194,7 @@ export function AppearanceDialog({
if (value !== null) field.onChange(value)
}}
>
- <SelectTrigger className="w-32" size="sm">
+ <SelectTrigger className="w-30" size="sm">
<SelectValue />
</SelectTrigger>
<SelectContent>
@@ -212,7 +229,7 @@ export function AppearanceDialog({
if (isSupportedLocale(value)) field.onChange(value)
}}
>
- <SelectTrigger className="min-w-32 max-w-64" size="sm">
+ <SelectTrigger className="min-w-30 max-w-64" size="sm">
<SelectValue />
</SelectTrigger>
<SelectContent>
@@ -233,7 +250,7 @@ export function AppearanceDialog({
)}
/>
- {showMacOnly && (
+ {isMac && (
<FormField
control={form.control}
name="traySpeedometer"
@@ -258,7 +275,7 @@ export function AppearanceDialog({
/>
)}
- {showMacOnly && (
+ {isMac && (
<FormField
control={form.control}
name="liquidGlassEffect"
@@ -283,13 +300,26 @@ export function AppearanceDialog({
/>
)}
- {showMacOnly && (
+ {showRunMode && (
<FormField
control={form.control}
name="runMode"
render={({ field }) => (
<FormItem className="flex items-start justify-between gap-4">
- <FormLabel>{t('settings.appearance.runMode')}</FormLabel>
+ <div className="space-y-1">
+ <FormLabel>
+ {t(
+ isMac
+ ? 'settings.appearance.runMode'
+ : 'settings.appearance.runModeLaunch'
+ )}
+ </FormLabel>
+ {isLinux && (
+ <FormDescription className="text-xs">
+ {t('settings.appearance.runModeLinuxDesc')}
+ </FormDescription>
+ )}
+ </div>
<FormControl>
<Select
items={runModeOptions}
diff --git a/src/renderer/routes/settings/cards/bit-torrent-dialog.tsx b/src/renderer/routes/settings/cards/bit-torrent-dialog.tsx
index e2b45ab0..ad64eb39 100644
--- a/src/renderer/routes/settings/cards/bit-torrent-dialog.tsx
+++ b/src/renderer/routes/settings/cards/bit-torrent-dialog.tsx
@@ -175,7 +175,7 @@ export function BitTorrentDialog({
type="number"
min={1024}
max={65535}
- className="w-24 h-8"
+ className="w-30 h-8"
value={field.value}
onChange={(e) => {
const n = Number.parseInt(e.target.value, 10)
@@ -204,7 +204,7 @@ export function BitTorrentDialog({
type="number"
min={1024}
max={65535}
- className="w-24 h-8"
+ className="w-30 h-8"
value={field.value}
onChange={(e) => {
const n = Number.parseInt(e.target.value, 10)
@@ -262,7 +262,7 @@ export function BitTorrentDialog({
type="number"
min={1}
max={1000}
- className="w-24 h-8"
+ className="w-30 h-8"
value={field.value}
onChange={(e) => {
const n = Number.parseInt(e.target.value, 10)
@@ -343,7 +343,7 @@ export function BitTorrentDialog({
min={0}
max={100}
step={0.1}
- className="w-24 h-8"
+ className="w-30 h-8"
value={field.value}
onChange={(e) =>
field.onChange(Number.parseFloat(e.target.value) || 0)
@@ -371,7 +371,7 @@ export function BitTorrentDialog({
type="number"
min={0}
max={525600}
- className="w-24 h-8"
+ className="w-30 h-8"
value={field.value}
onChange={(e) => {
const n = Number.parseInt(e.target.value, 10)
@@ -435,7 +435,7 @@ export function BitTorrentDialog({
type="number"
min={1}
max={168}
- className="w-24 h-8"
+ className="w-30 h-8"
value={field.value}
onChange={(e) => {
const n = Number.parseInt(e.target.value, 10)
@@ -499,7 +499,7 @@ export function BitTorrentDialog({
min={1000}
max={30000}
step={500}
- className="w-28 h-8"
+ className="w-30 h-8"
value={field.value}
onChange={(e) => {
const n = Number.parseInt(e.target.value, 10)
@@ -542,7 +542,7 @@ export function BitTorrentDialog({
min={500}
max={10000}
step={100}
- className="w-24 h-8"
+ className="w-30 h-8"
value={field.value}
onChange={(e) => {
const n = Number.parseInt(e.target.value, 10)
@@ -582,7 +582,7 @@ export function BitTorrentDialog({
min={0}
max={1}
step={0.05}
- className="w-24 h-8"
+ className="w-30 h-8"
value={field.value}
onChange={(e) =>
field.onChange(Number.parseFloat(e.target.value) || 0)
@@ -614,7 +614,7 @@ export function BitTorrentDialog({
type="number"
min={5}
max={200}
- className="w-24 h-8"
+ className="w-30 h-8"
value={field.value}
onChange={(e) => {
const n = Number.parseInt(e.target.value, 10)
diff --git a/src/renderer/routes/settings/cards/compact-limit-input.tsx b/src/renderer/routes/settings/cards/compact-limit-input.tsx
new file mode 100644
index 00000000..faa21295
--- /dev/null
+++ b/src/renderer/routes/settings/cards/compact-limit-input.tsx
@@ -0,0 +1,115 @@
+import { Button } from '@renderer/components/ui/button'
+import { ButtonGroup } from '@renderer/components/ui/button-group'
+import {
+ InputGroup,
+ InputGroupAddon,
+ InputGroupInput,
+ InputGroupText,
+} from '@renderer/components/ui/input-group'
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipProvider,
+ TooltipTrigger,
+} from '@renderer/components/ui/tooltip'
+import { Infinity as InfinityIcon, RotateCcw } from 'lucide-react'
+import { type ComponentProps, forwardRef } from 'react'
+
+type ZeroAction = 'unlimited' | 'inherit'
+
+type CompactLimitInputProps = Omit<
+ ComponentProps<typeof InputGroupInput>,
+ 'type' | 'value' | 'onChange'
+> & {
+ value: number
+ onValueChange: (value: number) => void
+ unit: string
+ zeroLabel: string
+ resetLabel: string
+ zeroAction?: ZeroAction
+}
+
+export const CompactLimitInput = forwardRef<
+ HTMLInputElement,
+ CompactLimitInputProps
+>(function CompactLimitInput(
+ {
+ value,
+ onValueChange,
+ unit,
+ zeroLabel,
+ resetLabel,
+ zeroAction = 'unlimited',
+ onKeyDown,
+ ...props
+ },
+ ref
+) {
+ const zero = value <= 0
+ const ResetIcon = zeroAction === 'inherit' ? RotateCcw : InfinityIcon
+
+ return (
+ <ButtonGroup className="w-40 shrink-0">
+ {!zero && (
+ <TooltipProvider>
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <Button
+ type="button"
+ variant="outline"
+ size="icon-sm"
+ aria-label={resetLabel}
+ onClick={() => onValueChange(0)}
+ >
+ <ResetIcon aria-hidden />
+ </Button>
+ }
+ />
+ <TooltipContent>{resetLabel}</TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ )}
+ <InputGroup className="h-8 min-w-0 w-auto flex-1 bg-background">
+ <InputGroupInput
+ {...props}
+ ref={ref}
+ data-slot="input-group-control"
+ type="text"
+ role="spinbutton"
+ inputMode="numeric"
+ autoComplete="off"
+ aria-valuemin={0}
+ aria-valuenow={Math.max(0, value)}
+ aria-valuetext={zero ? zeroLabel : `${value} ${unit}`}
+ className="h-8 min-w-0 px-2 text-right tabular-nums placeholder:text-right placeholder:text-xs"
+ value={zero ? '' : value}
+ placeholder={zeroLabel}
+ onChange={(event) => {
+ const nextValue = Number.parseInt(event.target.value, 10)
+ onValueChange(
+ Number.isFinite(nextValue) ? Math.max(0, nextValue) : 0
+ )
+ }}
+ onKeyDown={(event) => {
+ onKeyDown?.(event)
+ if (
+ event.defaultPrevented ||
+ (event.key !== 'ArrowUp' && event.key !== 'ArrowDown')
+ ) {
+ return
+ }
+ event.preventDefault()
+ const delta = event.key === 'ArrowUp' ? 1 : -1
+ onValueChange(Math.max(0, value + delta))
+ }}
+ />
+ {!zero && (
+ <InputGroupAddon align="inline-end" className="pr-2">
+ <InputGroupText className="text-[11px]">{unit}</InputGroupText>
+ </InputGroupAddon>
+ )}
+ </InputGroup>
+ </ButtonGroup>
+ )
+})
diff --git a/src/renderer/routes/settings/cards/downloads-dialog.test.tsx b/src/renderer/routes/settings/cards/downloads-dialog.test.tsx
index f18f0038..c5f436de 100644
--- a/src/renderer/routes/settings/cards/downloads-dialog.test.tsx
+++ b/src/renderer/routes/settings/cards/downloads-dialog.test.tsx
@@ -47,6 +47,7 @@ const FIXTURE = {
retryWait: 10,
lowestSpeedLimit: 0,
fileAllocation: 'none',
+ remoteTime: false,
diskCache: 32 * 1024 * 1024,
sessionSaveInterval: 15,
magnetResolveTimeout: 120,
@@ -226,6 +227,31 @@ describe('<DownloadsDialog>', () => {
expect(screen.queryByText(/restart to apply changes/i)).toBeNull()
})
+ it('selects the file modification time source and submits the aria2 setting', async () => {
+ render(
+ <DownloadsDialog
+ open
+ onClose={vi.fn()}
+ labelKey="settings.cards.downloads.title"
+ descKey="settings.cards.downloads.desc"
+ />
+ )
+
+ const user = userEvent.setup()
+ const modifiedTime = await screen.findByRole('combobox', {
+ name: /file modification time/i,
+ })
+ expect(modifiedTime).toHaveTextContent(/^local$/i)
+
+ await user.click(modifiedTime)
+ await user.click(await screen.findByRole('option', { name: /^server$/i }))
+ await user.click(screen.getByRole('button', { name: /save/i }))
+
+ expect(transport.invoke).toHaveBeenCalledWith(Commands.UpdateSettings, {
+ engine: { remoteTime: true },
+ })
+ })
+
it('renders the speed modes with user-facing names', async () => {
render(
<DownloadsDialog
@@ -317,6 +343,70 @@ describe('<DownloadsDialog>', () => {
expect(onClose).toHaveBeenCalled()
})
+ it('groups compact reset actions with their speed limit inputs', async () => {
+ vi.mocked(transport.invoke).mockImplementation(async (channel) => {
+ if (channel === Queries.GetSettings) {
+ return {
+ ...FIXTURE,
+ speedLimit: {
+ ...DEFAULT_SPEED_LIMIT_SETTINGS,
+ base: {
+ ...DEFAULT_SPEED_LIMIT_SETTINGS.base,
+ download: 1024 * 1024,
+ },
+ },
+ }
+ }
+ return { saved: true, requiresRestart: false, changedRestartKeys: [] }
+ })
+
+ render(
+ <DownloadsDialog
+ open
+ onClose={vi.fn()}
+ labelKey="settings.cards.downloads.title"
+ descKey="settings.cards.downloads.desc"
+ />
+ )
+
+ const user = userEvent.setup()
+ const baseDown = (await screen.findByLabelText(
+ /standard download limit/i
+ )) as HTMLInputElement
+ const altDown = screen.getByLabelText(
+ /low-speed download limit/i
+ ) as HTMLInputElement
+ const setUnlimited = screen.getByRole('button', {
+ name: /set unlimited/i,
+ })
+ const useStandard = screen
+ .getAllByRole('button', { name: /use standard limit/i })
+ .find((button) =>
+ button.closest('[data-slot="button-group"]')?.contains(altDown)
+ )
+
+ const standardGroup = setUnlimited.closest('[data-slot="button-group"]')
+ expect(standardGroup).toContainElement(baseDown)
+ expect(standardGroup).toHaveClass('w-40')
+ expect(useStandard).toBeDefined()
+
+ await user.click(setUnlimited)
+ await user.click(useStandard as HTMLElement)
+
+ expect(baseDown).toHaveValue('')
+ expect(baseDown).toHaveAttribute('placeholder', 'Unlimited')
+ expect(altDown).toHaveValue('')
+ expect(altDown).toHaveAttribute('placeholder', 'Standard limit')
+
+ await user.click(screen.getByRole('button', { name: /save/i }))
+ expect(transport.invoke).toHaveBeenCalledWith(Commands.UpdateSettings, {
+ speedLimit: {
+ base: { download: 0 },
+ alt: { download: 0 },
+ },
+ })
+ })
+
it('switching the turtle state to auto submits a turtle patch', async () => {
const onClose = vi.fn()
render(
diff --git a/src/renderer/routes/settings/cards/downloads-form.ts b/src/renderer/routes/settings/cards/downloads-form.ts
index 04ca3562..6c9581e9 100644
--- a/src/renderer/routes/settings/cards/downloads-form.ts
+++ b/src/renderer/routes/settings/cards/downloads-form.ts
@@ -23,6 +23,7 @@ export type EngineFields = Pick<
| 'retryWait'
| 'lowestSpeedLimit'
| 'fileAllocation'
+ | 'remoteTime'
| 'diskCache'
| 'sessionSaveInterval'
| 'magnetResolveTimeout'
@@ -55,6 +56,7 @@ export const ENGINE_DEFAULTS: EngineFields = {
retryWait: DEFAULT_ENGINE_SETTINGS.retryWait,
lowestSpeedLimit: DEFAULT_ENGINE_SETTINGS.lowestSpeedLimit,
fileAllocation: DEFAULT_ENGINE_SETTINGS.fileAllocation,
+ remoteTime: DEFAULT_ENGINE_SETTINGS.remoteTime,
diskCache: DEFAULT_ENGINE_SETTINGS.diskCache,
sessionSaveInterval: DEFAULT_ENGINE_SETTINGS.sessionSaveInterval,
magnetResolveTimeout: DEFAULT_ENGINE_SETTINGS.magnetResolveTimeout,
diff --git a/src/renderer/routes/settings/cards/engine-number-setting-row.tsx b/src/renderer/routes/settings/cards/engine-number-setting-row.tsx
index 0d2a5ce6..850f6534 100644
--- a/src/renderer/routes/settings/cards/engine-number-setting-row.tsx
+++ b/src/renderer/routes/settings/cards/engine-number-setting-row.tsx
@@ -63,7 +63,7 @@ export function EngineNumberSettingRow({
min={bounds.min}
max={bounds.max}
step={bounds.step}
- className="h-8 w-28"
+ className="w-30 h-8"
value={displayed}
onChange={(event) => {
const value = Number.parseInt(event.target.value, 10)
diff --git a/src/renderer/routes/settings/cards/engine-tuning-section.tsx b/src/renderer/routes/settings/cards/engine-tuning-section.tsx
index 137a84c1..d4d9e748 100644
--- a/src/renderer/routes/settings/cards/engine-tuning-section.tsx
+++ b/src/renderer/routes/settings/cards/engine-tuning-section.tsx
@@ -48,6 +48,16 @@ export function EngineTuningSection({
label: t('settings.downloads.disk.fileAllocationFalloc'),
},
] as const
+ const modifiedTimeOptions = [
+ {
+ value: 'local',
+ label: t('settings.downloads.disk.modifiedTimeLocal'),
+ },
+ {
+ value: 'server',
+ label: t('settings.downloads.disk.modifiedTimeServer'),
+ },
+ ] as const
const numericRow = (
name: keyof EngineFields,
labelKey: string,
@@ -188,6 +198,42 @@ export function EngineTuningSection({
</FormItem>
)}
/>
+ <FormField
+ control={form.control}
+ name="engine.remoteTime"
+ render={({ field }) => (
+ <FormItem className="flex items-start justify-between gap-4">
+ <div className="space-y-1">
+ <FormLabel>{t('settings.downloads.disk.modifiedTime')}</FormLabel>
+ <FormDescription className="text-xs">
+ {t('settings.downloads.disk.modifiedTimeDesc')}
+ </FormDescription>
+ </div>
+ <FormControl>
+ <Select
+ items={modifiedTimeOptions}
+ value={field.value ? 'server' : 'local'}
+ onValueChange={(value) => {
+ if (value !== null) field.onChange(value === 'server')
+ }}
+ >
+ <SelectTrigger className="w-30" size="sm">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectGroup>
+ {modifiedTimeOptions.map(({ label, value }) => (
+ <SelectItem key={value} value={value}>
+ {label}
+ </SelectItem>
+ ))}
+ </SelectGroup>
+ </SelectContent>
+ </Select>
+ </FormControl>
+ </FormItem>
+ )}
+ />
{numericRow(
'sessionSaveInterval',
'settings.downloads.disk.sessionSaveInterval',
diff --git a/src/renderer/routes/settings/cards/integration/media-tools-section.tsx b/src/renderer/routes/settings/cards/integration/media-tools-section.tsx
index 233fd692..b6d30fbb 100644
--- a/src/renderer/routes/settings/cards/integration/media-tools-section.tsx
+++ b/src/renderer/routes/settings/cards/integration/media-tools-section.tsx
@@ -239,7 +239,7 @@ export function MediaToolsSection() {
min={256}
max={65536}
data-testid="media-staging-mb-input"
- className="w-24 h-8"
+ className="w-30 h-8"
value={field.value}
onChange={(e) => {
const n = Number.parseInt(e.target.value, 10)
@@ -274,7 +274,7 @@ export function MediaToolsSection() {
min={60}
max={3600}
data-testid="media-op-timeout-sec-input"
- className="w-24 h-8"
+ className="w-30 h-8"
value={field.value}
onChange={(e) => {
const n = Number.parseInt(e.target.value, 10)
diff --git a/src/renderer/routes/settings/cards/network-dialog.tsx b/src/renderer/routes/settings/cards/network-dialog.tsx
index cd99c21a..a744af23 100644
--- a/src/renderer/routes/settings/cards/network-dialog.tsx
+++ b/src/renderer/routes/settings/cards/network-dialog.tsx
@@ -240,7 +240,7 @@ export function NetworkDialog({
if (value !== null) field.onChange(value)
}}
>
- <SelectTrigger className="w-35" size="sm">
+ <SelectTrigger className="w-30" size="sm">
<SelectValue />
</SelectTrigger>
<SelectContent>
@@ -274,7 +274,7 @@ export function NetworkDialog({
type="number"
min={1200}
max={7200}
- className="w-24 h-8"
+ className="w-30 h-8"
value={field.value}
onChange={(e) => {
const n = Number.parseInt(e.target.value, 10)
@@ -424,7 +424,7 @@ export function NetworkDialog({
type="number"
min={300}
max={86400}
- className="w-28 h-8"
+ className="w-30 h-8"
value={field.value}
onChange={(e) => {
const n = Number.parseInt(e.target.value, 10)
diff --git a/src/renderer/routes/settings/cards/proxy-section.tsx b/src/renderer/routes/settings/cards/proxy-section.tsx
index de4db98b..e913969f 100644
--- a/src/renderer/routes/settings/cards/proxy-section.tsx
+++ b/src/renderer/routes/settings/cards/proxy-section.tsx
@@ -209,7 +209,7 @@ export function ProxySection({ form }: { form: UseFormReturn<NetworkFields> }) {
control={form.control}
name="proxy.port"
render={({ field }) => (
- <FormItem className="w-28 space-y-0">
+ <FormItem className="w-30 space-y-0">
<FormControl>
<InputGroup className="h-8">
<InputGroupAddon align="inline-start">
diff --git a/src/renderer/routes/settings/cards/speed-limit-section.tsx b/src/renderer/routes/settings/cards/speed-limit-section.tsx
index 307ad3ec..12e420a8 100644
--- a/src/renderer/routes/settings/cards/speed-limit-section.tsx
+++ b/src/renderer/routes/settings/cards/speed-limit-section.tsx
@@ -24,6 +24,7 @@ import type { SpeedPoint } from '@shared/types/stats'
import { type ComponentProps, forwardRef, useEffect, useState } from 'react'
import type { UseFormReturn } from 'react-hook-form'
import { useTranslation } from 'react-i18next'
+import { CompactLimitInput } from './compact-limit-input'
import { type DownloadsFields, KB, MBPS } from './downloads-form'
const TIME_INPUT_CLS = 'h-8 w-24 bg-background font-mono tabular-nums'
@@ -252,58 +253,41 @@ export function SpeedLimitSection({
const adaptiveEnabled = settings.auto.adaptive.enabled
const summary = effectSummary(settings, t)
- const kbLimitRow = (name: KbLimitName, labelKey: string, descKey: string) => (
+ const kbLimitRow = (
+ name: KbLimitName,
+ labelKey: string,
+ descKey: string,
+ zeroAction: 'unlimited' | 'inherit'
+ ) => (
<FormField
control={form.control}
name={name}
- render={({ field }) => {
- const unlimited = (field.value as number) <= 0
- return (
- <FormItem className="flex items-start justify-between gap-4">
- <div className="min-w-0 space-y-1">
- <FormLabel>{t(labelKey)}</FormLabel>
- <FormDescription className="text-xs">
- {t(descKey)}
- </FormDescription>
- </div>
- <div className="flex shrink-0 items-center gap-1.5">
- <div className="relative">
- <FormControl>
- <Input
- type="number"
- min={0}
- className="h-8 w-32 pr-12"
- value={Math.round((field.value as number) / KB)}
- onChange={(event) => {
- const value = Number.parseInt(event.target.value, 10)
- field.onChange(Number.isFinite(value) ? value * KB : 0)
- }}
- />
- </FormControl>
- <span
- className="pointer-events-none absolute inset-y-0 right-2.5 flex items-center text-[11px] text-muted-foreground"
- aria-hidden
- >
- KB/s
- </span>
- </div>
- <Button
- type="button"
- variant="ghost"
- size="xs"
- disabled={unlimited}
- onClick={() => field.onChange(0)}
- >
- {t(
- unlimited
- ? 'settings.downloads.speedLimit.unlimited'
- : 'settings.downloads.speedLimit.setUnlimited'
- )}
- </Button>
- </div>
- </FormItem>
- )
- }}
+ render={({ field }) => (
+ <FormItem className="flex items-start justify-between gap-4">
+ <div className="min-w-0 space-y-1">
+ <FormLabel>{t(labelKey)}</FormLabel>
+ <FormDescription className="text-xs">{t(descKey)}</FormDescription>
+ </div>
+ <FormControl>
+ <CompactLimitInput
+ value={Math.round((field.value as number) / KB)}
+ onValueChange={(value) => field.onChange(value * KB)}
+ unit="KB/s"
+ zeroAction={zeroAction}
+ zeroLabel={t(
+ zeroAction === 'inherit'
+ ? 'settings.downloads.speedLimit.standardLimit'
+ : 'settings.downloads.speedLimit.unlimited'
+ )}
+ resetLabel={t(
+ zeroAction === 'inherit'
+ ? 'settings.downloads.speedLimit.useStandardLimit'
+ : 'settings.downloads.speedLimit.setUnlimited'
+ )}
+ />
+ </FormControl>
+ </FormItem>
+ )}
/>
)
@@ -454,12 +438,14 @@ export function SpeedLimitSection({
{kbLimitRow(
'speedLimit.base.download',
'settings.downloads.speedLimit.baseDownload',
- 'settings.downloads.speedLimit.baseDownloadDesc'
+ 'settings.downloads.speedLimit.baseDownloadDesc',
+ 'unlimited'
)}
{kbLimitRow(
'speedLimit.base.upload',
'settings.downloads.speedLimit.baseUpload',
- 'settings.downloads.speedLimit.baseUploadDesc'
+ 'settings.downloads.speedLimit.baseUploadDesc',
+ 'unlimited'
)}
<Separator className="my-2" />
@@ -471,12 +457,14 @@ export function SpeedLimitSection({
{kbLimitRow(
'speedLimit.alt.download',
'settings.downloads.speedLimit.altDownload',
- 'settings.downloads.speedLimit.altDownloadDesc'
+ 'settings.downloads.speedLimit.altDownloadDesc',
+ 'inherit'
)}
{kbLimitRow(
'speedLimit.alt.upload',
'settings.downloads.speedLimit.altUpload',
- 'settings.downloads.speedLimit.altUploadDesc'
+ 'settings.downloads.speedLimit.altUploadDesc',
+ 'inherit'
)}
{turtle === 'auto' && (
diff --git a/src/shared/locales/en-US.json b/src/shared/locales/en-US.json
index 36eefbd4..07a4b364 100644
--- a/src/shared/locales/en-US.json
+++ b/src/shared/locales/en-US.json
@@ -956,10 +956,14 @@
"traySpeedometerDesc": "macOS only — display the current speed next to the tray icon.",
"liquidGlassEffect": "Enable Liquid Glass effect",
"liquidGlassEffectDesc": "macOS 26 App only — recreates the main window when changed.",
- "runMode": "Run as",
- "runModeStandard": "Standard application",
- "runModeTray": "Tray application",
- "runModeHideTray": "Hide tray application",
+ "runMode": "Show app in",
+ "runModeStandard": "Dock & Menu Bar",
+ "runModeTray": "Menu Bar Only",
+ "runModeHideTray": "Dock Only",
+ "runModeLaunch": "When opening Motrix",
+ "runModeStandardDesktop": "Open Main Window",
+ "runModeTrayDesktop": "Start in System Tray",
+ "runModeLinuxDesc": "System tray availability and activation behavior depend on your desktop environment.",
"lightweightMode": "Lightweight mode",
"lightweightModeDesc": "Release interface memory after the main window closes. Background downloads continue; Windows and Linux keep a tray entry for reopening. Reopening takes a little longer and unsaved interface state is discarded."
},
@@ -1185,6 +1189,10 @@
"fileAllocationPrealloc": "Prealloc",
"fileAllocationTrunc": "Trunc",
"fileAllocationFalloc": "Falloc",
+ "modifiedTime": "File modification time",
+ "modifiedTimeDesc": "Choose which modification time completed HTTP and FTP downloads use.",
+ "modifiedTimeLocal": "Local",
+ "modifiedTimeServer": "Server",
"diskCache": "Disk cache (MB)",
"diskCacheDesc": "In-memory write cache.",
"sessionSaveInterval": "Session save interval (s)",
@@ -1215,6 +1223,8 @@
"baseUploadDesc": "The maximum everyday upload speed.",
"unlimited": "Unlimited",
"setUnlimited": "Set unlimited",
+ "standardLimit": "Standard limit",
+ "useStandardLimit": "Use standard limit",
"altSection": "Low-speed limits",
"altSectionDesc": "Used in Low speed mode or by scheduled rules. These limits can only reduce the standard limits.",
"altDownload": "Low-speed download limit",
diff --git a/src/shared/locales/zh-CN.json b/src/shared/locales/zh-CN.json
index 85cf4d4f..34f15d3f 100644
--- a/src/shared/locales/zh-CN.json
+++ b/src/shared/locales/zh-CN.json
@@ -943,10 +943,14 @@
"traySpeedometerDesc": "仅 macOS — 在托盘图标旁显示当前速度。",
"liquidGlassEffect": "启用液态玻璃效果",
"liquidGlassEffectDesc": "仅 macOS 26 App — 更改后会重建主窗口。",
- "runMode": "运行方式",
- "runModeStandard": "标准应用",
- "runModeTray": "托盘应用",
- "runModeHideTray": "隐藏托盘",
+ "runMode": "显示位置",
+ "runModeStandard": "程序坞与菜单栏",
+ "runModeTray": "仅菜单栏",
+ "runModeHideTray": "仅程序坞",
+ "runModeLaunch": "打开 Motrix 时",
+ "runModeStandardDesktop": "打开主窗口",
+ "runModeTrayDesktop": "在系统托盘中启动",
+ "runModeLinuxDesc": "系统托盘的可用性和激活方式取决于桌面环境。",
"lightweightMode": "轻量模式",
"lightweightModeDesc": "关闭主窗口后释放界面内存,后台下载继续运行。Windows 和 Linux 会保留托盘入口;重新打开会稍慢,未保存的界面状态将被丢弃。"
},
@@ -1172,6 +1176,10 @@
"fileAllocationPrealloc": "预分配",
"fileAllocationTrunc": "截断",
"fileAllocationFalloc": "Falloc",
+ "modifiedTime": "文件修改时间",
+ "modifiedTimeDesc": "选择 HTTP 和 FTP 下载完成后使用的文件修改时间。",
+ "modifiedTimeLocal": "本地修改时间",
+ "modifiedTimeServer": "服务器修改时间",
"diskCache": "磁盘缓存 (MB)",
"diskCacheDesc": "写入磁盘前的内存缓存上限。",
"sessionSaveInterval": "会话保存间隔 (秒)",
@@ -1202,6 +1210,8 @@
"baseUploadDesc": "日常上传时允许的最高速度。",
"unlimited": "不限速",
"setUnlimited": "设为不限速",
+ "standardLimit": "沿用常规上限",
+ "useStandardLimit": "沿用常规上限",
"altSection": "低速模式上限",
"altSectionDesc": "低速模式和定时规则使用;只会在常规上限基础上进一步降速。",
"altDownload": "低速下载上限",
diff --git a/src/shared/locales/zh-TW.json b/src/shared/locales/zh-TW.json
index 9b9d0c18..a7093ecb 100644
--- a/src/shared/locales/zh-TW.json
+++ b/src/shared/locales/zh-TW.json
@@ -943,10 +943,14 @@
"traySpeedometerDesc": "僅限 macOS,在系統匣圖示旁顯示目前速度。",
"liquidGlassEffect": "啟用液態玻璃效果",
"liquidGlassEffectDesc": "僅限 macOS 26 App,變更後會重新建立主視窗。",
- "runMode": "執行方式",
- "runModeStandard": "標準應用程式",
- "runModeTray": "系統匣應用程式",
- "runModeHideTray": "隱藏系統匣應用程式",
+ "runMode": "顯示位置",
+ "runModeStandard": "Dock 與選單列",
+ "runModeTray": "僅選單列",
+ "runModeHideTray": "僅 Dock",
+ "runModeLaunch": "開啟 Motrix 時",
+ "runModeStandardDesktop": "開啟主視窗",
+ "runModeTrayDesktop": "在系統匣中啟動",
+ "runModeLinuxDesc": "系統匣的可用性和啟用方式取決於桌面環境。",
"lightweightMode": "輕量模式",
"lightweightModeDesc": "關閉主視窗後釋放介面記憶體,背景下載會繼續運作。Windows 和 Linux 會保留系統匣入口;重新開啟會稍慢,未儲存的介面狀態將被捨棄。"
},
@@ -1172,6 +1176,10 @@
"fileAllocationPrealloc": "預先配置",
"fileAllocationTrunc": "截斷",
"fileAllocationFalloc": "配置",
+ "modifiedTime": "檔案修改時間",
+ "modifiedTimeDesc": "選擇 HTTP 與 FTP 下載完成後使用的檔案修改時間。",
+ "modifiedTimeLocal": "本機修改時間",
+ "modifiedTimeServer": "伺服器修改時間",
"diskCache": "磁碟快取 (MB)",
"diskCacheDesc": "記憶體內的寫入快取。",
"sessionSaveInterval": "工作階段儲存間隔 (秒)",
@@ -1202,6 +1210,8 @@
"baseUploadDesc": "日常上傳的最高速度。",
"unlimited": "不限速",
"setUnlimited": "設為不限速",
+ "standardLimit": "沿用標準限制",
+ "useStandardLimit": "沿用標準限制",
"altSection": "低速限制",
"altSectionDesc": "用於低速模式或排程規則。這些限制只能低於標準限制。",
"altDownload": "低速下載限制",
diff --git a/src/shared/schemas/engine-settings.test.ts b/src/shared/schemas/engine-settings.test.ts
index 7ce3ee3b..d98fe279 100644
--- a/src/shared/schemas/engine-settings.test.ts
+++ b/src/shared/schemas/engine-settings.test.ts
@@ -83,3 +83,24 @@ describe('engineSettingsSchema dnsMode', () => {
}
)
})
+
+describe('engineSettingsSchema remoteTime', () => {
+ it('uses the local modification time by default', () => {
+ expect(DEFAULT_ENGINE_SETTINGS.remoteTime).toBe(false)
+ })
+
+ it.each([true, false])('accepts %s', (remoteTime) => {
+ expect(engineSettingsSchema.parse({ remoteTime }).remoteTime).toBe(
+ remoteTime
+ )
+ })
+
+ it.each(['server', 1, null])(
+ 'recovers invalid persisted value %s to false',
+ (bad) => {
+ expect(engineSettingsSchema.parse({ remoteTime: bad }).remoteTime).toBe(
+ false
+ )
+ }
+ )
+})
diff --git a/src/shared/schemas/engine-settings.ts b/src/shared/schemas/engine-settings.ts
index e7c55794..681b8122 100644
--- a/src/shared/schemas/engine-settings.ts
+++ b/src/shared/schemas/engine-settings.ts
@@ -51,6 +51,7 @@ export const engineSettingsSchema = z
fileAllocation: z
.enum(['none', 'prealloc', 'trunc', 'falloc'])
.catch('none'),
+ remoteTime: z.boolean().catch(false),
diskCache: z
.number()
.int()
diff --git a/src/shared/types/settings.ts b/src/shared/types/settings.ts
index fb4e1380..6fb1bddb 100644
--- a/src/shared/types/settings.ts
+++ b/src/shared/types/settings.ts
@@ -193,6 +193,7 @@ export interface EngineSettings {
// Disk & session
fileAllocation: FileAllocation
+ remoteTime: boolean
diskCache: number
sessionSaveInterval: number