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

Bug with zip sdists? #11

Open
matt-phylum opened this issue Aug 15, 2023 · 0 comments
Open

Bug with zip sdists? #11

matt-phylum opened this issue Aug 15, 2023 · 0 comments

Comments

@matt-phylum
Copy link
Contributor

I don't understand what this code is supposed to be doing, but it doesn't seem right.

When parsing an SDistType::Zip, parse_zip is called with "PKG-INFO":

SDistType::Zip => Self::parse_zip(path, "PKG-INFO"),
All other code paths pass a different string that doesn't satisfy the conditions for this behavior.

parse_zip finds all the contained file paths that end with "PKG-INFO":

let metadata_files: Vec<_> = archive
.file_names()
.filter(|name| name.ends_with(metadata_file_suffix))
.map(ToString::to_string)
.collect();

If there is one path ending with "PKG-INFO", it is used:

[metadata_file] => {
let mut buf = Vec::new();
archive.by_name(metadata_file)?.read_to_end(&mut buf)?;
Metadata::parse(&buf)
}
This seems right.

If there are two paths ending with "PKG-INFO" and either of them ends with ".egg-info/PKG-INFO", the first one is used:

[file1, file2]
if file1.ends_with(".egg-info/PKG-INFO")
|| file2.ends_with(".egg-info/PKG-INFO") =>
{
let mut buf = Vec::new();
archive.by_name(file1)?.read_to_end(&mut buf)?;
Metadata::parse(&buf)
}

I don't understand in what cases there would be two paths that end with "PKG-INFO", but it seems like if the code is checking that one of them ends with ".egg-info/PKG-INFO", the path that gets used should be related to the result of that check. It also seems like there is a problem if both of the paths end with ".egg-info/PKG-INFO".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant