Skip to content

Commit

Permalink
Conditionally compile normalize_mode to remove warnings on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
rcook committed Sep 3, 2024
1 parent 244a4aa commit 8d9ef73
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion decompress/src/decompressors/ar.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::decompressors::utils::normalize_mode;
use crate::{DecompressError, Decompression, Decompressor, ExtractOpts, Listing};
use ar::Archive;
use lazy_static::lazy_static;
Expand Down Expand Up @@ -130,6 +129,7 @@ impl Decompressor for Ar {

#[cfg(unix)]
{
use crate::decompressors::utils::normalize_mode;
use std::os::unix::fs::PermissionsExt;
let mode = normalize_mode(mode);
fs::set_permissions(&outpath, fs::Permissions::from_mode(mode))?;
Expand Down
2 changes: 1 addition & 1 deletion decompress/src/decompressors/tar_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::{
path::{Path, PathBuf},
};

use crate::decompressors::utils::normalize_mode;
use crate::{DecompressError, ExtractOpts};
use tar::Archive;

Expand Down Expand Up @@ -71,6 +70,7 @@ pub fn tar_extract(

#[cfg(unix)]
{
use crate::decompressors::utils::normalize_mode;
use std::os::unix::fs::PermissionsExt;
if let Ok(mode) = h {
let mode = normalize_mode(mode);
Expand Down
1 change: 1 addition & 0 deletions decompress/src/decompressors/utils.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(unix)]
pub fn normalize_mode(mode: u32) -> u32 {
if mode == 0 {
0o644
Expand Down
6 changes: 2 additions & 4 deletions decompress/src/decompressors/zip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ use lazy_static::lazy_static;
use regex::Regex;
use zip::ZipArchive;

use crate::{
decompressors::utils::normalize_mode, DecompressError, Decompression, Decompressor,
ExtractOpts, Listing,
};
use crate::{DecompressError, Decompression, Decompressor, ExtractOpts, Listing};

lazy_static! {
static ref RE: Regex = Regex::new(r"(?i)\.zip$").unwrap();
Expand Down Expand Up @@ -120,6 +117,7 @@ impl Decompressor for Zip {
// Get and Set permissions
#[cfg(unix)]
{
use crate::decompressors::utils::normalize_mode;
use std::os::unix::fs::PermissionsExt;
if let Some(mode) = file.unix_mode() {
let mode = normalize_mode(mode);
Expand Down

0 comments on commit 8d9ef73

Please sign in to comment.