Skip to content

Commit 3ade20e

Browse files
committed
fix bug where "go to parent" wasn't shown in file-list for root files
1 parent e58ddc2 commit 3ade20e

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/web/source.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -269,25 +269,32 @@ pub(crate) async fn source_browser_handler(
269269
(None, None)
270270
};
271271

272+
let current_folder = if let Some(last_slash_pos) = path.rfind('/') {
273+
&path[..last_slash_pos + 1]
274+
} else {
275+
""
276+
};
277+
272278
let file_list = spawn_blocking({
273279
let name = name.clone();
274-
let path = path.clone();
280+
let current_folder = current_folder.to_string();
275281
move || {
276-
let folder = if let Some(last_slash_pos) = path.rfind('/') {
277-
&path[..last_slash_pos + 1]
278-
} else {
279-
""
280-
};
281282
let mut conn = pool.get()?;
282-
FileList::from_path(&mut conn, &name, &version, &version_or_latest, folder)
283+
FileList::from_path(
284+
&mut conn,
285+
&name,
286+
&version,
287+
&version_or_latest,
288+
&current_folder,
289+
)
283290
}
284291
})
285292
.await?
286293
.ok_or(AxumNope::ResourceNotFound)?;
287294

288295
Ok(SourcePage {
289296
file_list,
290-
show_parent_link: !path.is_empty(),
297+
show_parent_link: !current_folder.is_empty(),
291298
file,
292299
file_content,
293300
canonical_url: format!("https://docs.rs/crate/{}/latest/source/{}", name, path),

0 commit comments

Comments
 (0)