-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exports #135
Exports #135
Conversation
theseus/src/util/export.rs
Outdated
for path in path_list { | ||
if let Some(ref loading_bar) = loading_bar { | ||
emit_loading(loading_bar, 1.0, None).await?; | ||
} | ||
|
||
// Get local path of file, relative to profile folder | ||
let name = path.strip_prefix(profile_base_path)?; | ||
|
||
// Get highest level folder pair ('a/b' in 'a/b/c', 'a' in 'a') | ||
// We only go one layer deep for the sake of not having a huge list of overrides | ||
let topmost_two = name | ||
.iter() | ||
.take(2) | ||
.map(|os| os.to_string_lossy().to_string()) | ||
.collect::<Vec<_>>(); | ||
|
||
// a,b => a/b | ||
// a => a | ||
let topmost = match topmost_two.len() { | ||
2 => topmost_two.join("/"), | ||
1 => topmost_two[0].clone(), | ||
_ => { | ||
return Err(crate::ErrorKind::OtherError( | ||
"No topmost folder found".to_string(), | ||
) | ||
.into()) | ||
} | ||
}; | ||
|
||
if !included_overrides.contains(&topmost) { | ||
continue; | ||
} | ||
|
||
let name: std::borrow::Cow<str> = name.to_string_lossy(); | ||
let name = name.replace('\\', "/"); | ||
let name = name.trim_start_matches('/').to_string(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be better to do a starts with check of the path instead of trying to get the first 2 components?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there are several potential cases where that could cause trouble. if we had a file without an extension like Makefile
and a folder called Makefile_helpers
(or anything else where there can be ambiguity between files) the rule wanting to just get Makefile would get all subfolders+files in Makefile_helpers
We could add handling for that easily dont get me wrong but it wouldnt be any simpler than using the path splitting IMO, what do you think
Fixes MOD-438