Skip to content

Commit ba08285

Browse files
committed
admin/render_readmes.rs to correctly identify the readme_path
Previously, it would try to get a field called `readme_file` which never existed in the Cargo.toml manifest format. This fixes it. https://doc.rust-lang.org/cargo/reference/manifest.html#the-readme-field I believe the confusion arose because the `cargo package` command actually converts the readme contents -> readme field and the Cargo.toml readme field -> `readme_file` field when making the request to crates.io. However, in the admin render_readme backfill, it is opening the original Cargo.toml which has a `readme` field for the path. I manually tested with a local backend/frontend and confirmed that readme paths were being re-rendered correctly.
1 parent f4ed6bb commit ba08285

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

src/admin/render_readmes.rs

+5-12
Original file line numberDiff line numberDiff line change
@@ -213,31 +213,24 @@ fn get_readme(
213213
};
214214

215215
let rendered = {
216-
let path = format!(
217-
"{}-{}/{}",
218-
krate_name, version.num, manifest.package.readme?
219-
);
216+
let readme_path = manifest.package.readme.as_ref()?;
217+
let path = format!("{}-{}/{}", krate_name, version.num, readme_path);
220218
let contents = find_file_by_path(&mut entries, Path::new(&path), version, krate_name);
221219
text_to_html(
222220
&contents,
223-
manifest
224-
.package
225-
.readme_file
226-
.as_ref()
227-
.map_or("README.md", |e| &**e),
221+
readme_path,
228222
manifest.package.repository.as_deref(),
229223
)
230224
};
231225
return Some(rendered);
232226

233-
#[derive(Deserialize)]
227+
#[derive(Debug, Deserialize)]
234228
struct Package {
235229
readme: Option<String>,
236-
readme_file: Option<String>,
237230
repository: Option<String>,
238231
}
239232

240-
#[derive(Deserialize)]
233+
#[derive(Debug, Deserialize)]
241234
struct Manifest {
242235
package: Package,
243236
}

0 commit comments

Comments
 (0)