Borrow dids in remove_decks_and_child_decks

This commit is contained in:
RumovZ 2021-03-10 15:56:54 +01:00
parent 602ffa67a7
commit e1db8e1da1
3 changed files with 5 additions and 5 deletions

View file

@ -663,7 +663,7 @@ impl BackendService for Backend {
}
fn remove_decks(&self, input: pb::DeckIDs) -> BackendResult<Empty> {
self.with_col(|col| col.remove_decks_and_child_decks(input.into()))
self.with_col(|col| col.remove_decks_and_child_decks(&Into::<Vec<DeckID>>::into(input)))
.map(Into::into)
}

View file

@ -440,14 +440,14 @@ impl Collection {
self.storage.get_deck_id(&machine_name)
}
pub fn remove_decks_and_child_decks(&mut self, dids: Vec<DeckID>) -> Result<()> {
pub fn remove_decks_and_child_decks(&mut self, dids: &[DeckID]) -> Result<()> {
// fixme: vet cache clearing
self.state.deck_cache.clear();
self.transact(None, |col| {
let usn = col.usn()?;
for did in dids {
if let Some(deck) = col.storage.get_deck(did)? {
if let Some(deck) = col.storage.get_deck(*did)? {
let child_decks = col.storage.child_decks(&deck)?;
// top level
@ -779,7 +779,7 @@ mod test {
// delete top level
let top = col.get_or_create_normal_deck("one")?;
col.remove_decks_and_child_decks(vec![top.id])?;
col.remove_decks_and_child_decks(&[top.id])?;
// should have come back as "Default+" due to conflict
assert_eq!(sorted_names(&col), vec!["default", "Default+"]);

View file

@ -1532,7 +1532,7 @@ mod test {
col1.remove_cards_and_orphaned_notes(&[cardid])?;
let usn = col1.usn()?;
col1.remove_note_only_undoable(noteid, usn)?;
col1.remove_decks_and_child_decks(vec![deckid])?;
col1.remove_decks_and_child_decks(&[deckid])?;
let out = ctx.normal_sync(&mut col1).await;
assert_eq!(out.required, SyncActionRequired::NoChanges);