1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-09 15:48:16 -05:00

fix: Use -rw-r--r-- for cache files (#8132)

This commit is contained in:
Ryan Dahl 2020-10-26 12:58:58 -04:00 committed by GitHub
parent b9dc2c3521
commit c4d33e8d77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View file

@ -145,7 +145,7 @@ impl DiskCache {
Some(ref parent) => self.ensure_dir_exists(parent), Some(ref parent) => self.ensure_dir_exists(parent),
None => Ok(()), 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))) .map_err(|e| with_io_context(&e, format!("{:#?}", &path)))
} }
} }

View file

@ -17,6 +17,8 @@ use std::io;
use std::path::Path; use std::path::Path;
use std::path::PathBuf; use std::path::PathBuf;
pub const CACHE_PERM: u32 = 0o644;
/// Turn base of url (scheme, hostname, port) into a valid filename. /// Turn base of url (scheme, hostname, port) into a valid filename.
/// This method replaces port part with a special string token (because /// This method replaces port part with a special string token (because
/// ":" cannot be used in filename on some platforms). /// ":" cannot be used in filename on some platforms).
@ -85,7 +87,7 @@ impl Metadata {
pub fn write(&self, cache_filename: &Path) -> Result<(), AnyError> { pub fn write(&self, cache_filename: &Path) -> Result<(), AnyError> {
let metadata_filename = Self::filename(cache_filename); let metadata_filename = Self::filename(cache_filename);
let json = serde_json::to_string_pretty(self)?; 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(()) Ok(())
} }
@ -159,7 +161,7 @@ impl HttpCache {
.expect("Cache filename should have a parent dir"); .expect("Cache filename should have a parent dir");
self.ensure_dir_exists(parent_filename)?; self.ensure_dir_exists(parent_filename)?;
// Cache content // Cache content
deno_fs::write_file(&cache_filename, content, 0o666)?; deno_fs::write_file(&cache_filename, content, CACHE_PERM)?;
let metadata = Metadata { let metadata = Metadata {
url: url.to_string(), url: url.to_string(),

View file

@ -375,7 +375,7 @@ async fn bundle_command(
if let Some(out_file_) = out_file.as_ref() { if let Some(out_file_) = out_file.as_ref() {
let output_bytes = output.as_bytes(); let output_bytes = output.as_bytes();
let output_len = output_bytes.len(); 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!( info!(
"{} {:?} ({})", "{} {:?} ({})",
colors::green("Emit"), colors::green("Emit"),