sheet-organizer/src/sheet.rs

41 lines
1.0 KiB
Rust

#[derive(sqlx::FromRow, Debug)]
pub struct Sheet {
pub name: String,
// #[sqlx(from = "String")]
pub path: String,
// #[sqlx(from = "i64")]
pub file_size: i32,
pub file_hash: String,
}
#[derive(sqlx::FromRow)]
pub struct Composer {
pub name: String,
pub id: u32,
}
impl Sheet {
pub fn new_debug() -> Self {
Sheet {
name: "Hello world".to_string(),
path: "This/is/my/path".into(),
file_size: 42,
file_hash: "h4sh".to_string(),
}
}
pub fn verify_path(&self) -> std::io::Result<bool> {
// First compare file size since it is faster than hashing
// let file_size = fs::metadata(&self.path)?.len();
// if file_size == self.file_size {
// let file_content = fs::read(&self.path)?;
// let file_hash = blake3::hash(&file_content);
// if file_hash.to_string() == self.file_hash {
// return Ok(true);
// }
// }
Ok(false)
}
}