This commit is contained in:
despiegk 2025-04-09 07:56:46 +02:00
parent 44cbf20d7b
commit b9df692a54
4 changed files with 10 additions and 21 deletions

View File

@ -2,6 +2,9 @@
name = "doctree"
version = "0.1.0"
edition = "2024"
[lib]
path = "src/lib.rs"
[dependencies]
walkdir = "2.3.3"

View File

@ -156,8 +156,11 @@ impl Collection {
// Check if the path is valid
if self.path.as_os_str().is_empty() {
// If the path is empty, we're working with a collection loaded from Redis
// Return a placeholder content for demonstration purposes
return Ok(format!("Content for {} in collection {}\nThis is a placeholder since the actual file path is not available.", page_name, self.name));
// Return an error since the actual file path is not available
return Err(DocTreeError::IoError(std::io::Error::new(
std::io::ErrorKind::NotFound,
format!("File path not available for {} in collection {}", page_name, self.name)
)));
}
// Read the file

View File

@ -4,11 +4,11 @@ use std::sync::{Arc, Mutex};
use std::fs;
use serde::Deserialize;
use crate::collection::{Collection, CollectionBuilder};
use crate::collection::Collection;
use crate::error::{DocTreeError, Result};
use crate::storage::RedisStorage;
use crate::include::process_includes;
use crate::utils::{name_fix, ensure_md_extension};
use crate::utils::name_fix;
/// Configuration for a collection from a .collection file
#[derive(Deserialize, Default, Debug)]

View File

@ -78,20 +78,3 @@ pub fn ensure_md_extension(name: &str) -> String {
name.to_string()
}
}
/// Get the file extension from a path
///
/// # Arguments
///
/// * `path` - The path to check
///
/// # Returns
///
/// The file extension or an empty string
pub fn get_extension(path: &str) -> String {
Path::new(path)
.extension()
.and_then(|ext| ext.to_str())
.unwrap_or("")
.to_string()
}