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: 支持间隔复习 https://github.com/siyuan-note/siyuan/issues/6710
Liang Ding72e3cf5135bf
diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.goindex a77369aaa3..036f4b7218 100644--- a/kernel/model/flashcard.go+++ b/kernel/model/flashcard.go@@ -17,6 +17,7 @@package modelimport (+ "errors""os""path/filepath""strings"@@ -59,9 +60,14 @@ func RenderFlashcard(blockID string) (content string, err error) {func ReviewFlashcard(deckID string, blockID string, rating riff.Rating) (err error) {deckLock.Lock()- deck := Decks[deckID]- deckLock.Unlock()+ defer deckLock.Unlock()++ if syncingStorages {+ err = errors.New(Conf.Language(81))+ return+ }+ deck := Decks[deckID]deck.Review(blockID, rating)err = deck.Save()if nil != err {@@ -77,14 +83,19 @@ type Flashcard struct {}func GetDueFlashcards(deckID string) (ret []*Flashcard, err error) {+ deckLock.Lock()+ defer deckLock.Unlock()++ if syncingStorages {+ err = errors.New(Conf.Language(81))+ return+ }+if "" == deckID {return getAllDueFlashcards()}- deckLock.Lock()deck := Decks[deckID]- deckLock.Unlock()-cards := deck.Dues()for _, card := range cards {blockID := card.BlockID()@@ -132,9 +143,14 @@ func getAllDueFlashcards() (ret []*Flashcard, err error) {func RemoveFlashcards(deckID string, blockIDs []string) (err error) {deckLock.Lock()- deck := Decks[deckID]- deckLock.Unlock()+ defer deckLock.Unlock()+ if syncingStorages {+ err = errors.New(Conf.Language(81))+ return+ }++ deck := Decks[deckID]var rootIDs []stringblockRoots := map[string]string{}for _, blockID := range blockIDs {@@ -214,9 +230,14 @@ func RemoveFlashcards(deckID string, blockIDs []string) (err error) {func AddFlashcards(deckID string, blockIDs []string) (err error) {deckLock.Lock()- deck := Decks[deckID]- deckLock.Unlock()+ defer deckLock.Unlock()++ if syncingStorages {+ err = errors.New(Conf.Language(81))+ return+ }+ deck := Decks[deckID]var rootIDs []stringblockRoots := map[string]string{}for _, blockID := range blockIDs {@@ -324,9 +345,14 @@ func InitFlashcards() {func RenameDeck(deckID, name string) (err error) {deckLock.Lock()- deck := Decks[deckID]- deckLock.Unlock()+ defer deckLock.Unlock()++ if syncingStorages {+ err = errors.New(Conf.Language(81))+ return+ }+ deck := Decks[deckID]deck.Name = nameerr = deck.Save()if nil != err {@@ -337,6 +363,14 @@ func RenameDeck(deckID, name string) (err error) {}func RemoveDeck(deckID string) (err error) {+ deckLock.Lock()+ defer deckLock.Unlock()++ if syncingStorages {+ err = errors.New(Conf.Language(81))+ return+ }+riffSavePath := getRiffDir()deckPath := filepath.Join(riffSavePath, deckID+".deck")if err = os.Remove(deckPath); nil != err {@@ -352,6 +386,14 @@ func RemoveDeck(deckID string) (err error) {}func CreateDeck(name string) (deck *riff.Deck, err error) {+ deckLock.Lock()+ defer deckLock.Unlock()++ if syncingStorages {+ err = errors.New(Conf.Language(81))+ return+ }+riffSavePath := getRiffDir()deckID := ast.NewNodeID()deck, err = riff.LoadDeck(riffSavePath, deckID)@@ -360,10 +402,7 @@ func CreateDeck(name string) (deck *riff.Deck, err error) {return}deck.Name = name-- deckLock.Lock()Decks[deckID] = deck- deckLock.Unlock()return}diff --git a/kernel/model/repository.go b/kernel/model/repository.goindex faa52e586d..3188d62fa6 100644--- a/kernel/model/repository.go+++ b/kernel/model/repository.go@@ -755,6 +755,7 @@ func IndexRepo(memo string) (err error) {}var syncingFiles = sync.Map{}+var syncingStorages = falsefunc IsSyncingFile(rootID string) (ret bool) {_, ret = syncingFiles.Load(rootID)@@ -803,14 +804,17 @@ func bootSyncRepo() (err error) {}syncingFiles = sync.Map{}+ syncingStorages = falsefor _, fetchedFile := range fetchedFiles {name := path.Base(fetchedFile.Path)- if !(strings.HasSuffix(name, ".sy")) {+ if strings.HasSuffix(name, ".sy") {+ id := name[:len(name)-3]+ syncingFiles.Store(id, true)continue}-- id := name[:len(name)-3]- syncingFiles.Store(id, true)+ if strings.HasPrefix(name, "/storage/") {+ syncingStorages = true+ }}elapsed := time.Since(start)@@ -843,6 +847,7 @@ func bootSyncRepo() (err error) {return}syncingFiles = sync.Map{}+ syncingStorages = false}()}return