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:
parent
9aeb848d33
commit
ce64d696b9
|
@ -65,11 +65,28 @@ namespace SparkleLib {
|
|||
SparkleHelpers.DebugInfo ("Config", "Created \"" + icons_path + "\"");
|
||||
}
|
||||
|
||||
if (!File.Exists (FullPath))
|
||||
try {
|
||||
Load (FullPath);
|
||||
|
||||
} catch (FileNotFoundException) {
|
||||
CreateInitialConfig ();
|
||||
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void CreateInitialConfig ()
|
||||
|
|
Loading…
Reference in a new issue