File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed
Source/NETworkManager.Settings Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -68,12 +68,22 @@ public static void Load()
6868 Log . Info ( $ "Loading system-wide policies from: { filePath } ") ;
6969
7070 var jsonString = File . ReadAllText ( filePath ) ;
71- Current = JsonSerializer . Deserialize < PolicyInfo > ( jsonString , JsonOptions ) ;
71+
72+ // Treat empty or JSON "null" as "no policies" instead of crashing
73+ if ( string . IsNullOrWhiteSpace ( jsonString ) )
74+ {
75+ Current = new PolicyInfo ( ) ;
76+ Log . Info ( "Config file is empty, no system-wide policies loaded." ) ;
77+ }
78+ else
79+ {
80+ Current = JsonSerializer . Deserialize < PolicyInfo > ( jsonString , JsonOptions ) ?? new PolicyInfo ( ) ;
81+
82+ Log . Info ( "System-wide policies loaded successfully." ) ;
7283
73- Log . Info ( "System-wide policies loaded successfully." ) ;
74-
75- // Log enabled settings
76- Log . Info ( $ "System-wide policy - Update_CheckForUpdatesAtStartup: { Current . Update_CheckForUpdatesAtStartup ? . ToString ( ) ?? "Not set" } ") ;
84+ // Log enabled settings
85+ Log . Info ( $ "System-wide policy - Update_CheckForUpdatesAtStartup: { Current . Update_CheckForUpdatesAtStartup ? . ToString ( ) ?? "Not set" } ") ;
86+ }
7787 }
7888 catch ( Exception ex )
7989 {
You can’t perform that action at this time.
0 commit comments