Update issue #163

Status: Fixed
There is now an error message and a helpful rollback message displayed if the database version does not fit.

git-svn-id: https://duplicati.googlecode.com/svn/trunk@557 59da171f-624f-0410-aa54-27559c288bec
This commit is contained in:
kenneth.skovhede@gmail.com
2010-10-23 09:09:14 +00:00
parent 739fa5ad1b
commit 97318e602a
3 changed files with 30 additions and 2 deletions
+5
View File
@@ -109,6 +109,7 @@ namespace Duplicati.GUI
//ea, from 1 to 8, by stepping 2->3->4->5->6->7->8
SortedDictionary<int, string> upgrades = new SortedDictionary<int, string>();
string prefix = typeof(DatabaseUpgrader).Namespace + "." + FOLDER_NAME + ".";
int maxversion = -1;
foreach (string s in asm.GetManifestResourceNames())
{
//The resource name will be "Duplicati.GUI.Database_schema.1.Sample upgrade.sql"
@@ -119,6 +120,7 @@ namespace Duplicati.GUI
{
string version = s.Substring(prefix.Length, s.IndexOf(".", prefix.Length + 1) - prefix.Length);
int fileversion = int.Parse(version);
maxversion = Math.Max(maxversion, fileversion);
if (fileversion > dbversion)
{
if (!upgrades.ContainsKey(fileversion))
@@ -132,6 +134,9 @@ namespace Duplicati.GUI
}
}
if (dbversion > maxversion)
throw new Exception(string.Format(Strings.DatabaseUpgrader.InvalidVersionError, dbversion, maxversion, System.IO.Path.GetDirectoryName(sourcefile)));
if (upgrades.Count > 0)
{
string backupfile = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(sourcefile), Strings.DatabaseUpgrader.BackupFilenamePrefix + " " + DateTime.Now.ToString("yyyyMMddhhmmss") + ".sqlite");
+17 -2
View File
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.3082
// Runtime Version:2.0.50727.4952
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -78,6 +78,19 @@ namespace Duplicati.GUI.Strings {
}
}
/// <summary>
/// Looks up a localized string similar to
///The database has version {0} but the largest supported version is {1}.
///
///This is likely caused by upgrading to a newer version and then downgrading.
///If this is the case, there is likely a backup file of the previous database version in the folder {2}..
/// </summary>
internal static string InvalidVersionError {
get {
return ResourceManager.GetString("InvalidVersionError", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Unknown table layout detected.
/// </summary>
@@ -88,7 +101,9 @@ namespace Duplicati.GUI.Strings {
}
/// <summary>
/// Looks up a localized string similar to Failed to execute SQL: {0}\nError: {1}\nDatabase is NOT upgraded..
/// Looks up a localized string similar to Failed to execute SQL: {0}
///Error: {1}
///Database is NOT upgraded..
/// </summary>
internal static string UpgradeFailure {
get {
@@ -125,6 +125,14 @@
<value>Unable to determine database format: {0}</value>
<comment>An error message that is displayed if an error occurs while determining database layout</comment>
</data>
<data name="InvalidVersionError" xml:space="preserve">
<value>
The database has version {0} but the largest supported version is {1}.
This is likely caused by upgrading to a newer version and then downgrading.
If this is the case, there is likely a backup file of the previous database version in the folder {2}.</value>
<comment>An error message that is displayed if the database version number does not match</comment>
</data>
<data name="TableLayoutError" xml:space="preserve">
<value>Unknown table layout detected</value>
<comment>An error message that is displayed when the layout of the database is unexpected</comment>