Skip to content

Commit

Permalink
fix(filebrowser): fix "couldn't get parent of path" error
Browse files Browse the repository at this point in the history
  • Loading branch information
ravenclaw900 committed Jun 20, 2022
1 parent deb5ec5 commit 7817b65
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/backend/src/page_handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,16 @@ async fn browser_handler_helper(
socket_send: &mut SplitSink<warp::ws::WebSocket, Message>,
) -> anyhow::Result<()> {
match data.cmd.as_str() {
"cd" => {
let _send = socket_send
.send(Message::text(SerJson::serialize_json(
&shared::BrowserList {
contents: systemdata::browser_dir(std::path::Path::new(&data.args[0]))?,
},
)))
.await;
return Ok(());
}
"copy" => {
let mut num = 2;
while std::path::Path::new(&format!("{} {}", &data.args[0], num)).exists() {
Expand Down Expand Up @@ -287,8 +297,6 @@ async fn browser_handler_helper(
_ => {}
}

// 'refresh' and 'cd' covered here
// TODO: remove 'refresh', only use 'cd'
browser_refresh(socket_send, std::path::Path::new(&data.args[0])).await?;

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/src/pages/FileBrowser.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
try {
let msg = JSON.parse(e.data);
if (msg.finished) {
sendCmd(`${currentPath}/.`, "refresh");
sendCmd(`${currentPath}`, "cd");
} else if (msg.size) {
maxSlices = msg.size;
}
Expand Down Expand Up @@ -430,7 +430,7 @@
class="cursor-pointer"
title="Refresh"
on:click={() => {
sendCmd(`${currentPath}/.`, "refresh");
sendCmd(`${currentPath}`, "cd");
}}><Fa icon={faSyncAlt} size="lg" /></span
>
<span
Expand Down

0 comments on commit 7817b65

Please sign in to comment.