Skip to content

Commit

Permalink
fix(many): fix path related issues
Browse files Browse the repository at this point in the history
  • Loading branch information
fiji-flo committed Sep 12, 2024
1 parent 8323644 commit e2a6ebc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 7 additions & 3 deletions crates/rari-doc/src/redirects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::sync::LazyLock;

use rari_types::globals::{content_root, content_translated_root};
use rari_types::locale::Locale;
use rari_utils::error::RariIoError;
use tracing::error;

use crate::error::DocError;
Expand Down Expand Up @@ -48,7 +49,7 @@ static REDIRECTS: LazyLock<HashMap<String, String>> = LazyLock::new(|| {
if let Err(e) = read_redirects(
&content_root()
.to_path_buf()
.join("en-us")
.join(Locale::EnUs.as_folder_str())
.join("_redirects.txt"),
&mut map,
) {
Expand All @@ -70,11 +71,14 @@ fn read_redirects(path: &Path, map: &mut HashMap<String, String>) -> Result<(),
Ok(())
}

fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
fn read_lines<P>(filename: P) -> Result<io::Lines<io::BufReader<File>>, RariIoError>
where
P: AsRef<Path>,
{
let file = File::open(filename)?;
let file = File::open(filename.as_ref()).map_err(|e| RariIoError {
source: e,
path: filename.as_ref().to_path_buf(),
})?;
Ok(io::BufReader::new(file).lines())
}

Expand Down
5 changes: 4 additions & 1 deletion crates/rari-tools/src/popularities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::io::BufWriter;

use chrono::Utc;
use rari_types::globals::content_root;
use rari_types::locale::Locale;
use rari_types::Popularities;
use serde::Deserialize;

Expand Down Expand Up @@ -34,7 +35,9 @@ pub fn update_popularities(limit: usize) -> Popularities {
.insert(row.page, row.page_views / max);
}
}
let out_file = content_root().join("en-US").join("popularities.json");
let out_file = content_root()
.join(Locale::EnUs.as_folder_str())
.join("popularities.json");
let file = File::create(out_file).unwrap();
let buffed = BufWriter::new(file);

Expand Down

0 comments on commit e2a6ebc

Please sign in to comment.