|
|
@@ -1,7 +1,7 @@
|
|
|
use std::{
|
|
|
collections::{HashMap, HashSet},
|
|
|
fmt,
|
|
|
- fs::{self, File},
|
|
|
+ fs::{self, File, OpenOptions},
|
|
|
io::{BufReader, Read},
|
|
|
os::unix::fs::MetadataExt,
|
|
|
path::Path,
|
|
|
@@ -140,6 +140,7 @@ impl FlowCells {
|
|
|
instance.load_from_archive(archive_store_path)?;
|
|
|
instance.load_from_local(local_run_dir)?;
|
|
|
instance.annotate_with_inputs(inputs_path)?;
|
|
|
+ instance.save_to_archive(archive_store_path)?;
|
|
|
|
|
|
Ok(instance)
|
|
|
}
|
|
|
@@ -167,6 +168,20 @@ impl FlowCells {
|
|
|
Ok(())
|
|
|
}
|
|
|
|
|
|
+ pub fn save_to_archive(&mut self, archive_path: &str) -> anyhow::Result<()> {
|
|
|
+ let file = OpenOptions::new()
|
|
|
+ .write(true)
|
|
|
+ .create(true)
|
|
|
+ .truncate(true)
|
|
|
+ .open(archive_path)
|
|
|
+ .with_context(|| format!("Failed to open archive file for writing: {archive_path}"))?;
|
|
|
+
|
|
|
+ serde_json::to_writer_pretty(file, &self.flow_cells)
|
|
|
+ .with_context(|| format!("Failed to write FlowCells to: {archive_path}"))?;
|
|
|
+
|
|
|
+ Ok(())
|
|
|
+ }
|
|
|
+
|
|
|
/// Scan local run directories for flowcells and merge into `self.flow_cells`.
|
|
|
///
|
|
|
/// Uses `scan_local()` to parse local metadata and selects the most recently modified
|