From d3eb23c137e226e4803c5c94e8fe6d58b9d6ce14 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 7 Jun 2022 18:18:03 +0800 Subject: [PATCH 1/4] :bug: Fix npe --- kernel/api/filetree.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/api/filetree.go b/kernel/api/filetree.go index 758db6f91..da29033e7 100644 --- a/kernel/api/filetree.go +++ b/kernel/api/filetree.go @@ -200,6 +200,9 @@ func getFullHPathByID(c *gin.Context) { if !ok { return } + if nil == arg["id"] { + return + } id := arg["id"].(string) hPath, err := model.GetFullHPathByID(id) From 3aced60e8cc814b965670c153dda93b3b352359c Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 7 Jun 2022 18:27:51 +0800 Subject: [PATCH 2/4] =?UTF-8?q?:recycle:=20`=E5=B7=A5=E4=BD=9C=E7=A9=BA?= =?UTF-8?q?=E9=97=B4/incremental/`=20=E6=96=87=E4=BB=B6=E5=A4=B9=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E5=88=B0=20`=E5=B7=A5=E4=BD=9C=E7=A9=BA=E9=97=B4/temp?= =?UTF-8?q?/incremental/`=20Fix=20https://github.com/siyuan-note/siyuan/is?= =?UTF-8?q?sues/5119?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/api/system.go | 4 ++-- kernel/model/backup.go | 4 ++-- kernel/model/conf.go | 1 + kernel/model/sync.go | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/kernel/api/system.go b/kernel/api/system.go index 12336d3d3..bddd3288c 100644 --- a/kernel/api/system.go +++ b/kernel/api/system.go @@ -347,12 +347,12 @@ func setE2EEPasswd(c *gin.Context) { ret.Msg = err.Error() return } - if err := os.RemoveAll(filepath.Join(util.WorkspaceDir, "incremental")); nil != err { + if err := os.RemoveAll(filepath.Join(util.TempDir, "incremental")); nil != err { ret.Code = -1 ret.Msg = err.Error() return } - if err := os.MkdirAll(filepath.Join(util.WorkspaceDir, "incremental"), 0755); nil != err { + if err := os.MkdirAll(filepath.Join(util.TempDir, "incremental"), 0755); nil != err { ret.Code = -1 ret.Msg = err.Error() return diff --git a/kernel/model/backup.go b/kernel/model/backup.go index 4eab44826..ddf95bd3c 100644 --- a/kernel/model/backup.go +++ b/kernel/model/backup.go @@ -379,7 +379,7 @@ func UploadBackup() (err error) { var pathJSON = fmt.Sprintf("%x", md5.Sum([]byte("paths.json"))) // 6952277a5a37c17aa6a7c6d86cd507b1 func encryptDataDir(passwd string) (encryptedDataDir string, err error) { - encryptedDataDir = filepath.Join(util.WorkspaceDir, "incremental", "backup-encrypt") + encryptedDataDir = filepath.Join(util.TempDir, "incremental", "backup-encrypt") if err = os.RemoveAll(encryptedDataDir); nil != err { return } @@ -511,7 +511,7 @@ func encryptDataDir(passwd string) (encryptedDataDir string, err error) { } func decryptDataDir(passwd string) (decryptedDataDir string, err error) { - decryptedDataDir = filepath.Join(util.WorkspaceDir, "incremental", "backup-decrypt") + decryptedDataDir = filepath.Join(util.TempDir, "incremental", "backup-decrypt") if err = os.RemoveAll(decryptedDataDir); nil != err { return } diff --git a/kernel/model/conf.go b/kernel/model/conf.go index 987af968c..f698c40da 100644 --- a/kernel/model/conf.go +++ b/kernel/model/conf.go @@ -537,6 +537,7 @@ func clearWorkspaceTemp() { os.RemoveAll(filepath.Join(util.TempDir, "bazaar")) os.RemoveAll(filepath.Join(util.TempDir, "export")) os.RemoveAll(filepath.Join(util.TempDir, "import")) + os.RemoveAll(filepath.Join(util.WorkspaceDir, "incremental")) // `工作空间/incremental/` 文件夹移动到 `工作空间/temp/incremental/` https://github.com/siyuan-note/siyuan/issues/5119 tmps, err := filepath.Glob(filepath.Join(util.TempDir, "*.tmp")) if nil != err { diff --git a/kernel/model/sync.go b/kernel/model/sync.go index e70e1a598..892e0efab 100644 --- a/kernel/model/sync.go +++ b/kernel/model/sync.go @@ -663,7 +663,7 @@ func genCloudIndex(localDirPath string, excludes map[string]bool, calcHash bool) func recoverSyncData(metaPath, indexPath string, modified map[string]bool) (decryptedDataDir string, upsertFiles []string, err error) { passwd := Conf.E2EEPasswd - decryptedDataDir = filepath.Join(util.WorkspaceDir, "incremental", "sync-decrypt") + decryptedDataDir = filepath.Join(util.TempDir, "incremental", "sync-decrypt") if err = os.RemoveAll(decryptedDataDir); nil != err { return } @@ -772,7 +772,7 @@ func recoverSyncData(metaPath, indexPath string, modified map[string]bool) (decr } func prepareSyncData(passwd string, unchangedDataList map[string]bool) (encryptedDataDir string, upsertList map[string]bool, err error) { - encryptedDataDir = filepath.Join(util.WorkspaceDir, "incremental", "sync-encrypt") + encryptedDataDir = filepath.Join(util.TempDir, "incremental", "sync-encrypt") if err = os.RemoveAll(encryptedDataDir); nil != err { return } From b08910aacc42f86e2931c2a05b135c28192e1c3b Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 7 Jun 2022 18:59:25 +0800 Subject: [PATCH 3/4] :bug: Fix npe --- kernel/util/rhy.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/util/rhy.go b/kernel/util/rhy.go index a469411e0..1c29aad40 100644 --- a/kernel/util/rhy.go +++ b/kernel/util/rhy.go @@ -33,7 +33,7 @@ func GetRhyResult(force bool, proxyURL string) (map[string]interface{}, error) { defer rhyResultLock.Unlock() now := time.Now().Unix() - if 3600 >= now-rhyResultCacheTime && !force { + if 3600 >= now-rhyResultCacheTime && !force && 0 < len(cachedRhyResult) { return cachedRhyResult, nil } From 8b3f5594044d245d8a17c966926278657e2e89cb Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 7 Jun 2022 19:41:25 +0800 Subject: [PATCH 4/4] =?UTF-8?q?:bug:=20=E5=A4=9A=E7=BA=A7=E6=A0=87?= =?UTF-8?q?=E9=A2=98=E6=8A=98=E5=8F=A0=E5=90=8E=E4=B8=8A=E7=BA=A7=E5=9D=97?= =?UTF-8?q?=E5=BC=95=E6=B5=AE=E7=AA=97=E4=B8=AD=E6=9C=AA=E6=8A=98=E5=8F=A0?= =?UTF-8?q?=20Fix=20https://github.com/siyuan-note/siyuan/issues/4997?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/file.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/model/file.go b/kernel/model/file.go index b49465ea8..f191158c0 100644 --- a/kernel/model/file.go +++ b/kernel/model/file.go @@ -694,8 +694,9 @@ func loadNodesByMode(node *ast.Node, inputIndex, mode, size int, isDoc, isHeadin } else if isHeading { level := node.HeadingLevel for n := node.Next; nil != n; n = n.Next { - if "1" == n.IALAttr("heading-fold") && ("1" == node.IALAttr("fold") && 0 == mode) { - // 从大纲跳转折叠标题的下方标题时需要判断跳转的标题是否是折叠 https://github.com/siyuan-note/siyuan/issues/4920 + if "1" == n.IALAttr("heading-fold") { + // 大纲点击折叠标题跳转聚焦 https://github.com/siyuan-note/siyuan/issues/4920 + // 多级标题折叠后上级块引浮窗中未折叠 https://github.com/siyuan-note/siyuan/issues/4997 continue } if ast.NodeHeading == n.Type {