Skip to content

Commit

Permalink
[python] handle storage Sync issues properly (#17939)
Browse files Browse the repository at this point in the history
* [python] handle storage Sync issues properly

The variable "path" doesn't exist when handling this exception. Use
self._file and return after reporting the error to avoid further
exceptions.

* Update src/controller/python/chip/storage/__init__.py

Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>

Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
  • Loading branch information
2 people authored and pull[bot] committed Jun 2, 2022
1 parent cb2da5b commit 1467828
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/controller/python/chip/storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ def Sync(self):
self._file = open(self._path, 'w')
except Exception as ex:
logging.warn(
f"Could not open {path} for writing configuration. Error:")
f"Could not open {self._path} for writing configuration. Error:")
logging.warn(ex)
return

self._file.seek(0)
json.dump(self.jsonData, self._file, ensure_ascii=True, indent=4)
Expand Down

0 comments on commit 1467828

Please sign in to comment.