fix(sdk): Fix resolving package wildcards
Directories were ignored as invalid extension type. Now they are recursed into.
This commit is contained in:
parent
bc4d2fcd8a
commit
0cf2908904
3 changed files with 40 additions and 17 deletions
12
Cargo.lock
generated
12
Cargo.lock
generated
|
@ -56,6 +56,17 @@ version = "1.0.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46016233fc1bb55c23b856fe556b7db6ccd05119a0a392e04f0b3b7c79058f16"
|
||||
|
||||
[[package]]
|
||||
name = "async-recursion"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b015a331cc64ebd1774ba119538573603427eaace0a1950c423ab971f903796"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "atk"
|
||||
version = "0.16.0"
|
||||
|
@ -2007,6 +2018,7 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
|||
name = "sdk"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"async-recursion",
|
||||
"bitflags",
|
||||
"byteorder",
|
||||
"color-eyre",
|
||||
|
|
|
@ -23,3 +23,4 @@ tokio-stream = { version = "0.1.11", features = ["fs", "io-util"] }
|
|||
tracing = { version = "0.1.37", features = ["async-await"] }
|
||||
tracing-error = "0.2.0"
|
||||
luajit2-sys = "0.0.2"
|
||||
async-recursion = "1.0.2"
|
||||
|
|
|
@ -4,6 +4,7 @@ use std::ops::{Deref, DerefMut};
|
|||
use std::path::{Path, PathBuf};
|
||||
use std::str::FromStr;
|
||||
|
||||
use async_recursion::async_recursion;
|
||||
use color_eyre::eyre::{self, Context};
|
||||
use color_eyre::Result;
|
||||
use tokio::fs;
|
||||
|
@ -13,14 +14,15 @@ use crate::bundle::file::{BundleFileType, UserFile};
|
|||
use crate::murmur::{HashGroup, Murmur64};
|
||||
|
||||
#[tracing::instrument]
|
||||
#[async_recursion]
|
||||
async fn resolve_wildcard<P1, P2>(
|
||||
wildcard: P1,
|
||||
root: P2,
|
||||
t: Option<BundleFileType>,
|
||||
) -> Result<Vec<PathBuf>>
|
||||
where
|
||||
P1: AsRef<Path> + std::fmt::Debug,
|
||||
P2: AsRef<Path> + std::fmt::Debug,
|
||||
P1: AsRef<Path> + std::fmt::Debug + std::marker::Send,
|
||||
P2: AsRef<Path> + std::fmt::Debug + std::marker::Send + std::marker::Copy,
|
||||
{
|
||||
let wildcard = wildcard.as_ref();
|
||||
|
||||
|
@ -56,6 +58,12 @@ where
|
|||
path.to_path_buf()
|
||||
};
|
||||
|
||||
let meta = entry.metadata().await?;
|
||||
if meta.is_dir() {
|
||||
let wildcard = file_path.join("*");
|
||||
let inner_paths = resolve_wildcard(wildcard, root, t).await?;
|
||||
paths.extend_from_slice(&inner_paths);
|
||||
} else {
|
||||
// Skip file if there is a desired extension `t`, but the file's
|
||||
// extension name doesn't match
|
||||
if t.is_some() {
|
||||
|
@ -65,7 +73,7 @@ where
|
|||
.and_then(|ext| BundleFileType::from_str(ext).ok());
|
||||
|
||||
if ext != t {
|
||||
tracing::debug!(
|
||||
tracing::warn!(
|
||||
"Skipping wildcard result with invalid extension: {}",
|
||||
file_path.display(),
|
||||
);
|
||||
|
@ -73,8 +81,10 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
tracing::debug!("Found file {}", file_path.display());
|
||||
paths.push(file_path);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(paths)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue