Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Avoid flashcard package data overwriting the cloud when syncing on a new device Fix https://github.com/siyuan-note/siyuan/issues/8024

Liang Ding221e5c4be3d0
diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.go
index 9106abb212..b8c6689ac0 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"