From aab3d88a7d3b75e28405314d34dcdf214891ffb2 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 28 Mar 2023 18:03:23 +0800 Subject: [PATCH 1/3] :art: Copyright version --- kernel/versioninfo.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/versioninfo.json b/kernel/versioninfo.json index 504f3f40c..b5bb075ca 100644 --- a/kernel/versioninfo.json +++ b/kernel/versioninfo.json @@ -12,7 +12,7 @@ "FileDescription": "SiYuan Kernel", "FileVersion": "", "InternalName": "", - "LegalCopyright": "© 2022 Yunnan Liandi Technology Co., Ltd.", + "LegalCopyright": "© 2023 Yunnan Liandi Technology Co., Ltd.", "LegalTrademarks": "", "OriginalFilename": "", "PrivateBuild": "", From d55af3966d247cf8678fba04f8645a3ba810ae9a Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 28 Mar 2023 18:48:40 +0800 Subject: [PATCH 2/3] =?UTF-8?q?:bug:=20Windows=20=E7=AB=AF=E9=83=A8?= =?UTF-8?q?=E5=88=86=E7=B3=BB=E7=BB=9F=E4=B8=8A=E5=86=85=E6=A0=B8=E5=B4=A9?= =?UTF-8?q?=E6=BA=83=20https://github.com/siyuan-note/siyuan/issues/7806?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/util/runtime.go | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/kernel/util/runtime.go b/kernel/util/runtime.go index 21e1058d1..7871b4752 100644 --- a/kernel/util/runtime.go +++ b/kernel/util/runtime.go @@ -303,17 +303,21 @@ func existAvailabilityStatus(workspaceAbsPath string) bool { // 改进 Windows 端第三方同步盘检测 https://github.com/siyuan-note/siyuan/issues/7777 defer logging.Recover() - ole.CoInitialize(0) - defer ole.CoUninitialize() - dataAbsPath := filepath.Join(workspaceAbsPath, "data") - dir, file := filepath.Split(dataAbsPath) - - if !gulu.File.IsExist(dataAbsPath) { - dataAbsPath = workspaceAbsPath + checkAbsPath := filepath.Join(workspaceAbsPath, "data") + if !gulu.File.IsExist(checkAbsPath) { + checkAbsPath = workspaceAbsPath + } + if !gulu.File.IsExist(checkAbsPath) { + logging.LogWarnf("check path [%s] not exist", checkAbsPath) return false } + logging.LogInfof("check workspace [%s] availability status", checkAbsPath) + + ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED) + defer ole.CoUninitialize() + dir, file := filepath.Split(checkAbsPath) unknown, err := oleutil.CreateObject("Shell.Application") if nil != err { logging.LogWarnf("create shell application failed: %s", err) @@ -339,6 +343,10 @@ func existAvailabilityStatus(workspaceAbsPath string) bool { return false } fileObj := result.ToIDispatch() + if nil == fileObj { + logging.LogWarnf("call shell [ParseName] file is nil [%s]", checkAbsPath) + return false + } result, err = oleutil.CallMethod(folderObj, "GetDetailsOf", fileObj, 303) if nil != err { @@ -357,7 +365,7 @@ func existAvailabilityStatus(workspaceAbsPath string) bool { if strings.Contains(status, "sync") || strings.Contains(status, "同步") || strings.Contains(status, "available on this device") || strings.Contains(status, "在此设备上可用") || strings.Contains(status, "available when online") || strings.Contains(status, "联机时可用") { - logging.LogErrorf("[%s] third party sync status [%s]", dataAbsPath, status) + logging.LogErrorf("[%s] third party sync status [%s]", checkAbsPath, status) return true } return false From 55076cc89c6ffa71cfb28ed30ea61b3227f2df4a Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 28 Mar 2023 19:04:49 +0800 Subject: [PATCH 3/3] =?UTF-8?q?:bug:=20Windows=20=E7=AB=AF=E9=83=A8?= =?UTF-8?q?=E5=88=86=E7=B3=BB=E7=BB=9F=E4=B8=8A=E5=86=85=E6=A0=B8=E5=B4=A9?= =?UTF-8?q?=E6=BA=83=20https://github.com/siyuan-note/siyuan/issues/7806?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/util/runtime.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/util/runtime.go b/kernel/util/runtime.go index 7871b4752..31c605435 100644 --- a/kernel/util/runtime.go +++ b/kernel/util/runtime.go @@ -315,7 +315,12 @@ func existAvailabilityStatus(workspaceAbsPath string) bool { logging.LogInfof("check workspace [%s] availability status", checkAbsPath) - ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED) + runtime.LockOSThread() + defer runtime.LockOSThread() + if err := ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED); nil != err { + logging.LogWarnf("initialize ole failed: %s", err) + return false + } defer ole.CoUninitialize() dir, file := filepath.Split(checkAbsPath) unknown, err := oleutil.CreateObject("Shell.Application")