diff --git a/Duplicati.sln b/Duplicati.sln index 553dae212..97647f9e2 100644 --- a/Duplicati.sln +++ b/Duplicati.sln @@ -55,6 +55,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Duplicati.CommandLine.Backe EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Duplicati.Library.Backend.GoogleDocs", "Duplicati\Library\Backend\GoogleDocs\Duplicati.Library.Backend.GoogleDocs.csproj", "{42C91180-11EB-4590-82EA-80FE9D4DEBEC}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Duplicati.Library.SQLiteHelper", "Duplicati\Library\SQLiteHelper\Duplicati.Library.SQLiteHelper.csproj", "{2C838169-B187-4B09-8768-1C24C2521C8D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -104,6 +106,12 @@ Global {2AF960C0-357D-4D44-A3D5-8B6E89DB0F11}.Release|Any CPU.Build.0 = Release|Any CPU {2AF960C0-357D-4D44-A3D5-8B6E89DB0F11}.Test|Any CPU.ActiveCfg = Debug|Any CPU {2AF960C0-357D-4D44-A3D5-8B6E89DB0F11}.Test|Any CPU.Build.0 = Debug|Any CPU + {2C838169-B187-4B09-8768-1C24C2521C8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2C838169-B187-4B09-8768-1C24C2521C8D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2C838169-B187-4B09-8768-1C24C2521C8D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2C838169-B187-4B09-8768-1C24C2521C8D}.Release|Any CPU.Build.0 = Release|Any CPU + {2C838169-B187-4B09-8768-1C24C2521C8D}.Test|Any CPU.ActiveCfg = Debug|Any CPU + {2C838169-B187-4B09-8768-1C24C2521C8D}.Test|Any CPU.Build.0 = Debug|Any CPU {33FD1D24-C28F-4C71-933F-98F1586EA76C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {33FD1D24-C28F-4C71-933F-98F1586EA76C}.Debug|Any CPU.Build.0 = Debug|Any CPU {33FD1D24-C28F-4C71-933F-98F1586EA76C}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/Duplicati/Library/Main/Database/LocalDatabase.cs b/Duplicati/Library/Main/Database/LocalDatabase.cs index 44ffb7ea2..dc858b3a9 100644 --- a/Duplicati/Library/Main/Database/LocalDatabase.cs +++ b/Duplicati/Library/Main/Database/LocalDatabase.cs @@ -36,11 +36,11 @@ namespace Duplicati.Library.Main.Database protected static System.Data.IDbConnection CreateConnection(string path) { path = System.IO.Path.GetFullPath(path); - var c = (System.Data.IDbConnection)Activator.CreateInstance(Duplicati.Library.Utility.SQLiteLoader.SQLiteConnectionType); + var c = (System.Data.IDbConnection)Activator.CreateInstance(Duplicati.Library.SQLiteHelper.SQLiteLoader.SQLiteConnectionType); if (!System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(path))) System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(path)); - Library.Utility.DatabaseUpgrader.UpgradeDatabase(c, path, typeof(LocalDatabase)); + Library.SQLiteHelper.DatabaseUpgrader.UpgradeDatabase(c, path, typeof(LocalDatabase)); return c; } diff --git a/Duplicati/Library/Main/Duplicati.Library.Main.csproj b/Duplicati/Library/Main/Duplicati.Library.Main.csproj index e146f0e6d..c2057504f 100644 --- a/Duplicati/Library/Main/Duplicati.Library.Main.csproj +++ b/Duplicati/Library/Main/Duplicati.Library.Main.csproj @@ -141,6 +141,10 @@ {D63E53E4-A458-4C2F-914D-92F715F58ACE} Duplicati.Library.Snapshots + + {2C838169-B187-4B09-8768-1C24C2521C8D} + Duplicati.Library.SQLiteHelper + diff --git a/Duplicati/Library/Main/Operation/CreateBugReportHandler.cs b/Duplicati/Library/Main/Operation/CreateBugReportHandler.cs index 3b0416267..3f9a26ee4 100644 --- a/Duplicati/Library/Main/Operation/CreateBugReportHandler.cs +++ b/Duplicati/Library/Main/Operation/CreateBugReportHandler.cs @@ -79,7 +79,7 @@ namespace Duplicati.Library.Main.Operation Type sqlite = null; string sqliteversion = ""; - try { sqlite = Duplicati.Library.Utility.SQLiteLoader.SQLiteConnectionType; } + try { sqlite = Duplicati.Library.SQLiteHelper.SQLiteLoader.SQLiteConnectionType; } catch { } if (sqlite != null) diff --git a/Duplicati/Library/Utility/DatabaseUpgrader.cs b/Duplicati/Library/SQLiteHelper/DatabaseUpgrader.cs similarity index 97% rename from Duplicati/Library/Utility/DatabaseUpgrader.cs rename to Duplicati/Library/SQLiteHelper/DatabaseUpgrader.cs index 0b6f9d70a..caa79b6e7 100644 --- a/Duplicati/Library/Utility/DatabaseUpgrader.cs +++ b/Duplicati/Library/SQLiteHelper/DatabaseUpgrader.cs @@ -22,7 +22,7 @@ using System.Collections.Generic; using System.Text; using System.Data; -namespace Duplicati.Library.Utility +namespace Duplicati.Library.SQLiteHelper { /// /// This class will read embedded files from the given folder. diff --git a/Duplicati/Library/SQLiteHelper/Duplicati.Library.SQLiteHelper.csproj b/Duplicati/Library/SQLiteHelper/Duplicati.Library.SQLiteHelper.csproj new file mode 100644 index 000000000..9bc706f67 --- /dev/null +++ b/Duplicati/Library/SQLiteHelper/Duplicati.Library.SQLiteHelper.csproj @@ -0,0 +1,78 @@ + + + + Debug + AnyCPU + 10.0.0 + 2.0 + {2C838169-B187-4B09-8768-1C24C2521C8D} + Library + Duplicati.Library.SQLiteHelper + SQLiteHelper + true + ..\..\GUI\Duplicati.GUI.TrayIcon\Duplicati.snk + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + false + + + full + true + bin\Release + prompt + 4 + false + + + + + + + + + + + DatabaseUpgrader.resx + + + + + + + + + + + SQLite\win64\System.Data.SQLite.dll + PreserveNewest + + + SQLite\win32\System.Data.SQLite.dll + PreserveNewest + + + SQLite\pinvoke\System.Data.SQLite.dll + PreserveNewest + + + + + + ResXFileCodeGenerator + DatabaseUpgrader.Designer.cs + + + + + {DE3E5D4C-51AB-4E5E-BEE8-E636CEBFBA65} + Duplicati.Library.Utility + + + \ No newline at end of file diff --git a/Duplicati/Library/SQLiteHelper/Properties/AssemblyInfo.cs b/Duplicati/Library/SQLiteHelper/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..eb6759c39 --- /dev/null +++ b/Duplicati/Library/SQLiteHelper/Properties/AssemblyInfo.cs @@ -0,0 +1,38 @@ +// Copyright (C) 2014, Kenneth Skovhede +// http://www.hexad.dk, opensource@hexad.dk +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. +[assembly: AssemblyTitle("SQLiteHelper")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. +[assembly: AssemblyVersion("1.0.*")] +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/Duplicati/Library/Utility/SQLiteLoader.cs b/Duplicati/Library/SQLiteHelper/SQLiteLoader.cs similarity index 97% rename from Duplicati/Library/Utility/SQLiteLoader.cs rename to Duplicati/Library/SQLiteHelper/SQLiteLoader.cs index 67684df62..91546fa00 100644 --- a/Duplicati/Library/Utility/SQLiteLoader.cs +++ b/Duplicati/Library/SQLiteHelper/SQLiteLoader.cs @@ -1,93 +1,93 @@ -#region Disclaimer / License -// Copyright (C) 2011, Kenneth Skovhede -// http://www.hexad.dk, opensource@hexad.dk -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -// -#endregion -using System; -using System.Collections.Generic; -using System.Text; - -namespace Duplicati.Library.Utility -{ - public static class SQLiteLoader - { - /// - /// A cached copy of the type - /// - private static Type m_type = null; - - /// - /// Returns the SQLiteCommand type for the current architecture - /// - public static Type SQLiteConnectionType - { - get - { - if (m_type == null) - { - string filename = "System.Data.SQLite.dll"; - string basePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "SQLite"); - - //Default is to use the pinvoke version which requires a native .dll/.so - string assemblyPath = System.IO.Path.Combine(basePath, "pinvoke"); - - if (!Duplicati.Library.Utility.Utility.IsMono) - { - //If we run with MS.Net we can use the mixed mode assemblies - if (Library.Utility.Utility.Is64BitProcess) - { - if (System.IO.File.Exists(System.IO.Path.Combine(System.IO.Path.Combine(basePath, "win64"), filename))) - assemblyPath = System.IO.Path.Combine(basePath, "win64"); - } - else - { - if (System.IO.File.Exists(System.IO.Path.Combine(System.IO.Path.Combine(basePath, "win32"), filename))) - assemblyPath = System.IO.Path.Combine(basePath, "win32"); - } - } else { - //On Mono, we try to find the Mono version of SQLite - - //This secrect commandline variable can be used to support older installations - if (System.Environment.GetEnvironmentVariable("DISABLE_MONO_DATA_SQLITE") == null) - { - try - { - Type t = System.Reflection.Assembly.Load("Mono.Data.Sqlite, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756").GetType("Mono.Data.Sqlite.SqliteConnection"); - if (t != null && t.GetInterface("System.Data.IDbConnection", false) != null) - { - Version v = new Version((string)t.GetProperty("SQLiteVersion").GetValue(null, null)); - if (v >= new Version(3, 6, 3)) - { - m_type = t; - return m_type; - } - } - - } catch (Exception ex){ - Console.WriteLine(string.Format("Failed to load Mono.Data.Sqlite.SqliteConnection, reverting to built-in.{0} Error message: {1}", Environment.NewLine, ex.ToString())); - } - } - } - - m_type = System.Reflection.Assembly.LoadFile(System.IO.Path.Combine(assemblyPath, filename)).GetType("System.Data.SQLite.SQLiteConnection"); - } - - return m_type; - } - } - } -} +#region Disclaimer / License +// Copyright (C) 2011, Kenneth Skovhede +// http://www.hexad.dk, opensource@hexad.dk +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// +#endregion +using System; +using System.Collections.Generic; +using System.Text; + +namespace Duplicati.Library.SQLiteHelper +{ + public static class SQLiteLoader + { + /// + /// A cached copy of the type + /// + private static Type m_type = null; + + /// + /// Returns the SQLiteCommand type for the current architecture + /// + public static Type SQLiteConnectionType + { + get + { + if (m_type == null) + { + string filename = "System.Data.SQLite.dll"; + string basePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "SQLite"); + + //Default is to use the pinvoke version which requires a native .dll/.so + string assemblyPath = System.IO.Path.Combine(basePath, "pinvoke"); + + if (!Duplicati.Library.Utility.Utility.IsMono) + { + //If we run with MS.Net we can use the mixed mode assemblies + if (Library.Utility.Utility.Is64BitProcess) + { + if (System.IO.File.Exists(System.IO.Path.Combine(System.IO.Path.Combine(basePath, "win64"), filename))) + assemblyPath = System.IO.Path.Combine(basePath, "win64"); + } + else + { + if (System.IO.File.Exists(System.IO.Path.Combine(System.IO.Path.Combine(basePath, "win32"), filename))) + assemblyPath = System.IO.Path.Combine(basePath, "win32"); + } + } else { + //On Mono, we try to find the Mono version of SQLite + + //This secrect commandline variable can be used to support older installations + if (System.Environment.GetEnvironmentVariable("DISABLE_MONO_DATA_SQLITE") == null) + { + try + { + Type t = System.Reflection.Assembly.Load("Mono.Data.Sqlite, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756").GetType("Mono.Data.Sqlite.SqliteConnection"); + if (t != null && t.GetInterface("System.Data.IDbConnection", false) != null) + { + Version v = new Version((string)t.GetProperty("SQLiteVersion").GetValue(null, null)); + if (v >= new Version(3, 6, 3)) + { + m_type = t; + return m_type; + } + } + + } catch (Exception ex){ + Console.WriteLine(string.Format("Failed to load Mono.Data.Sqlite.SqliteConnection, reverting to built-in.{0} Error message: {1}", Environment.NewLine, ex.ToString())); + } + } + } + + m_type = System.Reflection.Assembly.LoadFile(System.IO.Path.Combine(assemblyPath, filename)).GetType("System.Data.SQLite.SQLiteConnection"); + } + + return m_type; + } + } + } +} diff --git a/Duplicati/Library/Utility/Strings/DatabaseUpgrader.Designer.cs b/Duplicati/Library/SQLiteHelper/Strings/DatabaseUpgrader.Designer.cs similarity index 94% rename from Duplicati/Library/Utility/Strings/DatabaseUpgrader.Designer.cs rename to Duplicati/Library/SQLiteHelper/Strings/DatabaseUpgrader.Designer.cs index b65fa7d47..b14632cdc 100644 --- a/Duplicati/Library/Utility/Strings/DatabaseUpgrader.Designer.cs +++ b/Duplicati/Library/SQLiteHelper/Strings/DatabaseUpgrader.Designer.cs @@ -8,7 +8,7 @@ // // ------------------------------------------------------------------------------ -namespace Duplicati.Library.Utility.Strings { +namespace Duplicati.Library.SQLiteHelper.Strings { using System; @@ -29,7 +29,7 @@ namespace Duplicati.Library.Utility.Strings { internal static System.Resources.ResourceManager ResourceManager { get { if (object.Equals(null, resourceMan)) { - System.Resources.ResourceManager temp = new System.Resources.ResourceManager("Duplicati.Library.Utility.Strings.DatabaseUpgrader", typeof(DatabaseUpgrader).Assembly); + System.Resources.ResourceManager temp = new System.Resources.ResourceManager("Duplicati.Library.SQLiteHelper.Strings.DatabaseUpgrader", typeof(DatabaseUpgrader).Assembly); resourceMan = temp; } return resourceMan; diff --git a/Duplicati/Library/Utility/Strings/DatabaseUpgrader.resx b/Duplicati/Library/SQLiteHelper/Strings/DatabaseUpgrader.resx similarity index 100% rename from Duplicati/Library/Utility/Strings/DatabaseUpgrader.resx rename to Duplicati/Library/SQLiteHelper/Strings/DatabaseUpgrader.resx diff --git a/Duplicati/Library/Utility/Duplicati.Library.Utility.csproj b/Duplicati/Library/Utility/Duplicati.Library.Utility.csproj index 127fada82..dc3d1e494 100644 --- a/Duplicati/Library/Utility/Duplicati.Library.Utility.csproj +++ b/Duplicati/Library/Utility/Duplicati.Library.Utility.csproj @@ -90,11 +90,6 @@ - - - - DatabaseUpgrader.resx - Uri.resx @@ -142,10 +137,6 @@ ResXFileCodeGenerator Uri.Designer.cs - - ResXFileCodeGenerator - DatabaseUpgrader.Designer.cs - - - - - - - - - - SQLite\win64\System.Data.SQLite.dll - PreserveNewest - - - SQLite\win32\System.Data.SQLite.dll - PreserveNewest - - - SQLite\pinvoke\System.Data.SQLite.dll - PreserveNewest - - \ No newline at end of file diff --git a/Duplicati/Server/Duplicati.Server.csproj b/Duplicati/Server/Duplicati.Server.csproj index df3e8efd0..d76976ddc 100644 --- a/Duplicati/Server/Duplicati.Server.csproj +++ b/Duplicati/Server/Duplicati.Server.csproj @@ -204,6 +204,10 @@ {D63E53E4-A458-4C2F-914D-92F715F58ACE} Duplicati.Library.Snapshots + + {2C838169-B187-4B09-8768-1C24C2521C8D} + Duplicati.Library.SQLiteHelper + diff --git a/Duplicati/Server/Program.cs b/Duplicati/Server/Program.cs index d988d93a2..e180bd16e 100644 --- a/Duplicati/Server/Program.cs +++ b/Duplicati/Server/Program.cs @@ -267,7 +267,7 @@ namespace Duplicati.Server Duplicati.Library.Logging.Log.CurrentLog = new Duplicati.Library.Logging.StreamLog(commandlineOptions["log-file"]); } - Version sqliteVersion = new Version((string)Duplicati.Library.Utility.SQLiteLoader.SQLiteConnectionType.GetProperty("SQLiteVersion").GetValue(null, null)); + Version sqliteVersion = new Version((string)Duplicati.Library.SQLiteHelper.SQLiteLoader.SQLiteConnectionType.GetProperty("SQLiteVersion").GetValue(null, null)); if (sqliteVersion < new Version(3, 6, 3)) { if (writeConsole) @@ -283,7 +283,7 @@ namespace Duplicati.Server } //Create the connection instance - System.Data.IDbConnection con = (System.Data.IDbConnection)Activator.CreateInstance(Duplicati.Library.Utility.SQLiteLoader.SQLiteConnectionType); + System.Data.IDbConnection con = (System.Data.IDbConnection)Activator.CreateInstance(Duplicati.Library.SQLiteHelper.SQLiteLoader.SQLiteConnectionType); try { @@ -302,7 +302,7 @@ namespace Duplicati.Server //Attempt to open the database, handling any encryption present OpenDatabase(con); - Duplicati.Library.Utility.DatabaseUpgrader.UpgradeDatabase(con, DatabasePath, typeof(Duplicati.Server.Database.Connection)); + Duplicati.Library.SQLiteHelper.DatabaseUpgrader.UpgradeDatabase(con, DatabasePath, typeof(Duplicati.Server.Database.Connection)); } catch (Exception ex) { diff --git a/Duplicati/Server/WebServer.cs b/Duplicati/Server/WebServer.cs index 25e4c61fd..be38e4f3f 100644 --- a/Duplicati/Server/WebServer.cs +++ b/Duplicati/Server/WebServer.cs @@ -399,7 +399,7 @@ namespace Duplicati.Server return; } - using(var con = (System.Data.IDbConnection)Activator.CreateInstance(Duplicati.Library.Utility.SQLiteLoader.SQLiteConnectionType)) + using(var con = (System.Data.IDbConnection)Activator.CreateInstance(Duplicati.Library.SQLiteHelper.SQLiteLoader.SQLiteConnectionType)) { con.ConnectionString = "Data Source=" + backup.DBPath; con.Open();