Skip to content

Commit 90790f0

Browse files
committed
BREAKING: return Ids when saving snapshots
1 parent 2c662b3 commit 90790f0

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

crates/core/src/backend/decrypt.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,15 +276,18 @@ pub trait DecryptWriteBackend: WriteBackend + Clone + 'static {
276276
&self,
277277
list: I,
278278
p: impl Progress,
279-
) -> RusticResult<()> {
279+
) -> RusticResult<Vec<Id>> {
280280
p.set_length(list.len() as u64);
281-
list.par_bridge().try_for_each(|file| -> RusticResult<_> {
282-
_ = self.save_file(file)?;
283-
p.inc(1);
284-
Ok(())
285-
})?;
281+
let ids = list
282+
.par_bridge()
283+
.map(|file| -> RusticResult<Id> {
284+
let id = self.save_file(file)?;
285+
p.inc(1);
286+
Ok(id)
287+
})
288+
.collect::<RusticResult<_>>()?;
286289
p.finish();
287-
Ok(())
290+
Ok(ids)
288291
}
289292

290293
/// Deletes the given list of files.

crates/core/src/commands/copy.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use log::trace;
44
use rayon::prelude::{IntoParallelRefIterator, ParallelBridge, ParallelIterator};
55

66
use crate::{
7-
backend::{decrypt::DecryptWriteBackend, node::NodeType},
7+
backend::node::NodeType,
88
blob::{packer::Packer, tree::TreeStreamerOnce, BlobType},
99
error::RusticResult,
1010
index::{indexer::Indexer, ReadIndex},
@@ -130,8 +130,7 @@ pub(crate) fn copy<'a, Q, R: IndexedFull, P: ProgressBars, S: IndexedIds>(
130130
_ = tree_packer.finalize()?;
131131
indexer.write().unwrap().finalize()?;
132132

133-
let p = pb.progress_counter("saving snapshots...");
134-
be_dest.save_list(snaps.iter(), p)?;
133+
let _ = repo_dest.save_snapshots(snaps)?;
135134
Ok(())
136135
}
137136

crates/core/src/repository.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,13 +1020,12 @@ impl<P: ProgressBars, S: Open> Repository<P, S> {
10201020
/// * [`CryptBackendErrorKind::SerializingToJsonByteVectorFailed`] - If the file could not be serialized to json.
10211021
///
10221022
/// [`CryptBackendErrorKind::SerializingToJsonByteVectorFailed`]: crate::error::CryptBackendErrorKind::SerializingToJsonByteVectorFailed
1023-
pub fn save_snapshots(&self, mut snaps: Vec<SnapshotFile>) -> RusticResult<()> {
1023+
pub fn save_snapshots(&self, mut snaps: Vec<SnapshotFile>) -> RusticResult<Vec<Id>> {
10241024
for snap in &mut snaps {
10251025
snap.id = Id::default();
10261026
}
10271027
let p = self.pb.progress_counter("saving snapshots...");
1028-
self.dbe().save_list(snaps.iter(), p)?;
1029-
Ok(())
1028+
self.dbe().save_list(snaps.iter(), p)
10301029
}
10311030

10321031
/// Check the repository for errors or inconsistencies

0 commit comments

Comments
 (0)