🐛 The corrupted data causes the kernel to hang https://github.com/siyuan-note/siyuan/issues/12852

This commit is contained in:
Daniel 2024-10-20 21:45:04 +08:00
parent 62a8117ba7
commit a94b333f09
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -118,14 +118,12 @@ func (box *Box) docIAL(p string) (ret map[string]string) {
filePath := filepath.Join(util.DataDir, box.ID, p)
filelock.Lock(filePath)
defer filelock.Unlock(filePath)
file, err := os.Open(filePath)
if err != nil {
logging.LogErrorf("open file [%s] failed: %s", p, err)
filelock.Unlock(filePath)
return nil
}
defer file.Close()
iter := jsoniter.Parse(jsoniter.ConfigCompatibleWithStandardLibrary, file, 512)
for field := iter.ReadObject(); field != ""; field = iter.ReadObject() {
@ -136,6 +134,8 @@ func (box *Box) docIAL(p string) (ret map[string]string) {
iter.Skip()
}
}
file.Close()
filelock.Unlock(filePath)
if 1 > len(ret) {
logging.LogWarnf("properties not found in file [%s]", p)