Skip to content

Commit

Permalink
Merge pull request #16 from bkille/compare-paf-index-timestamps
Browse files Browse the repository at this point in the history
Compare paf index timestamps
  • Loading branch information
AndreaGuarracino authored May 21, 2024
2 parents 3a61f4d + 8f6b00e commit bb1ad8d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ To compile and install `impg` from source, you'll need a recent rust build toolc
## Authors

Erik Garrison <erik.garrison@gmail.com>
Andrea Guarracino <aguarra1@uthsc.edu>
Bryce Kille <brycekille@gmail.com>

## License
Expand Down
12 changes: 12 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,18 @@ fn generate_index(paf_file: &str, num_threads: NonZeroUsize) -> io::Result<Impg>

fn load_index(paf_file: &str) -> io::Result<Impg> {
let index_file = format!("{}.impg", paf_file);

let paf_file_metadata = std::fs::metadata(paf_file)?;
let index_file_metadata = std::fs::metadata(index_file.clone())?;
if let (Ok(paf_file_ts), Ok(index_file_ts)) = (paf_file_metadata.modified(), index_file_metadata.modified()) {
if paf_file_ts > index_file_ts
{
eprintln!("WARNING:\tPAF file has been modified since impg index creation.");
}
} else {
eprintln!("WARNING:\tUnable to compare timestamps of PAF file and impg index file. PAF file may have been modified since impg index creation.");
}

let file = File::open(index_file)?;
let reader = BufReader::new(file);
let serializable: SerializableImpg = bincode::deserialize_from(reader).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, format!("Failed to deserialize index: {:?}", e)))?;
Expand Down

0 comments on commit bb1ad8d

Please sign in to comment.