diff --git a/src/main.rs b/src/main.rs
index b8ea2ee..ef83c60 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -279,7 +279,7 @@ fn handle_connection(
let mut pk_path = path.to_path_buf();
let mut data_path = path.to_path_buf();
- let (pki_path, start_level, relative_path, partial) = if relative_path.is_empty() {
+ let (pki_path, audio_path, start_level, relative_path, partial) = if relative_path.is_empty() {
if access == Access::Full {
pk_path.push("index.pk");
data_path.push("index.dat");
@@ -288,9 +288,10 @@ fn handle_connection(
data_path.push("partial.dat");
}
- (None, 0, String::new(), None)
+ (None, None, 0, String::new(), None)
} else {
let mut pki_path = path.to_path_buf();
+ let mut audio_path = path.to_path_buf();
let path = percent_decode_str(relative_path).decode_utf8_lossy();
if path.contains('_') {
@@ -312,14 +313,16 @@ fn handle_connection(
} else {
pki_path.push(format!("{path}.pkc"));
}
+ audio_path.push(format!("{path}.mp3"));
data_path.push(format!("{path}.dat"));
- (Some(pki_path), 1, path.to_string(), num)
+ (Some(pki_path), Some(audio_path), 1, path.to_string(), num)
};
let file_paths = DocumentPaths {
pk: &pk_path,
pki: pki_path.as_ref().map(|path| path.as_ref()),
+ audio: audio_path.as_ref().map(|path| path.as_ref()),
data: &data_path,
};
@@ -414,6 +417,7 @@ fn reply_binary(
struct DocumentPaths<'a> {
pk: &'a Path,
pki: Option<&'a Path>,
+ audio: Option<&'a Path>,
data: &'a Path,
}
@@ -532,24 +536,36 @@ fn handle_relative_connection(
let handle_entry = |mut entry: &str, output: &mut TcpStream, level: usize| {
let level = level + 1;
- let mut path = path.to_path_buf();
+ let mut pki_path = path.to_path_buf();
+ let mut audio_path = path.to_path_buf();
if let Some((real_entry, _)) = entry.split_once(':') {
entry = real_entry
}
let pki_extension = if censored { "pkc" } else { "pki" };
- path.push(if relative_path.is_empty() {
- format!("{entry}.{pki_extension}")
+ if relative_path.is_empty() {
+ pki_path.push(format!("{entry}.{pki_extension}"));
+ audio_path.push(format!("{entry}.mp3"));
} else {
- format!("{relative_path}/{entry}.{pki_extension}")
- });
+ pki_path.push(format!("{relative_path}/{entry}.{pki_extension}"));
+ audio_path.push(format!("{relative_path}/{entry}.mp3"));
+ };
- let Ok(file) = File::open(path) else {
+ let Ok(file) = File::open(pki_path) else {
return;
};
+
let _ = writeln!(
output,
"