feat(markdown) remove id check & extraction

This commit is contained in:
lumither committed 2025-03-26 19:44:47 -07:00
1 parent ac5f30151f
commit b748764d79
2 files changed
+1 -18

No files matched your search

-6
View File
@@ -2,12 +2,6 @@ use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[error("missing front-matter field: id")]
MissingID,
#[error("invalid file id: {}", msg)]
InvalidID { msg: String },
#[error("invalid front-matter: {}", msg)]
InvalidFrontMatter { msg: String },
+1 -12
View File
@@ -3,20 +3,17 @@ mod utils;
use std::fs;
use std::path::Path;
use std::str::FromStr;
use crate::error::Error;
use crate::utils::front_matter::{parse_front_matter, split_md_front_matter};
use base64::{Engine, engine::general_purpose};
use base64::{engine::general_purpose, Engine};
use serde::Serialize;
use serde_json::Value;
use sha2::{Digest, Sha256};
use uuid::Uuid;
#[derive(Default, Debug, Serialize)]
pub struct MdFile {
pub file_id: Uuid,
pub filename: String,
pub meta: Value,
pub content: String,
@@ -36,13 +33,6 @@ impl MdFile {
Err(e) => return Err(Error::InvalidFrontMatter { msg: e.to_string() }),
};
let hash = calculate_hash_base64(&raw_file_bytes);
let file_id = match front_matter["id"].as_str() {
Some(id) => match Uuid::from_str(id) {
Ok(id) => id,
Err(e) => return Err(Error::InvalidID { msg: e.to_string() }),
},
None => return Err(Error::MissingID),
};
let file_name = Path::new(file_path)
.file_name()
.unwrap()
@@ -51,7 +41,6 @@ impl MdFile {
.to_string();
Ok(MdFile {
file_id,
filename: file_name,
meta: front_matter,
content,