mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-04-24 03:50:14 +10:00
global_settings.py: Add handling for corrupted config files
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
# OpenCore Legacy Patcher changelog
|
# OpenCore Legacy Patcher changelog
|
||||||
|
|
||||||
## 1.1.0
|
## 1.1.0
|
||||||
|
- Add error handling for corrupted patcher settings
|
||||||
|
|
||||||
## 1.0.0
|
## 1.0.0
|
||||||
- Resolve BCM2046 and BCM2070 support on macOS 13.3 and newer
|
- Resolve BCM2046 and BCM2070 support on macOS 13.3 and newer
|
||||||
|
|||||||
@@ -31,7 +31,12 @@ class GlobalEnviromentSettings:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if Path(self.global_settings_plist).exists():
|
if Path(self.global_settings_plist).exists():
|
||||||
plist = plistlib.load(Path(self.global_settings_plist).open("rb"))
|
try:
|
||||||
|
plist = plistlib.load(Path(self.global_settings_plist).open("rb"))
|
||||||
|
except Exception as e:
|
||||||
|
logging.error("Error: Unable to read global settings file")
|
||||||
|
logging.error(e)
|
||||||
|
return None
|
||||||
if property_name in plist:
|
if property_name in plist:
|
||||||
return plist[property_name]
|
return plist[property_name]
|
||||||
return None
|
return None
|
||||||
@@ -43,7 +48,12 @@ class GlobalEnviromentSettings:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if Path(self.global_settings_plist).exists():
|
if Path(self.global_settings_plist).exists():
|
||||||
plist = plistlib.load(Path(self.global_settings_plist).open("rb"))
|
try:
|
||||||
|
plist = plistlib.load(Path(self.global_settings_plist).open("rb"))
|
||||||
|
except Exception as e:
|
||||||
|
logging.error("Error: Unable to read global settings file")
|
||||||
|
logging.error(e)
|
||||||
|
return
|
||||||
plist[property_name] = property_value
|
plist[property_name] = property_value
|
||||||
try:
|
try:
|
||||||
plistlib.dump(plist, Path(self.global_settings_plist).open("wb"))
|
plistlib.dump(plist, Path(self.global_settings_plist).open("wb"))
|
||||||
@@ -69,9 +79,14 @@ class GlobalEnviromentSettings:
|
|||||||
defaults_path = Path(defaults_path).expanduser()
|
defaults_path = Path(defaults_path).expanduser()
|
||||||
|
|
||||||
if Path(defaults_path).exists():
|
if Path(defaults_path).exists():
|
||||||
defaults_plist = plistlib.load(Path(defaults_path).open("rb"))
|
|
||||||
# merge defaults with global settings
|
# merge defaults with global settings
|
||||||
global_settings_plist = plistlib.load(Path(self.global_settings_plist).open("rb"))
|
try:
|
||||||
|
defaults_plist = plistlib.load(Path(defaults_path).open("rb"))
|
||||||
|
global_settings_plist = plistlib.load(Path(self.global_settings_plist).open("rb"))
|
||||||
|
except Exception as e:
|
||||||
|
logging.error("Error: Unable to read global settings file")
|
||||||
|
logging.error(e)
|
||||||
|
return
|
||||||
global_settings_plist.update(defaults_plist)
|
global_settings_plist.update(defaults_plist)
|
||||||
try:
|
try:
|
||||||
plistlib.dump(global_settings_plist, Path(self.global_settings_plist).open("wb"))
|
plistlib.dump(global_settings_plist, Path(self.global_settings_plist).open("wb"))
|
||||||
|
|||||||
Reference in New Issue
Block a user