commit 7b1e7e5feaaf2b63e5bff5d015a7c0ae4d0d506c
parent 3dde9494824bd75214b7a830375c849d9b64a7d8
Author: lash <dev@holbrook.no>
Date: Mon, 25 Jul 2022 14:35:30 +0000
Add xattr import
Diffstat:
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/src/main.rs b/src/main.rs
@@ -25,6 +25,7 @@ use log::{
info,
};
+use biblatex::EntryType;
use kitab::rdf::{
read as rdf_read,
read_all as rdf_read_all,
@@ -130,6 +131,23 @@ fn store(index_path: &Path, m: &MetaData) {
debug!("stored as rdf {:?}", fp);
}
+fn exec_import_xattr(f: &Path, index_path: &Path) -> bool {
+ let m = MetaData::from_xattr(f);
+ match m.typ() {
+ EntryType::Unknown(v) => {
+ debug!("vvv {}", v);
+ return false;
+ },
+ _ => {},
+ };
+
+ debug!("successfully processed xattr import source");
+
+ info!("importing xattr source {:?}", &m);
+ store(index_path, &m);
+ true
+}
+
fn exec_import_rdf(f: &Path, index_path: &Path) -> bool {
let f = File::open(f).unwrap();
let entries = match rdf_read_all(&f) {
@@ -153,7 +171,7 @@ fn exec_import_rdf(f: &Path, index_path: &Path) -> bool {
fn exec_import_biblatex(f: &Path, index_path: &Path) -> bool {
let f = File::open(f).unwrap();
let entries = match biblatex_read_all(&f) {
- Ok(v) => {
+ Ok(v) => {
v
},
Err(e) => {
@@ -207,6 +225,9 @@ fn main() {
Some(v) => {
let p = str_to_path(v);
info!("have path {:?}", &p);
+ if exec_import_xattr(p.as_path(), index_dir.as_path()) {
+ return;
+ }
if exec_import_rdf(p.as_path(), index_dir.as_path()) {
return;
}