Create a new config.xml if it exists but is empty. Throw an error if the format is invalid. Fixes #315

This commit is contained in:
Hylke Bons 2011-08-26 23:50:50 +02:00
parent 79f3473467
commit 3a571c7baf

View file

@ -65,10 +65,27 @@ namespace SparkleLib {
SparkleHelpers.DebugInfo ("Config", "Created \"" + icons_path + "\"");
}
if (!File.Exists (FullPath))
try {
Load (FullPath);
} catch (FileNotFoundException) {
CreateInitialConfig ();
Load (FullPath);
} catch (XmlException) {
FileInfo file = new FileInfo (FullPath);
if (file.Length == 0) {
File.Delete (FullPath);
CreateInitialConfig ();
} else {
throw new XmlException (FullPath + " does not contain a valid SparkleShare XML tree.");
}
} finally {
Load (FullPath);
}
}