Skip to content

Commit 084d8c7

Browse files
committed
delegate filename resolution to stam-rust
1 parent 42e2a03 commit 084d8c7

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/annotationstore.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use pyo3::exceptions::{PyRuntimeError, PyTypeError, PyValueError};
22
use pyo3::prelude::*;
33
use pyo3::types::*;
44
use std::ops::FnOnce;
5-
use std::path::Path;
65
use std::sync::{Arc, RwLock};
76

87
use crate::annotation::{PyAnnotation, PyAnnotations};
@@ -233,10 +232,10 @@ impl PyAnnotationStore {
233232
let store_clone = self.store.clone();
234233
self.map_mut(|store| {
235234
let mut dataset = if let Some(filename) = filename {
236-
if Path::new(filename).exists() {
237-
AnnotationDataSet::from_file(filename, store.config().clone())?
238-
} else {
239-
AnnotationDataSet::new(store.config().clone())
235+
match AnnotationDataSet::from_file(filename, store.config().clone()) {
236+
Ok(dataset) => dataset,
237+
Err(StamError::IOError(..)) => AnnotationDataSet::new(store.config().clone()), //no such file, create anew
238+
Err(e) => return Err(e), //other error, propagate
240239
}
241240
} else {
242241
AnnotationDataSet::new(store.config().clone())

0 commit comments

Comments
 (0)