Skip to content

misterdownloadmanager: The ultimate open-source, clean-room download manager written from scratch in pure Rust for Windows, Mac, and Linux

Helpers run in a folder they can write, never MDM's install folder (fixes #834) (#845)

Ahmed Nefzaoui5de22bf83674
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5674862e..94eb2d31 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -31,6 +31,7 @@ Each release's notes on GitHub come from its section here (`## [X.Y.Z]`, see
### Fixed
+- Looking up a video put online in the last two days no longer fails with "[Errno 13] Permission denied: 'C:\Program Files\Mister Download Manager\tmp…'" when MDM was opened from the Start menu. yt-dlp checks such a video's formats with a small file in the folder it was started in, and MDM started its helpers in its own, which is the install folder Windows doesn't let you write. yt-dlp, gallery-dl, ffmpeg and 7-Zip now run in your temporary folder; if that one can't be written, in a `work` folder of MDM's data folder, which the log names ([#834](https://github.com/anefzaoui/misterdownloadmanager/issues/834)).
- A video a site sends through a program's address (`stream.php?file=lecture.mp4`, `remote_control.php`, many lecture and video sites do) is named by what it is, not by the program: MDM took the name and the type from the address's last part, so the file was saved as `stream.php`, the browser's media list showed **remote_control.php · PHP**, and the Download video window offered **PHP** and then failed ("The extracted extension (php) is unusual and will be skipped for safety reasons"). Now a name whose ending is a program's (`.php`, `.asp`, `.aspx`, `.jsp`, `.cgi` and the like), a page's or none at all takes its type from the address's `file=` name, else from what the server says it sends (video/mp4 is `.mp4`), else from the file's first bytes; a video from the browser whose address names nothing (a program, a bare number, `videoplayback`) is named by its page's title, with the **Prefix media file names with the page title** switch on or off; and a name the server gives (Content-Disposition) still wins. The media list shows that name and type (**Lecture 1.mp4 · MP4**), the button over a video says MP4 instead of PHP, and the Download video window saves such a video as an MP4. Only media, picture, document and archive types are taken this way, never a program's ([#695](https://github.com/anefzaoui/misterdownloadmanager/issues/695), [#800](https://github.com/anefzaoui/misterdownloadmanager/issues/800)).
- Copying several links at once no longer opens **Download File Info** with all of them run together as one address (with **Offer to download links copied to the clipboard** on): a copied text with spaces or line breaks in it is not one link, and is left for **Add batch download from clipboard** ([#709](https://github.com/anefzaoui/misterdownloadmanager/issues/709)).
- Windows: MDM follows the Group Policy **Do not preserve zone information in file attachments**, as browsers do: with it on, for the computer or for you, downloads no longer get the mark that says they came from the internet (the Mark of the Web). MDM added it to every download whatever the policy said. A new option, **Options → Save to → Mark downloaded files as coming from the internet** (on by default), turns the mark off for MDM alone, on every system: Windows' Mark of the Web, macOS' quarantine and Linux's origin attributes ([#813](https://github.com/anefzaoui/misterdownloadmanager/issues/813)).
diff --git a/Cargo.lock b/Cargo.lock
index 9c34294c..d9987ff0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4882,6 +4882,7 @@ dependencies = [
"thiserror 2.0.21",
"tokio",
"tokio-util",
+ "tracing",
"url",
"win32job",
"zip",
diff --git a/ROADMAP.md b/ROADMAP.md
index c611b839..3a22cda0 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -556,6 +556,9 @@ Bug fixes from the first days of 0.5.0, a Safari extension, and more file types.
These ship in the next version.
+- ✅ Looking up a new video (put online in the last two days) no longer fails with "Permission
+ denied" in MDM's install folder: the helpers run in your temporary folder, or MDM's own if
+ that one can't be written ([#834](https://github.com/anefzaoui/misterdownloadmanager/issues/834))
- ✅ A video a site sends through a program's address (`stream.php?file=…`,
`remote_control.php`) is named by what it is: the page's title (or the address's `file=` name)
and its real type, `Lecture.mp4`, not `stream.php`; the browser's media list shows that name
diff --git a/crates/extract/src/external.rs b/crates/extract/src/external.rs
index 77b52451..01fb84ae 100644
--- a/crates/extract/src/external.rs
+++ b/crates/extract/src/external.rs
@@ -42,6 +42,10 @@ pub fn extract(
w: &mut Writer,
password: Option<&str>,
) -> Result<(), Error> {
+ // Full paths: 7-Zip runs in the staging folder, MDM's own and writable, never in the folder
+ // MDM was started in (its install folder from the Start menu, #834).
+ let full = |p: &Path| std::path::absolute(p).unwrap_or_else(|_| p.to_owned());
+ let (root, archive) = (full(w.root()), full(archive));
let mut cmd = Command::new(tool);
cmd.arg("x")
.arg("-y")
@@ -50,9 +54,10 @@ pub fn extract(
// An empty password when none is given: 7-Zip then fails at once on an encrypted
// archive instead of asking on a console nobody sees.
.arg(format!("-p{}", password.unwrap_or("")))
- .arg(format!("-o{}", w.root().display()))
+ .arg(format!("-o{}", root.display()))
.arg("--")
- .arg(archive)
+ .arg(&archive)
+ .current_dir(&root)
.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(Stdio::piped());
diff --git a/crates/ipc/src/lib.rs b/crates/ipc/src/lib.rs
index 0b845af4..5acd1d70 100644
--- a/crates/ipc/src/lib.rs
+++ b/crates/ipc/src/lib.rs
@@ -266,7 +266,13 @@ static DATA_DIR: std::sync::OnceLock<PathBuf> = std::sync::OnceLock::new();
/// Use `dir` as the data folder from now on (over `MDM_DATA_DIR`): `--headless --data <dir>`.
pub fn set_data_dir(dir: PathBuf) {
- let _ = DATA_DIR.set(dir);
+ let _ = DATA_DIR.set(full(dir));
+}
+
+/// `dir` as a full path (#834): the helpers run in a folder of their own, and are given paths in
+/// the data folder (their programs, ffmpeg's place, the files MDM writes for them).
+fn full(dir: PathBuf) -> PathBuf {
+ std::path::absolute(&dir).unwrap_or(dir)
}
/// The app's data folder, `%APPDATA%\misterdownloadmanager` (list, settings, channel, crash
@@ -285,7 +291,7 @@ pub fn data_dir() -> Option<PathBuf> {
static RESOLVED: std::sync::OnceLock<Option<PathBuf>> = std::sync::OnceLock::new();
once(&RESOLVED, || {
if let Some(dir) = std::env::var_os("MDM_DATA_DIR") {
- return Some(PathBuf::from(dir));
+ return Some(full(PathBuf::from(dir)));
}
if let Some(dir) = portable_dir() {
return Some(dir);
diff --git a/crates/tools/Cargo.toml b/crates/tools/Cargo.toml
index 311f0521..af669b0a 100644
--- a/crates/tools/Cargo.toml
+++ b/crates/tools/Cargo.toml
@@ -23,6 +23,7 @@ sha2.workspace = true
thiserror.workspace = true
tokio.workspace = true
tokio-util.workspace = true
+tracing.workspace = true
url.workspace = true
percent-encoding.workspace = true
zip = { version = "9.1.3", default-features = false, features = ["deflate"] }
diff --git a/crates/tools/src/gallery.rs b/crates/tools/src/gallery.rs
index f13562f3..650fb898 100644
--- a/crates/tools/src/gallery.rs
+++ b/crates/tools/src/gallery.rs
@@ -498,7 +498,10 @@ impl GalleryJob {
let mut ours: Vec<String> = vec![
// The files right in `folder` (the gallery's own), not in subfolders of the site's.
"--directory".into(),
- folder.to_string_lossy().into_owned(),
+ // A full path: gallery-dl runs in a folder of its own (#834).
+ crate::workdir::absolute(folder)
+ .to_string_lossy()
+ .into_owned(),
// One file a second at most: gentle with the sites (Wikimedia answers 429 to
// faster tools) and with the person's line.
"--sleep".into(),
diff --git a/crates/tools/src/lib.rs b/crates/tools/src/lib.rs
index 93c0b55f..5e64ce2e 100644
--- a/crates/tools/src/lib.rs
+++ b/crates/tools/src/lib.rs
@@ -23,6 +23,7 @@ pub mod streams;
mod system;
pub mod update;
pub mod video;
+pub mod workdir;
use std::path::{Path, PathBuf};
diff --git a/crates/tools/src/proc.rs b/crates/tools/src/proc.rs
index 05e4c5ed..652c8a5a 100644
--- a/crates/tools/src/proc.rs
+++ b/crates/tools/src/proc.rs
@@ -608,12 +608,12 @@ fn header_domain(host: &str) -> &str {
}
/// A cookie file's `text` ([`jar_cookies`], [`header_cookies`]) in a file only this user can
-/// read.
+/// read, in the helpers' temporary folder ([`crate::workdir::temp_dir`]).
fn cookie_file(text: &str) -> std::io::Result<CookieFile> {
use std::io::Write;
use std::sync::atomic::{AtomicU64, Ordering};
static N: AtomicU64 = AtomicU64::new(0);
- let path = std::env::temp_dir().join(format!(
+ let path = crate::workdir::temp_dir().join(format!(
"mdm-cookies-{}-{}.txt",
std::process::id(),
N.fetch_add(1, Ordering::Relaxed)
@@ -951,9 +951,11 @@ fn with_cookie_trouble(message: String, warnings: &[String], tail: &VecDeque<Str
}
/// Start `cmd` supervised: no window, in the job, stdout piped for the caller, stderr kept as a
-/// tail, with a PATH it can walk ([`with_usable_path`], #508).
+/// tail, with a PATH it can walk ([`with_usable_path`], #508), in a folder it can write that is
+/// also its TEMP ([`crate::workdir`], #834: never MDM's install folder).
pub fn spawn(mut cmd: Command, name: &str) -> Result<Spawned, ProcError> {
with_usable_path(&mut cmd);
+ crate::workdir::apply(&mut cmd, crate::workdir::folders());
cmd.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::piped());
@@ -1675,6 +1677,42 @@ foreach ($d in $env:PATH.Split(';')) {
assert!(matches!(err, ProcError::Timeout(_)), "{err}");
}
+ /// #834: a helper (here a stand-in that prints where it runs and its temporary folders)
+ /// starts in the helpers' folder, not in MDM's own working folder, and has it as TEMP, TMP
+ /// and TMPDIR.
+ #[test]
+ fn a_helper_runs_in_the_helpers_folder() {
+ let dir = crate::workdir::folders()
+ .dir
+ .clone()
+ .expect("a temporary folder that can be written");
+ #[cfg(windows)]
+ let cmd = {
+ let mut c = Command::new("cmd");
+ c.args(["/C", "cd& echo %TEMP%& echo %TMP%& echo %TMPDIR%"]);
+ c
+ };
+ #[cfg(unix)]
+ let cmd = {
+ let mut c = Command::new("/bin/sh");
+ c.args(["-c", r#"pwd -P; echo "$TEMP"; echo "$TMP"; echo "$TMPDIR""#]);
+ c
+ };
+ let out = output(cmd, "stand-in", Duration::from_secs(10)).unwrap();
+ let out = String::from_utf8_lossy(&out);
+ let lines: Vec<&str> = out.lines().map(str::trim).collect();
+ assert_eq!(lines.len(), 4, "{out}");
+ let real = |p: &Path| std::fs::canonicalize(p).unwrap();
+ assert_eq!(real(Path::new(lines[0])), real(&dir), "{out}");
+ assert_ne!(
+ real(Path::new(lines[0])),
+ real(&std::env::current_dir().unwrap())
+ );
+ for temp in &lines[1..] {
+ assert_eq!(Path::new(temp), dir, "{out}");
+ }
+ }
+
/// #61: killing a helper ends what it started too (yt-dlp.exe is a launcher whose child
/// downloads). Here a script starts a child that writes a line every second: once killed,
/// the file stops growing.
diff --git a/crates/tools/src/video.rs b/crates/tools/src/video.rs
index 1a862db4..bbd4b9a3 100644
--- a/crates/tools/src/video.rs
+++ b/crates/tools/src/video.rs
@@ -540,11 +540,12 @@ pub struct VideoJob {
current: Arc<crate::streams::Current>,
}
-/// A private file for the looked-up page (its links are signed; removed when the run ends).
+/// A private file for the looked-up page (its links are signed; removed when the run ends), in
+/// the helpers' temporary folder ([`crate::workdir::temp_dir`]).
fn info_file() -> PathBuf {
use std::sync::atomic::{AtomicU64, Ordering};
static N: AtomicU64 = AtomicU64::new(0);
- std::env::temp_dir().join(format!(
+ crate::workdir::temp_dir().join(format!(
"mdm-video-{}-{}.json",
std::process::id(),
N.fetch_add(1, Ordering::Relaxed)
@@ -1587,7 +1588,8 @@ impl VideoJob {
) -> Result<VideoJob, ProcError> {
proc::safe(url)?;
let preloaded = preloaded.filter(|p| p.selector == selector);
- let output = dir.join(format!("{}.%(ext)s", template_text(stem)));
+ // A full path: yt-dlp runs in a folder of its own (#834).
+ let output = crate::workdir::absolute(dir).join(format!("{}.%(ext)s", template_text(stem)));
// An MP3, Opus or FLAC choice (#32, #70): the best sound, converted by ffmpeg.
let convert = crate::resolve::audio_conversion(selector);
let format = if convert.is_some() {
diff --git a/crates/tools/src/workdir.rs b/crates/tools/src/workdir.rs
new file mode 100644
index 00000000..0b84128b
--- /dev/null
+++ b/crates/tools/src/workdir.rs
@@ -0,0 +1,286 @@
+//! Where the helpers run (#834): every one starts in a folder it can write, with TEMP, TMP and
+//! TMPDIR naming that folder.
+//!
+//! A helper used to inherit MDM's own working folder, which is the install folder when MDM is
+//! opened from the Start menu (`C:\Program Files\Mister Download Manager`). yt-dlp writes there:
+//! before it chooses a format a site marks as needing a check (YouTube's streams in pieces of a
+//! video put online in the last two days), it tries the format with a small file of its own in
+//! its working folder (its `temp` path, which MDM doesn't set), and Windows refused it: "[Errno
+//! 13] Permission denied: 'C:\\Program Files\\Mister Download Manager\\tmp….tmp'".
+//!
+//! The folder is the person's temporary folder when a file can be made in it, else a `work`
+//! folder in MDM's data folder (said once in the log): Python, yt-dlp's and gallery-dl's
+//! language, falls back to the working folder when TEMP can't be written, and so would have
+//! landed in the install folder again. MDM's own files for the helpers (a page's cookies, a
+//! looked-up page) go in the same folder ([`temp_dir`]).
+
+use std::path::{Path, PathBuf};
+use std::process::Command;
+
+/// The folder the helpers run in and are given as their temporary folder.
+#[derive(Clone, Debug, PartialEq, Eq)]
+pub struct Folders {
+ /// Their working folder and TEMP, TMP and TMPDIR; `None` when no folder could be written at
+ /// all (they then get what MDM has, as before).
+ pub dir: Option<PathBuf>,
+ /// The person's temporary folder, when it couldn't be written and `dir` replaced it.
+ pub replaced: Option<PathBuf>,
+}
+
+/// The variables a temporary folder is read from: Python reads all three, in this order, on
+/// every system; Windows' programs read TMP and TEMP, Linux's and macOS's TMPDIR.
+pub const TEMP_VARS: [&str; 3] = ["TMPDIR", "TEMP", "TMP"];
+
+/// `p` as a full path (against MDM's working folder; unchanged if that can't be read): a helper
+/// runs elsewhere, so a relative path MDM gives it would name another file.
+pub fn absolute(p: &Path) -> PathBuf {
+ std::path::absolute(p).unwrap_or_else(|_| p.to_owned())
+}
+
+/// Can a file be made in `dir`? A file is made there and removed: a folder's permissions say
+/// little on Windows (a deny rule, a controlled folder, a full or read-only drive).
+pub fn writable(dir: &Path) -> bool {
+ use std::sync::atomic::{AtomicU64, Ordering};
+ static N: AtomicU64 = AtomicU64::new(0);
+ if !dir.is_dir() {
+ return false;
+ }
+ let probe = dir.join(format!(
+ ".mdm-probe-{}-{}",
+ std::process::id(),
+ N.fetch_add(1, Ordering::Relaxed)
+ ));
+ let made = std::fs::OpenOptions::new()
+ .write(true)
+ .create_new(true)
+ .open(&probe);
+ match made {
+ Ok(file) => {
+ drop(file);
+ let _ = std::fs::remove_file(&probe);
+ true
+ }
+ Err(_) => false,
+ }
+}
+
+/// The folder for the helpers: the person's temporary folder `user` when a file can be made in
+/// it, else `<data>/work` (made, private to the user on Linux and macOS).
+pub fn choose(user: &Path, data: Option<&Path>) -> Folders {
+ let user = absolute(user);
+ if writable(&user) {
+ return Folders {
+ dir: Some(user),
+ replaced: None,
+ };
+ }
+ let own = data
+ .map(|d| absolute(&d.join("work")))
+ .filter(|w| mdm_ipc::private_dir(w).is_ok() && writable(w));
+ Folders {
+ replaced: own.as_ref().map(|_| user),
+ dir: own,
+ }
+}
+
+/// The helpers' folder, chosen once per run (the system's temporary folder, MDM's data folder).
+/// A replaced temporary folder is said in the log the first time.
+pub fn folders() -> &'static Folders {
+ static FOLDERS: std::sync::OnceLock<Folders> = std::sync::OnceLock::new();
+ FOLDERS.get_or_init(|| {
+ let chosen = choose(&std::env::temp_dir(), mdm_ipc::data_dir().as_deref());
+ match (&chosen.dir, &chosen.replaced) {
+ (Some(dir), Some(user)) => tracing::warn!(
+ "helpers: the temporary folder {} can't be written; yt-dlp, gallery-dl and \
+ ffmpeg use {} instead",
+ user.display(),
+ dir.display()
+ ),
+ (None, _) => tracing::warn!(
+ "helpers: neither the temporary folder {} nor MDM's data folder can be \
+ written; the helpers run where MDM does",
+ std::env::temp_dir().display()
+ ),
+ _ => {}
+ }
+ chosen
+ })
+}
+
+/// Where MDM puts its own files for a helper (a page's cookies, a looked-up page): the helpers'
+/// folder, else the system's temporary folder.
+pub fn temp_dir() -> PathBuf {
+ folders().dir.clone().unwrap_or_else(std::env::temp_dir)
+}
+
+/// Start `cmd` in `folders`' folder with it as TEMP, TMP and TMPDIR. A working folder or a
+/// variable `cmd` was already given stays.
+pub fn apply(cmd: &mut Command, folders: &Folders) {
+ let Some(dir) = &folders.dir else { return };
+ if cmd.get_current_dir().is_none() {
+ cmd.current_dir(dir);
+ }
+ for var in TEMP_VARS {
+ let given = cmd.get_envs().any(|(k, _)| {
+ if cfg!(windows) {
+ k.eq_ignore_ascii_case(var)
+ } else {
+ k == var
+ }
+ });
+ if !given {
+ cmd.env(var, dir);
+ }
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn the_persons_temporary_folder_when_it_can_be_written() {
+ let user = tempfile::tempdir().unwrap();
+ let data = tempfile::tempdir().unwrap();
+ let f = choose(user.path(), Some(data.path()));
+ assert_eq!(f.dir.as_deref(), Some(user.path()));
+ assert_eq!(f.replaced, None);
+ // Nothing made in the data folder, and no probe left behind.
+ assert!(!data.path().join("work").exists());
+ assert_eq!(std::fs::read_dir(user.path()).unwrap().count(), 0);
+ }
+
+ #[test]
+ fn mdms_own_folder_when_the_temporary_folder_is_missing() {
+ let data = tempfile::tempdir().unwrap();
+ let missing = data.path().join("no-such-temp");
+ let f = choose(&missing, Some(data.path()));
+ let work = data.path().join("work");
+ assert_eq!(f.dir.as_deref(), Some(work.as_path()));
+ assert_eq!(f.replaced.as_deref(), Some(missing.as_path()));
+ assert!(work.is_dir());
+ }
+
+ #[test]
+ fn mdms_own_folder_when_the_temporary_folder_is_a_file() {
+ let data = tempfile::tempdir().unwrap();
+ let file = data.path().join("temp.txt");
+ std::fs::write(&file, b"x").unwrap();
+ let f = choose(&file, Some(data.path()));
+ assert_eq!(f.dir, Some(data.path().join("work")));
+ assert_eq!(f.replaced, Some(file));
+ }
+
+ /// A folder this user may read but not write (Windows: a deny rule, as `C:\Program Files`
+ /// refuses a user; elsewhere: mode 0555).
+ fn read_only(dir: &Path) {
+ #[cfg(windows)]
+ {
+ let user = std::env::var("USERNAME").unwrap();
+ let ok = Command::new("icacls")
+ .arg(dir)
+ .args(["/deny", &format!("{user}:(OI)(CI)(WD,AD,WEA,WA)")])
+ .stdout(std::process::Stdio::null())
+ .status()
+ .unwrap()
+ .success();
+ assert!(ok);
+ }
+ #[cfg(unix)]
+ {
+ use std::os::unix::fs::PermissionsExt;
+ std::fs::set_permissions(dir, std::fs::Permissions::from_mode(0o555)).unwrap();
+ }
+ }
+
+ fn writable_again(dir: &Path) {
+ #[cfg(windows)]
+ {
+ let _ = Command::new("icacls")
+ .arg(dir)
+ .arg("/reset")
+ .stdout(std::process::Stdio::null())
+ .status();
+ }
+ #[cfg(unix)]
+ {
+ use std::os::unix::fs::PermissionsExt;
+ let _ = std::fs::set_permissions(dir, std::fs::Permissions::from_mode(0o755));
+ }
+ }
+
+ #[test]
+ fn mdms_own_folder_when_the_temporary_folder_cant_be_written() {
+ let data = tempfile::tempdir().unwrap();
+ let locked = data.path().join("locked");
+ std::fs::create_dir(&locked).unwrap();
+ read_only(&locked);
+ // root writes anywhere (a container's test run): nothing to check then.
+ if writable(&locked) {
+ writable_again(&locked);
+ return;
+ }
+ let f = choose(&locked, Some(data.path()));
+ writable_again(&locked);
+ assert_eq!(f.dir, Some(data.path().join("work")));
+ assert_eq!(f.replaced, Some(locked));
+ }
+
+ #[test]
+ fn nothing_when_no_folder_can_be_written() {
+ let data = tempfile::tempdir().unwrap();
+ let missing = data.path().join("no-such-temp");
+ // A data folder under a file can't be made.
+ let file = data.path().join("f");
+ std::fs::write(&file, b"x").unwrap();
+ let f = choose(&missing, Some(&file.join("data")));
+ assert_eq!(
+ f,
+ Folders {
+ dir: None,
+ replaced: None
+ }
+ );
+ let f = choose(&missing, None);
+ assert_eq!(f.dir, None);
+ // The helper is then left as it was.
+ let mut cmd = Command::new("x");
+ apply(&mut cmd, &f);
+ assert!(cmd.get_current_dir().is_none());
+ assert_eq!(cmd.get_envs().count(), 0);
+ }
+
+ #[test]
+ fn a_relative_temporary_folder_is_made_full() {
+ let f = choose(Path::new("."), None);
+ let dir = f.dir.unwrap();
+ assert!(dir.is_absolute(), "{}", dir.display());
+ }
+
+ #[test]
+ fn the_folder_and_variables_a_helper_gets() {
+ let f = Folders {
+ dir: Some(PathBuf::from("/mdm/work")),
+ replaced: None,
+ };
+ let mut cmd = Command::new("x");
+ apply(&mut cmd, &f);
+ assert_eq!(cmd.get_current_dir(), Some(Path::new("/mdm/work")));
+ let mut envs: Vec<_> = cmd
+ .get_envs()
+ .map(|(k, v)| (k.to_owned(), v.map(ToOwned::to_owned)))
+ .collect();
+ envs.sort();
+ assert_eq!(
+ envs,
+ ["TEMP", "TMP", "TMPDIR"].map(|k| (k.into(), Some("/mdm/work".into())))
+ );
+ // What a caller gave stays.
+ let mut cmd = Command::new("x");
+ cmd.current_dir("/own").env("TMP", "/own-tmp");
+ apply(&mut cmd, &f);
+ assert_eq!(cmd.get_current_dir(), Some(Path::new("/own")));
+ let tmp = cmd.get_envs().find(|(k, _)| *k == "TMP").unwrap().1;
+ assert_eq!(tmp, Some(std::ffi::OsStr::new("/own-tmp")));
+ }
+}
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md
index b011bb49..aeb1c9ae 100644
--- a/docs/ARCHITECTURE.md
+++ b/docs/ARCHITECTURE.md
@@ -16,7 +16,7 @@ How Mister Download Manager's pieces fit together.
| `crates/debrid` | `mdm-debrid` | Debrid accounts (#44): the services' official APIs (Real-Debrid, AllDebrid, Premiumize, TorBox) turn a file host's link into a direct one the engine downloads |
| `crates/extract` | `mdm-extract` | Archive extraction (#37): zip, tar, gz and xz in process; 7z and RAR through an installed 7-Zip, run as its own program |
| `crates/geo` | `mdm-geo` | Where a download's server is (#140): an IP-to-country range table built from DB-IP's Lite data (`tools/geo/build.py`), looked up on this computer only, and the countries' flags |
-| `crates/tools` | `mdm-tools` | Video pages through yt-dlp and ffmpeg, image galleries through gallery-dl (run as separate programs); while a network adapter is chosen, their connections go through a proxy of MDM's on 127.0.0.1 that binds them to it (`relay.rs`) |
+| `crates/tools` | `mdm-tools` | Video pages through yt-dlp and ffmpeg, image galleries through gallery-dl (run as separate programs); while a network adapter is chosen, their connections go through a proxy of MDM's on 127.0.0.1 that binds them to it (`relay.rs`); each runs in a folder it can write, also its TEMP (`workdir.rs`) |
| `crates/crash` | `mdm-crash` | Crash and freeze reports: the monitor process, out-of-process minidumps, symbolicated stacks, the report's text and the release logs ([crash-reports.md](crash-reports.md)) |
| `crates/torrent` | `mdm-torrent` | BitTorrent and magnet links through librqbit |
| `crates/labserver` | `mdm-labserver` | An HTTP Range server with a request log and fault injection, and an FTP/FTPS server with its own faults, for tests and benchmarks |