Merge feat/documents-folders-and-ui: Documents folders, collapsible sidebar, theme switch

# Conflicts:
#	src/main/download.ts
#	src/renderer/src/components/DownloadBar.tsx
This commit is contained in:
2026-06-24 11:26:52 -04:00
15 changed files with 363 additions and 409 deletions
+13 -11
View File
@@ -1,7 +1,7 @@
import { spawn, execFile, type ChildProcess } from 'child_process'
import { existsSync } from 'fs'
import { join } from 'path'
import { app, BrowserWindow, Notification, type WebContents } from 'electron'
import { BrowserWindow, Notification, type WebContents } from 'electron'
import {
getYtdlpPath,
getBinDir,
@@ -10,7 +10,7 @@ import {
getFfprobePath,
getSystem32Path
} from './binaries'
import { getSettings, getDownloadArchivePath } from './settings'
import { getSettings, getDownloadArchivePath, getDefaultMediaDir } from './settings'
import { getCookiesFilePath } from './cookies'
import { listTemplates } from './templates'
import { assertHttpUrl } from './url'
@@ -175,16 +175,18 @@ function resolveExtraArgs(opts: StartDownloadOptions, settings: Settings): strin
/** Resolve settings + per-download overrides into the full yt-dlp argv. */
export function buildCommand(opts: StartDownloadOptions): string[] {
const settings = getSettings()
// A per-download outputDir override must clear the same safety check the
// persisted setting does (absolute path only); a renderer-supplied override is
// otherwise untrusted — it dictates where downloaded files get written. An
// unsafe override is ignored in favour of the validated setting, then the OS
// Downloads folder. (audit F4)
// Output dir resolution: a per-download override wins, then the user's explicit
// per-kind folder (Settings → Video/Audio folder), and finally — when that's
// blank — the per-kind default (Documents\Video for video, Documents\Audio for audio).
//
// A per-download outputDir override must clear the same safety check the persisted
// setting does (absolute path only); a renderer-supplied override is otherwise
// untrusted — it dictates where downloaded files get written. An unsafe override is
// ignored in favour of the per-kind folder, then the per-kind default. (audit F4)
const override = opts.outputDir?.trim()
const outDir =
(override && isSafeOutputDir(override) ? override : '') ||
settings.outputDir ||
app.getPath('downloads')
const safeOverride = override && isSafeOutputDir(override) ? override : ''
const perKindDir = (opts.kind === 'audio' ? settings.audioDir : settings.videoDir)?.trim()
const outDir = safeOverride || perKindDir || getDefaultMediaDir(opts.kind)
// A collection (media-manager) download is filed into <channel>/<playlist>/
// <NNN> - <title> folders; an ordinary download uses the flat filenameTemplate.
const filenameTemplate = settings.filenameTemplate?.trim() || '%(title)s.%(ext)s'