mirror of
https://github.com/WiiDatabase/nusdownloader.git
synced 2024-11-27 04:34:14 +01:00
Added FileNotFound checks to database loader
This commit is contained in:
parent
6ac6a30516
commit
778a44e31b
@ -34,6 +34,9 @@ namespace NUS_Downloader
|
|||||||
|
|
||||||
public void LoadDatabaseToStream(string databaseFile)
|
public void LoadDatabaseToStream(string databaseFile)
|
||||||
{
|
{
|
||||||
|
// Does it exist?
|
||||||
|
if (!File.Exists(databaseFile))
|
||||||
|
throw new FileNotFoundException("I couldn't find the database file!", "database.xml");
|
||||||
// Load database.xml into MemoryStream
|
// Load database.xml into MemoryStream
|
||||||
databaseString = File.ReadAllText(databaseFile);
|
databaseString = File.ReadAllText(databaseFile);
|
||||||
/*System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
|
/*System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
|
||||||
|
@ -1652,18 +1652,26 @@ namespace NUS_Downloader
|
|||||||
private void RetrieveNewDatabase_Completed(object sender, RunWorkerCompletedEventArgs e)
|
private void RetrieveNewDatabase_Completed(object sender, RunWorkerCompletedEventArgs e)
|
||||||
{
|
{
|
||||||
string database = e.Result.ToString();
|
string database = e.Result.ToString();
|
||||||
Database db = new Database();
|
try
|
||||||
db.LoadDatabaseToStream(Path.Combine(CURRENT_DIR, "database.xml"));
|
|
||||||
string currentversion = db.GetDatabaseVersion();
|
|
||||||
string onlineversion = Database.GetDatabaseVersion(database);
|
|
||||||
WriteStatus(" - Database successfully parsed!");
|
|
||||||
WriteStatus(" - Current Database Version: " + currentversion);
|
|
||||||
WriteStatus(" - Online Database Version: " + onlineversion);
|
|
||||||
|
|
||||||
if (currentversion == onlineversion)
|
|
||||||
{
|
{
|
||||||
WriteStatus(" - You have the latest database version!");
|
Database db = new Database();
|
||||||
return;
|
db.LoadDatabaseToStream(Path.Combine(CURRENT_DIR, "database.xml"));
|
||||||
|
string currentversion = db.GetDatabaseVersion();
|
||||||
|
string onlineversion = Database.GetDatabaseVersion(database);
|
||||||
|
WriteStatus(" - Database successfully parsed!");
|
||||||
|
WriteStatus(" - Current Database Version: " + currentversion);
|
||||||
|
WriteStatus(" - Online Database Version: " + onlineversion);
|
||||||
|
|
||||||
|
if (currentversion == onlineversion)
|
||||||
|
{
|
||||||
|
WriteStatus(" - You have the latest database version!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (FileNotFoundException)
|
||||||
|
{
|
||||||
|
WriteStatus(" - Database does not yet exist.");
|
||||||
|
WriteStatus(" - Online Database Version: " + Database.GetDatabaseVersion(database));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isCreation = false;
|
bool isCreation = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user