Skip to content

Commit

Permalink
Fixed which name it uses to look up the card
Browse files Browse the repository at this point in the history
  • Loading branch information
CEbbinghaus committed Sep 26, 2024
1 parent 2ea7bb2 commit 116b91a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions backend/src/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,33 +103,34 @@ fn find_mount_name() -> Result<Option<String>, Error> {
continue;
}

let mount: String = match entry.file_name().to_str() {
let raw_mount_name: String = match entry.file_name().to_str() {
Some(v) => v.to_owned(),
None => {
error!("Failed to convert mount point to string");
return Ok(None);
}
};
info!(mount = ?mount, "Found MicroSD Card mount label");

// apparently the label will occasionally contain ascii escape characters like \x20
let unescaped = match unescaper::unescape(&mount) {
let mount_name = match unescaper::unescape(&raw_mount_name) {
Ok(v) => v,
Err(err) => {
error!(%err, "Failed to unescape mount point");
return Ok(None);
}
};

if !has_libraryfolder(&Some(mount)) {
info!(mount = mount_name, "Found MicroSD Card mount label");

if !has_libraryfolder(&Some(mount_name)) {
warn!(
mount = unescaped,
mount = mount_name,
"Mount point does not resolve library folder"
);
return Ok(None);
}

return Ok(Some(unescaped));
return Ok(Some(mount_name));
}

Ok(None)
Expand Down

0 comments on commit 116b91a

Please sign in to comment.