Skip to content

Commit

Permalink
fix: ensure files inside the .wws folder are ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelmmiguel committed Jan 27, 2023
1 parent 9f49736 commit e74f319
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/router/files.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2022 VMware, Inc.
// SPDX-License-Identifier: Apache-2.0

use crate::store::STORE_FOLDER;
use std::ffi::OsStr;
use std::path::{Component, Path, PathBuf};
use wax::{Glob, WalkEntry};
Expand Down Expand Up @@ -32,7 +33,12 @@ impl Files {

glob.walk(&self.root)
.filter_map(|el| match el {
Ok(entry) if !self.is_in_public_folder(entry.path()) => Some(entry),
Ok(entry)
if !self.is_in_public_folder(entry.path())
&& !self.is_in_wws_folder(entry.path()) =>
{
Some(entry)
}
_ => None,
})
.collect()
Expand All @@ -51,6 +57,14 @@ impl Files {
_ => false,
})
}

/// Checks if the given filepath is inside the ".wws" special folder.
fn is_in_wws_folder(&self, path: &Path) -> bool {
path.components().any(|c| match c {
Component::Normal(os_str) => os_str == OsStr::new(STORE_FOLDER),
_ => false,
})
}
}

#[cfg(test)]
Expand Down

0 comments on commit e74f319

Please sign in to comment.