From 221e5c4be3d04c2a0a92a9bd4e447826905f7015 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 18 Apr 2023 13:36:01 +0800 Subject: [PATCH] :art: Avoid flashcard package data overwriting the cloud when syncing on a new device Fix https://github.com/siyuan-note/siyuan/issues/8024 --- kernel/model/flashcard.go | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.go index 9106abb21..b8c6689ac 100644 --- a/kernel/model/flashcard.go +++ b/kernel/model/flashcard.go @@ -608,6 +608,20 @@ func (tx *Transaction) doAddFlashcards(operation *Operation) (ret *TxErr) { deckID := operation.DeckID blockIDs := operation.BlockIDs + foundDeck := false + for _, deck := range Decks { + if deckID == deck.ID { + foundDeck = true + break + } + } + if !foundDeck { + deck, createErr := createDeck0("Built-in Deck", builtinDeckID) + if nil == createErr { + Decks[deck.ID] = deck + } + } + blockRoots := map[string]string{} for _, blockID := range blockIDs { bt := treenode.GetBlockTree(blockID) @@ -713,21 +727,6 @@ func LoadFlashcards() { Decks[deckID] = deck } } - - // 支持基于文档复习闪卡 https://github.com/siyuan-note/siyuan/issues/7057 - foundBuiltinDeck := false - for _, deck := range Decks { - if builtinDeckID == deck.ID { - foundBuiltinDeck = true - break - } - } - if !foundBuiltinDeck { - deck, createErr := createDeck0("Built-in Deck", builtinDeckID) - if nil == createErr { - Decks[deck.ID] = deck - } - } } const builtinDeckID = "20230218211946-2kw8jgx"