From c4d33e8d778aa1b86197f1c54ff8e4e61a2ebf53 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 26 Oct 2020 12:58:58 -0400 Subject: [PATCH] fix: Use -rw-r--r-- for cache files (#8132) --- cli/disk_cache.rs | 2 +- cli/http_cache.rs | 6 ++++-- cli/main.rs | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cli/disk_cache.rs b/cli/disk_cache.rs index 1fc9b32898..398085cc25 100644 --- a/cli/disk_cache.rs +++ b/cli/disk_cache.rs @@ -145,7 +145,7 @@ impl DiskCache { Some(ref parent) => self.ensure_dir_exists(parent), None => Ok(()), }?; - deno_fs::write_file(&path, data, 0o666) + deno_fs::write_file(&path, data, crate::http_cache::CACHE_PERM) .map_err(|e| with_io_context(&e, format!("{:#?}", &path))) } } diff --git a/cli/http_cache.rs b/cli/http_cache.rs index 73d5698514..7310c9e921 100644 --- a/cli/http_cache.rs +++ b/cli/http_cache.rs @@ -17,6 +17,8 @@ use std::io; use std::path::Path; use std::path::PathBuf; +pub const CACHE_PERM: u32 = 0o644; + /// Turn base of url (scheme, hostname, port) into a valid filename. /// This method replaces port part with a special string token (because /// ":" cannot be used in filename on some platforms). @@ -85,7 +87,7 @@ impl Metadata { pub fn write(&self, cache_filename: &Path) -> Result<(), AnyError> { let metadata_filename = Self::filename(cache_filename); let json = serde_json::to_string_pretty(self)?; - deno_fs::write_file(&metadata_filename, json, 0o666)?; + deno_fs::write_file(&metadata_filename, json, CACHE_PERM)?; Ok(()) } @@ -159,7 +161,7 @@ impl HttpCache { .expect("Cache filename should have a parent dir"); self.ensure_dir_exists(parent_filename)?; // Cache content - deno_fs::write_file(&cache_filename, content, 0o666)?; + deno_fs::write_file(&cache_filename, content, CACHE_PERM)?; let metadata = Metadata { url: url.to_string(), diff --git a/cli/main.rs b/cli/main.rs index 2acdff57d6..75677d1fbb 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -375,7 +375,7 @@ async fn bundle_command( if let Some(out_file_) = out_file.as_ref() { let output_bytes = output.as_bytes(); let output_len = output_bytes.len(); - deno_fs::write_file(out_file_, output_bytes, 0o666)?; + deno_fs::write_file(out_file_, output_bytes, 0o644)?; info!( "{} {:?} ({})", colors::green("Emit"),