From e782ba1a6fd8342cddd961da9274dbd0244685d1 Mon Sep 17 00:00:00 2001 From: Philipp A Date: Wed, 13 Feb 2019 14:57:00 +0100 Subject: Use proper directory for cache files (#1763) Operating systems have defined directories for cache files. That allows them to do smart things such as leaving them out when doing a backup, or deleting them when disk space gets low. Also a %home%\.deno folder on windows made no sense whatsoever. Fixes #481 --- src/deno_dir.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/deno_dir.rs b/src/deno_dir.rs index 9d175077a..bcde87927 100644 --- a/src/deno_dir.rs +++ b/src/deno_dir.rs @@ -63,7 +63,13 @@ impl DenoDir { ) -> std::io::Result { // Only setup once. let home_dir = dirs::home_dir().expect("Could not get home directory."); - let default = home_dir.join(".deno"); + let fallback = home_dir.join(".deno"); + // We use the OS cache dir because all files deno writes are cache files + // Once that changes we need to start using different roots if DENO_DIR + // is not set, and keep a single one if it is. + let default = dirs::cache_dir() + .map(|d| d.join("deno")) + .unwrap_or(fallback); let root: PathBuf = custom_root.unwrap_or(default); let gen = root.as_path().join("gen"); -- cgit v1.2.3