mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-17 09:20:03 +00:00
Fix zip extraction and bins::infer_bin_dir_template
(#869)
- Fix zip extraction code: Ensure dir is rwx and file is readable for curr user - Add more integration test for `ExtractedFiles` - Fix `bins::infer_bin_dir_template` introduced in #856 Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
460522f5bd
commit
01c8ecb778
4 changed files with 56 additions and 14 deletions
|
@ -79,14 +79,18 @@ impl ExtractedFiles {
|
|||
}
|
||||
}
|
||||
|
||||
/// * `path` - must be canonical and must not be empty, but could be "."
|
||||
/// for top-level.
|
||||
/// * `path` - must be a relative path without `.`, `..`, `/`, `prefix:/`
|
||||
/// and must not be empty, for these values it is guaranteed to
|
||||
/// return `None`.
|
||||
/// But could be set to "." for top-level.
|
||||
pub fn get_entry(&self, path: &Path) -> Option<&ExtractedFilesEntry> {
|
||||
self.0.get(path)
|
||||
}
|
||||
|
||||
/// * `path` - must be canonical and must not be empty, but could be "."
|
||||
/// for top-level.
|
||||
/// * `path` - must be a relative path without `.`, `..`, `/`, `prefix:/`
|
||||
/// and must not be empty, for these values it is guaranteed to
|
||||
/// return `None`.
|
||||
/// But could be set to "." for top-level.
|
||||
pub fn get_dir(&self, path: &Path) -> Option<&HashSet<Box<OsStr>>> {
|
||||
match self.get_entry(path)? {
|
||||
ExtractedFilesEntry::Dir(file_names) => Some(file_names),
|
||||
|
@ -94,8 +98,10 @@ impl ExtractedFiles {
|
|||
}
|
||||
}
|
||||
|
||||
/// * `path` - must be canonical and must not be empty, but could be "."
|
||||
/// for top-level.
|
||||
/// * `path` - must be a relative path without `.`, `..`, `/`, `prefix:/`
|
||||
/// and must not be empty, for these values it is guaranteed to
|
||||
/// return `false`.
|
||||
/// But could be set to "." for top-level.
|
||||
pub fn has_file(&self, path: &Path) -> bool {
|
||||
matches!(self.get_entry(path), Some(ExtractedFilesEntry::File))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue