Skip to content
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

Merged
merged 29 commits into from
Jun 26, 2023
Merged

Exports #135

merged 29 commits into from
Jun 26, 2023

Conversation

thesuzerain
Copy link
Contributor

@thesuzerain thesuzerain commented Jun 6, 2023

Fixes MOD-438

@thesuzerain thesuzerain marked this pull request as ready for review June 6, 2023 18:58
theseus/src/api/pack.rs Outdated Show resolved Hide resolved
Comment on lines 69 to 104
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();
Copy link
Member

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?

Copy link
Contributor Author

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

theseus/src/util/export.rs Show resolved Hide resolved
theseus/src/api/profile.rs Show resolved Hide resolved
@Geometrically Geometrically merged commit 47970d9 into master Jun 26, 2023
@Geometrically Geometrically deleted the exports branch June 26, 2023 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants