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