pub struct ImportRun { /* private fields */ }Expand description
What one import run knows: each notes file it has touched, read from disk once and kept in step with what the run has stored since, in a dry run too. That is what makes the lines of one run be judged against each other, and a dry run report what the real run then does.
A run is a dry run or a real one from ImportRun::new to its end, so
what a dry run remembers as stored can never be taken for stored by a
real one: a preview and the import after it are two runs.
End a run with ImportRun::finish, on an early stop too: nothing a
real run stored is durable before it returns Ok. The compiler cannot
tell a run that was dropped on an early return from one that was
finished (#[must_use] only catches a run that is never bound). So a
real run that is dropped unfinished syncs what it appended as it goes,
and logs it if that fails; only the caller’s chance to see the error is
lost.
Implementations§
Source§impl ImportRun
impl ImportRun
Sourcepub fn new(dry_run: bool) -> Self
pub fn new(dry_run: bool) -> Self
A run that writes (dry_run false), or one that writes, creates and
syncs nothing and gives the outcomes the real run would give from the
same files.
pub fn is_dry_run(&self) -> bool
Sourcepub fn finish(self) -> Result<Vec<PathBuf>, MemoryError>
pub fn finish(self) -> Result<Vec<PathBuf>, MemoryError>
End the run: sync every file it appended to, then the directory of
each. An import’s appends are not synced one by one, so nothing the
run stored is durable until this returns Ok; call it when the run
stops early too. Returns the files synced, sorted. A dry run has
none.
Every file and every directory is tried, also after one failed.
An error is MemoryError::WrittenUnconfirmed for the first sync
that failed, naming its file: the lines the run reported as stored
are in their files, and that sync failed.