Skip to content

Commit 18c0271

Browse files
committed
Add debug and warning messages to the "path" importer
1 parent 7c523a6 commit 18c0271

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/exporter/graphml.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use graphannis_core::{
2424
util::{join_qname, split_qname},
2525
};
2626
use itertools::Itertools;
27+
use log::{debug, warn};
2728
use serde_derive::{Deserialize, Serialize};
2829
use zip::ZipWriter;
2930

@@ -621,19 +622,34 @@ impl Exporter for GraphMLExporter {
621622
// used, we can store them in the ZIP file itself and the when
622623
// unpacked, the paths are still valid regardless of whether they
623624
// existed in the first place on the target system.
625+
debug!("Iterating over all linked files");
624626
for file_path in self.get_linked_files(graph)? {
627+
let file_path = file_path?;
625628
let original_path = self
626629
.zip_copy_from
627630
.clone()
628631
.unwrap_or_default()
629-
.join(file_path?);
632+
.join(&file_path);
633+
634+
debug!(
635+
"Attempt to copy file {original_path:?} (from label value \"{file_path:?}\") to ZIP"
636+
);
630637

631638
if original_path.is_relative() {
639+
debug!("Creating file in ZIP for {original_path:?}");
632640
zip_file.start_file(original_path.to_string_lossy(), zip_options)?;
641+
} else {
642+
warn!("Non-relative files are not supported in ZIP files: {original_path:?} ");
643+
}
644+
if original_path.exists() {
645+
let file_to_copy = File::open(original_path)?;
646+
let mut reader = BufReader::new(file_to_copy);
647+
std::io::copy(&mut reader, &mut zip_file)?;
648+
} else {
649+
warn!(
650+
"Could not copy {original_path:?} because the source file does not exist"
651+
);
633652
}
634-
let file_to_copy = File::open(original_path)?;
635-
let mut reader = BufReader::new(file_to_copy);
636-
std::io::copy(&mut reader, &mut zip_file)?;
637653
}
638654
}
639655
Ok(())

0 commit comments

Comments
 (0)