🎨 使用第三方同步盘时弹出提示并退出内核 https://github.com/siyuan-note/siyuan/issues/7683

This commit is contained in:
Liang Ding 2023-03-16 23:17:07 +08:00
parent f63d09fa1a
commit 042daa73e5
No known key found for this signature in database
GPG key ID: 136F30F901A2231D

View file

@ -147,7 +147,7 @@ func CheckFileSysStatus() {
os.Exit(ExitCodeFileSysInconsistent) os.Exit(ExitCodeFileSysInconsistent)
} }
const fileSysStatusCheckFile = "filesys_status_check" const fileSysStatusCheckFile = ".siyuan/filesys_status_check"
for { for {
workspaceDirLower := strings.ToLower(WorkspaceDir) workspaceDirLower := strings.ToLower(WorkspaceDir)
@ -168,7 +168,7 @@ func CheckFileSysStatus() {
continue continue
} }
for i := 0; i < 16; i++ { for i := 0; i < 32; i++ {
tmp := filepath.Join(dir, "check_"+gulu.Rand.String(7)) tmp := filepath.Join(dir, "check_"+gulu.Rand.String(7))
data := make([]byte, 1024*4) data := make([]byte, 1024*4)
_, err := rand.Read(data) _, err := rand.Read(data)
@ -184,7 +184,7 @@ func CheckFileSysStatus() {
time.Sleep(time.Second) time.Sleep(time.Second)
for j := 0; j < 64; j++ { for j := 0; j < 32; j++ {
f, err := os.Open(tmp) f, err := os.Open(tmp)
if nil != err { if nil != err {
reportFileSysFatalError(err) reportFileSysFatalError(err)
@ -196,19 +196,18 @@ func CheckFileSysStatus() {
break break
} }
time.Sleep(100 * time.Millisecond) time.Sleep(200 * time.Millisecond)
if err = os.Rename(tmp, tmp+"_1"); nil != err { if err = os.Rename(tmp, tmp+"_1"); nil != err {
reportFileSysFatalError(err) reportFileSysFatalError(err)
break break
} }
time.Sleep(100 * time.Millisecond) time.Sleep(200 * time.Millisecond)
if err = os.Rename(tmp+"_1", tmp); nil != err { if err = os.Rename(tmp+"_1", tmp); nil != err {
reportFileSysFatalError(err) reportFileSysFatalError(err)
break break
} }
}
entries, err := os.ReadDir(dir) entries, err := os.ReadDir(dir)
if nil != err { if nil != err {
@ -226,6 +225,7 @@ func CheckFileSysStatus() {
reportFileSysFatalError(fmt.Errorf("dir [%s] has more than 1 file", dir)) reportFileSysFatalError(fmt.Errorf("dir [%s] has more than 1 file", dir))
break break
} }
}
if err = os.RemoveAll(tmp); nil != err { if err = os.RemoveAll(tmp); nil != err {
reportFileSysFatalError(err) reportFileSysFatalError(err)