An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Data sync block flashcard
Liang Dingdce875160737
diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.goindex b8c6689ac0..4c693743f0 100644--- a/kernel/model/flashcard.go+++ b/kernel/model/flashcard.go@@ -17,7 +17,6 @@package modelimport (- "errors""math""os""path/filepath"@@ -247,10 +246,7 @@ func ReviewFlashcard(deckID, cardID string, rating riff.Rating, reviewedCardIDsdeckLock.Lock()defer deckLock.Unlock()- if syncingStorages {- err = errors.New(Conf.Language(81))- return- }+ waitForSyncingStorages()deck := Decks[deckID]card := deck.GetCard(cardID)@@ -290,10 +286,7 @@ func SkipReviewFlashcard(deckID, cardID string) (err error) {deckLock.Lock()defer deckLock.Unlock()- if syncingStorages {- err = errors.New(Conf.Language(81))- return- }+ waitForSyncingStorages()deck := Decks[deckID]card := deck.GetCard(cardID)@@ -330,10 +323,7 @@ func GetNotebookDueFlashcards(boxID string, reviewedCardIDs []string) (ret []*FldeckLock.Lock()defer deckLock.Unlock()- if syncingStorages {- err = errors.New(Conf.Language(81))- return- }+ waitForSyncingStorages()entries, err := os.ReadDir(filepath.Join(util.DataDir, boxID))if nil != err {@@ -384,10 +374,7 @@ func GetTreeDueFlashcards(rootID string, reviewedCardIDs []string) (ret []*FlashdeckLock.Lock()defer deckLock.Unlock()- if syncingStorages {- err = errors.New(Conf.Language(81))- return- }+ waitForSyncingStorages()deck := Decks[builtinDeckID]if nil == deck {@@ -425,10 +412,7 @@ func GetDueFlashcards(deckID string, reviewedCardIDs []string) (ret []*FlashcarddeckLock.Lock()defer deckLock.Unlock()- if syncingStorages {- err = errors.New(Conf.Language(81))- return- }+ waitForSyncingStorages()if "" == deckID {ret, unreviewedCount = getAllDueFlashcards(reviewedCardIDs)@@ -735,10 +719,7 @@ func RenameDeck(deckID, name string) (err error) {deckLock.Lock()defer deckLock.Unlock()- if syncingStorages {- err = errors.New(Conf.Language(81))- return- }+ waitForSyncingStorages()deck := Decks[deckID]deck.Name = name@@ -754,10 +735,7 @@ func RemoveDeck(deckID string) (err error) {deckLock.Lock()defer deckLock.Unlock()- if syncingStorages {- err = errors.New(Conf.Language(81))- return- }+ waitForSyncingStorages()riffSavePath := getRiffDir()deckPath := filepath.Join(riffSavePath, deckID+".deck")@@ -785,10 +763,7 @@ func CreateDeck(name string) (deck *riff.Deck, err error) {}func createDeck(name string) (deck *riff.Deck, err error) {- if syncingStorages {- err = errors.New(Conf.Language(81))- return- }+ waitForSyncingStorages()deckID := ast.NewNodeID()deck, err = createDeck0(name, deckID)diff --git a/kernel/model/repository.go b/kernel/model/repository.goindex 35f0c77539..d419bd4961 100644--- a/kernel/model/repository.go+++ b/kernel/model/repository.go@@ -831,7 +831,7 @@ var syncingFiles = sync.Map{}var syncingStorages = falsefunc waitForSyncingStorages() {- for i := 0; i < 30; i++ {+ for i := 0; i < 60; i++ {if syncingStorages {return}