Skip to content

Commit e2a6ebc

Browse files
committed
fix(many): fix path related issues
1 parent 8323644 commit e2a6ebc

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

Diff for: crates/rari-doc/src/redirects.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::sync::LazyLock;
88

99
use rari_types::globals::{content_root, content_translated_root};
1010
use rari_types::locale::Locale;
11+
use rari_utils::error::RariIoError;
1112
use tracing::error;
1213

1314
use crate::error::DocError;
@@ -48,7 +49,7 @@ static REDIRECTS: LazyLock<HashMap<String, String>> = LazyLock::new(|| {
4849
if let Err(e) = read_redirects(
4950
&content_root()
5051
.to_path_buf()
51-
.join("en-us")
52+
.join(Locale::EnUs.as_folder_str())
5253
.join("_redirects.txt"),
5354
&mut map,
5455
) {
@@ -70,11 +71,14 @@ fn read_redirects(path: &Path, map: &mut HashMap<String, String>) -> Result<(),
7071
Ok(())
7172
}
7273

73-
fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
74+
fn read_lines<P>(filename: P) -> Result<io::Lines<io::BufReader<File>>, RariIoError>
7475
where
7576
P: AsRef<Path>,
7677
{
77-
let file = File::open(filename)?;
78+
let file = File::open(filename.as_ref()).map_err(|e| RariIoError {
79+
source: e,
80+
path: filename.as_ref().to_path_buf(),
81+
})?;
7882
Ok(io::BufReader::new(file).lines())
7983
}
8084

Diff for: crates/rari-tools/src/popularities.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::io::BufWriter;
33

44
use chrono::Utc;
55
use rari_types::globals::content_root;
6+
use rari_types::locale::Locale;
67
use rari_types::Popularities;
78
use serde::Deserialize;
89

@@ -34,7 +35,9 @@ pub fn update_popularities(limit: usize) -> Popularities {
3435
.insert(row.page, row.page_views / max);
3536
}
3637
}
37-
let out_file = content_root().join("en-US").join("popularities.json");
38+
let out_file = content_root()
39+
.join(Locale::EnUs.as_folder_str())
40+
.join("popularities.json");
3841
let file = File::create(out_file).unwrap();
3942
let buffed = BufWriter::new(file);
4043

0 commit comments

Comments
 (0)