diff --git a/SoObjects/SOGo/SOGoSystemDefaults.m b/SoObjects/SOGo/SOGoSystemDefaults.m index 67101044f..3393c57f0 100644 --- a/SoObjects/SOGo/SOGoSystemDefaults.m +++ b/SoObjects/SOGo/SOGoSystemDefaults.m @@ -87,20 +87,40 @@ static void _injectConfigurationFromFile (NSUserDefaults *ud, NSString *filename, NSObject *logger) { + NSDictionary *newConfig,*fileAttrs; + NSError *fmError = nil; NSFileManager *fm; - NSDictionary *newConfig; fm = [NSFileManager defaultManager]; if ([fm fileExistsAtPath: filename]) { - newConfig = [NSDictionary dictionaryWithContentsOfFile: filename]; - if (newConfig) - [ud registerDefaults: newConfig]; + fileAttrs = [fm attributesOfItemAtPath: filename + error: &fmError]; + if (![fileAttrs objectForKey: @"NSFileSize"]) + { + [logger errorWithFormat: + @"Can't get file attributes from '%@': %@", + filename, [fmError description]]; + exit(1); + } + if ([[fileAttrs objectForKey: @"NSFileSize"] intValue] == 0 ) + { + [logger warnWithFormat: + @"Empty file: '%@'. Skipping", + filename]; + } else { - [logger errorWithFormat: @"Cannot read configuration from '%@'.", - filename]; - exit (1); + newConfig = [NSDictionary dictionaryWithContentsOfFile: filename]; + if (newConfig) + [ud registerDefaults: newConfig]; + else + { + [logger errorWithFormat: + @"Cannot read configuration from '%@'. Aborting", + filename]; + exit(1); + } } } }