Skip to content

Commit

Permalink
[core] more robust check of "status" file
Browse files Browse the repository at this point in the history
  • Loading branch information
servantftechnicolor authored and fabiencastan committed Dec 8, 2020
1 parent 25181b5 commit 358436d
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions meshroom/core/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,15 @@ def updateStatusFromCache(self):
self.statusFileLastModTime = -1
self.status.reset()
else:
with open(statusFile, 'r') as jsonFile:
statusData = json.load(jsonFile)
self.status.fromDict(statusData)
self.statusFileLastModTime = os.path.getmtime(statusFile)
try:
with open(statusFile, 'r') as jsonFile:
statusData = json.load(jsonFile)
self.status.fromDict(statusData)
self.statusFileLastModTime = os.path.getmtime(statusFile)
except Exception as e:
self.statusFileLastModTime = -1
self.status.reset()

if oldStatus != self.status.status:
self.statusChanged.emit()

Expand Down Expand Up @@ -314,8 +319,11 @@ def saveStatusFile(self):
data = self.status.toDict()
statusFilepath = self.statusFile
folder = os.path.dirname(statusFilepath)
if not os.path.exists(folder):
try:
os.makedirs(folder)
except Exception as e:
pass

statusFilepathWriting = getWritingFilepath(statusFilepath)
with open(statusFilepathWriting, 'w') as jsonFile:
json.dump(data, jsonFile, indent=4)
Expand Down

0 comments on commit 358436d

Please sign in to comment.