diff --git a/Duplicati.Library.RestAPI/Database/Backup.cs b/Duplicati.Library.RestAPI/Database/Backup.cs index 117253942..c71a8bda9 100644 --- a/Duplicati.Library.RestAPI/Database/Backup.cs +++ b/Duplicati.Library.RestAPI/Database/Backup.cs @@ -1,20 +1,24 @@ -// Copyright (C) 2015, The Duplicati Team +// Copyright (C) 2024, The Duplicati Team +// https://duplicati.com, hello@duplicati.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. -// http://www.duplicati.com, info@duplicati.com -// -// 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; using Duplicati.Server.Serialization.Interface; using System.Collections.Generic; @@ -46,7 +50,7 @@ namespace Duplicati.Server.Database { this.ID = null; } - + internal void LoadChildren(Connection con) { if (this.IsTemporary) @@ -65,7 +69,7 @@ namespace Duplicati.Server.Database this.Metadata = con.GetMetadata(id); } } - + /// /// The backup ID /// @@ -90,27 +94,27 @@ namespace Duplicati.Server.Database /// The path to the local database /// public string DBPath { get; internal set; } - + /// /// The backup source folders and files /// public string[] Sources { get; set; } - + /// /// The backup settings /// public ISetting[] Settings { get; set; } - + /// /// The filters applied to the source files /// public IFilter[] Filters { get; set; } - + /// /// The backup metadata /// - public IDictionary Metadata { get; set; } - + public IDictionary Metadata { get; set; } + /// /// Gets a value indicating if this instance is not persisted to the database /// diff --git a/Duplicati.Library.RestAPI/Database/Connection.cs b/Duplicati.Library.RestAPI/Database/Connection.cs index fc47340ef..080b345b0 100644 --- a/Duplicati.Library.RestAPI/Database/Connection.cs +++ b/Duplicati.Library.RestAPI/Database/Connection.cs @@ -1,20 +1,24 @@ -// Copyright (C) 2015, The Duplicati Team +// Copyright (C) 2024, The Duplicati Team +// https://duplicati.com, hello@duplicati.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. -// http://www.duplicati.com, info@duplicati.com -// -// 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; using System.Collections.Generic; using System.Linq; @@ -38,15 +42,15 @@ namespace Duplicati.Server.Database m_connection = connection; m_errorcmd = m_connection.CreateCommand(); m_errorcmd.CommandText = @"INSERT INTO ""ErrorLog"" (""BackupID"", ""Message"", ""Exception"", ""Timestamp"") VALUES (?,?,?,?)"; - for(var i = 0; i < 4; i++) + for (var i = 0; i < 4; i++) m_errorcmd.Parameters.Add(m_errorcmd.CreateParameter()); - + this.ApplicationSettings = new ServerSettings(this); } - + public void LogError(string backupid, string message, Exception ex) { - lock(m_lock) + lock (m_lock) { if (!long.TryParse(backupid, out long id)) id = -1; @@ -57,49 +61,50 @@ namespace Duplicati.Server.Database m_errorcmd.ExecuteNonQuery(); } } - + internal void ExecuteWithCommand(Action f) { - lock(m_lock) - using(var cmd = m_connection.CreateCommand()) + lock (m_lock) + using (var cmd = m_connection.CreateCommand()) f(cmd); } internal Serializable.ImportExportStructure PrepareBackupForExport(IBackup backup) { var scheduleId = GetScheduleIDsFromTags(new string[] { "ID=" + backup.ID }); - return new Serializable.ImportExportStructure() { - CreatedByVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(), - Backup = (Database.Backup)backup, - Schedule = (Database.Schedule)(scheduleId.Any() ? GetSchedule(scheduleId.First()) : null), - DisplayNames = SpecialFolders.GetSourceNames(backup) - }; + return new Serializable.ImportExportStructure() + { + CreatedByVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(), + Backup = (Database.Backup)backup, + Schedule = (Database.Schedule)(scheduleId.Any() ? GetSchedule(scheduleId.First()) : null), + DisplayNames = SpecialFolders.GetSourceNames(backup) + }; } - + public string RegisterTemporaryBackup(IBackup backup) { - lock(m_lock) + lock (m_lock) { if (backup == null) throw new ArgumentNullException(nameof(backup)); if (backup.ID != null) throw new ArgumentException("Backup is already active, cannot make temporary"); - + backup.ID = Guid.NewGuid().ToString("D"); m_temporaryBackups.Add(backup.ID, (Backup)backup); return backup.ID; } } - + public void UnregisterTemporaryBackup(IBackup backup) { - lock(m_lock) + lock (m_lock) m_temporaryBackups.Remove(backup.ID); } public void UpdateTemporaryBackup(IBackup backup) { - lock(m_lock) + lock (m_lock) if (m_temporaryBackups.Remove(backup.ID)) m_temporaryBackups.Add(backup.ID, (Backup)backup); } @@ -108,8 +113,8 @@ namespace Duplicati.Server.Database { if (string.IsNullOrEmpty(id)) return null; - - lock(m_lock) + + lock (m_lock) { Backup b; m_temporaryBackups.TryGetValue(id, out b); @@ -118,10 +123,10 @@ namespace Duplicati.Server.Database } public ServerSettings ApplicationSettings { get; private set; } - + internal IDictionary GetMetadata(long id) { - lock(m_lock) + lock (m_lock) return ReadFromDb( (rd) => new KeyValuePair( ConvertToString(rd, 0), @@ -130,11 +135,11 @@ namespace Duplicati.Server.Database @"SELECT ""Name"", ""Value"" FROM ""Metadata"" WHERE ""BackupID"" = ? ", id) .ToDictionary((k) => k.Key, (k) => k.Value); } - + internal void SetMetadata(IDictionary values, long id, System.Data.IDbTransaction transaction) { - lock(m_lock) - using(var tr = transaction == null ? m_connection.BeginTransaction() : null) + lock (m_lock) + using (var tr = transaction == null ? m_connection.BeginTransaction() : null) { OverwriteAndUpdateDb( tr, @@ -143,29 +148,30 @@ namespace Duplicati.Server.Database @"INSERT INTO ""Metadata"" (""BackupID"", ""Name"", ""Value"") VALUES (?, ?, ?)", (f) => new object[] { id, f.Key, f.Value } ); - + if (tr != null) tr.Commit(); } } - + internal IFilter[] GetFilters(long id) { - lock(m_lock) + lock (m_lock) return ReadFromDb( - (rd) => (IFilter)new Filter() { - Order = ConvertToInt64(rd, 0), + (rd) => (IFilter)new Filter() + { + Order = ConvertToInt64(rd, 0), Include = ConvertToBoolean(rd, 1), Expression = ConvertToString(rd, 2) ?? "" }, @"SELECT ""Order"", ""Include"", ""Expression"" FROM ""Filter"" WHERE ""BackupID"" = ? ORDER BY ""Order"" ", id) .ToArray(); } - + internal void SetFilters(IEnumerable values, long id, System.Data.IDbTransaction transaction = null) { - lock(m_lock) - using(var tr = transaction == null ? m_connection.BeginTransaction() : null) + lock (m_lock) + using (var tr = transaction == null ? m_connection.BeginTransaction() : null) { OverwriteAndUpdateDb( tr, @@ -174,7 +180,7 @@ namespace Duplicati.Server.Database @"INSERT INTO ""Filter"" (""BackupID"", ""Order"", ""Include"", ""Expression"") VALUES (?, ?, ?, ?)", (f) => new object[] { id, f.Order, f.Include, f.Expression } ); - + if (tr != null) tr.Commit(); } @@ -182,9 +188,10 @@ namespace Duplicati.Server.Database public ISetting[] GetSettings(long id) { - lock(m_lock) + lock (m_lock) return ReadFromDb( - (rd) => (ISetting)new Setting() { + (rd) => (ISetting)new Setting() + { Filter = ConvertToString(rd, 0) ?? "", Name = ConvertToString(rd, 1) ?? "", Value = ConvertToString(rd, 2) ?? "" @@ -193,42 +200,43 @@ namespace Duplicati.Server.Database @"SELECT ""Filter"", ""Name"", ""Value"" FROM ""Option"" WHERE ""BackupID"" = ?", id) .ToArray(); } - + internal void SetSettings(IEnumerable values, long id, System.Data.IDbTransaction transaction = null) { - lock(m_lock) - using(var tr = transaction == null ? m_connection.BeginTransaction() : null) + lock (m_lock) + using (var tr = transaction == null ? m_connection.BeginTransaction() : null) { OverwriteAndUpdateDb( tr, @"DELETE FROM ""Option"" WHERE ""BackupID"" = ?", new object[] { id }, values, @"INSERT INTO ""Option"" (""BackupID"", ""Filter"", ""Name"", ""Value"") VALUES (?, ?, ?, ?)", - (f) => { + (f) => + { if (Duplicati.Server.WebServer.Server.PASSWORD_PLACEHOLDER.Equals(f.Value)) throw new Exception("Attempted to save a property with the placeholder password"); return new object[] { id, f.Filter ?? "", f.Name, f.Value ?? "" }; } - ); - + ); + if (tr != null) tr.Commit(); } } - + internal string[] GetSources(long id) { - lock(m_lock) + lock (m_lock) return ReadFromDb( (rd) => ConvertToString(rd, 0), @"SELECT ""Path"" FROM ""Source"" WHERE ""BackupID"" = ?", id) .ToArray(); } - + internal void SetSources(IEnumerable values, long id, System.Data.IDbTransaction transaction) { - lock(m_lock) - using(var tr = transaction == null ? m_connection.BeginTransaction() : null) + lock (m_lock) + using (var tr = transaction == null ? m_connection.BeginTransaction() : null) { OverwriteAndUpdateDb( tr, @@ -236,8 +244,8 @@ namespace Duplicati.Server.Database values, @"INSERT INTO ""Source"" (""BackupID"", ""Path"") VALUES (?, ?)", (f) => new object[] { id, f } - ); - + ); + if (tr != null) tr.Commit(); } @@ -247,16 +255,16 @@ namespace Duplicati.Server.Database { if (tags == null || tags.Length == 0) return new long[0]; - + if (tags.Length == 1 && tags[0].StartsWith("ID=", StringComparison.Ordinal)) return new long[] { long.Parse(tags[0].Substring("ID=".Length)) }; - - lock(m_lock) - using(var cmd = m_connection.CreateCommand()) + + lock (m_lock) + using (var cmd = m_connection.CreateCommand()) { var sb = new StringBuilder(); - - foreach(var t in tags) + + foreach (var t in tags) { if (sb.Length != 0) sb.Append(" OR "); @@ -268,7 +276,7 @@ namespace Duplicati.Server.Database } cmd.CommandText = @"SELECT ""ID"" FROM ""Backup"" WHERE " + sb; - + return Read(cmd, (rd) => ConvertToInt64(rd, 0)).ToArray(); } } @@ -283,10 +291,11 @@ namespace Duplicati.Server.Database internal IBackup GetBackup(long id) { - lock(m_lock) + lock (m_lock) { var bk = ReadFromDb( - (rd) => new Backup { + (rd) => new Backup + { ID = ConvertToInt64(rd, 0).ToString(), Name = ConvertToString(rd, 1), Description = ConvertToString(rd, 2), @@ -296,20 +305,21 @@ namespace Duplicati.Server.Database }, @"SELECT ""ID"", ""Name"", ""Description"", ""Tags"", ""TargetURL"", ""DBPath"" FROM ""Backup"" WHERE ID = ?", id) .FirstOrDefault(); - + if (bk != null) bk.LoadChildren(this); - + return bk; } } - + internal ISchedule GetSchedule(long id) { - lock(m_lock) + lock (m_lock) { var bk = ReadFromDb( - (rd) => new Schedule { + (rd) => new Schedule + { ID = ConvertToInt64(rd, 0), Tags = (ConvertToString(rd, 1) ?? "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), Time = ConvertToDateTime(rd, 2), @@ -349,13 +359,13 @@ namespace Duplicati.Server.Database { if (tags == null || tags.Length == 0) return new long[0]; - - lock(m_lock) - using(var cmd = m_connection.CreateCommand()) + + lock (m_lock) + using (var cmd = m_connection.CreateCommand()) { var sb = new StringBuilder(); - - foreach(var t in tags) + + foreach (var t in tags) { if (sb.Length != 0) sb.Append(" OR "); @@ -367,7 +377,7 @@ namespace Duplicati.Server.Database } cmd.CommandText = @"SELECT ""ID"" FROM ""Schedule"" WHERE " + sb; - + return Read(cmd, (rd) => ConvertToInt64(rd, 0)).ToArray(); } } @@ -387,7 +397,7 @@ namespace Duplicati.Server.Database if (item.Sources == null || item.Sources.Any(x => string.IsNullOrWhiteSpace(x)) || item.Sources.Length == 0) return "Invalid source list"; - + var disabled_encryption = false; var passphrase = string.Empty; var gpgAsymmetricEncryption = false; @@ -449,7 +459,8 @@ namespace Duplicati.Server.Database if (!string.IsNullOrWhiteSpace(s.Value) && s.Value.Contains("-")) return "The prefix cannot contain hyphens (-)"; } - else if (string.Equals(s.Name, "--gpg-encryption-command", StringComparison.OrdinalIgnoreCase)) { + else if (string.Equals(s.Name, "--gpg-encryption-command", StringComparison.OrdinalIgnoreCase)) + { gpgAsymmetricEncryption = string.Equals(s.Value, "--encrypt", StringComparison.OrdinalIgnoreCase); } } @@ -485,9 +496,9 @@ namespace Duplicati.Server.Database { cmd.Transaction = tr; cmd.Parameters.Add(cmd.CreateParameter()); - ((System.Data.IDbDataParameter) cmd.Parameters[0]).Value = path; + ((System.Data.IDbDataParameter)cmd.Parameters[0]).Value = path; cmd.Parameters.Add(cmd.CreateParameter()); - ((System.Data.IDbDataParameter) cmd.Parameters[1]).Value = item.ID; + ((System.Data.IDbDataParameter)cmd.Parameters[1]).Value = item.ID; cmd.CommandText = @"UPDATE ""Backup"" SET ""DBPath""=? WHERE ""ID""=?"; cmd.ExecuteNonQuery(); @@ -502,7 +513,7 @@ namespace Duplicati.Server.Database private void AddOrUpdateBackup(IBackup item, bool updateSchedule, ISchedule schedule) { - lock(m_lock) + lock (m_lock) { bool update = item.ID != null; if (!update && item.DBPath == null) @@ -511,7 +522,7 @@ namespace Duplicati.Server.Database if (!System.IO.Directory.Exists(folder)) System.IO.Directory.CreateDirectory(folder); - for(var i = 0; i < 100; i++) + for (var i = 0; i < 100; i++) { var guess = System.IO.Path.Combine(folder, System.IO.Path.ChangeExtension(Duplicati.Library.Main.DatabaseLocator.GenerateRandomName(), ".sqlite")); if (!System.IO.File.Exists(guess)) @@ -520,12 +531,12 @@ namespace Duplicati.Server.Database break; } } - + if (item.DBPath == null) throw new Exception("Unable to generate a unique database file name"); } - using(var tr = m_connection.BeginTransaction()) + using (var tr = m_connection.BeginTransaction()) { OverwriteAndUpdateDb( tr, @@ -535,13 +546,14 @@ namespace Duplicati.Server.Database update ? @"UPDATE ""Backup"" SET ""Name""=?, ""Description""=?, ""Tags""=?, ""TargetURL""=? WHERE ""ID""=?" : @"INSERT INTO ""Backup"" (""Name"", ""Description"", ""Tags"", ""TargetURL"", ""DBPath"") VALUES (?,?,?,?,?)", - (n) => { - + (n) => + { + if (n.TargetURL.IndexOf(Duplicati.Server.WebServer.Server.PASSWORD_PLACEHOLDER, StringComparison.Ordinal) >= 0) throw new Exception("Attempted to save a backup with the password placeholder"); if (update && long.Parse(n.ID) <= 0) throw new Exception("Invalid update, cannot update application settings through update method"); - + return new object[] { n.Name, n.Description ?? "" , // Description is optional but the column is set to NOT NULL, an additional check is welcome @@ -552,13 +564,13 @@ namespace Duplicati.Server.Database }); if (!update) - using(var cmd = m_connection.CreateCommand()) + using (var cmd = m_connection.CreateCommand()) { cmd.Transaction = tr; cmd.CommandText = @"SELECT last_insert_rowid();"; item.ID = ExecuteScalarInt64(cmd).ToString(); } - + var id = long.Parse(item.ID); if (long.Parse(item.ID) <= 0) @@ -568,10 +580,10 @@ namespace Duplicati.Server.Database SetSettings(item.Settings, id, tr); SetFilters(item.Filters, id, tr); SetMetadata(item.Metadata, id, tr); - + if (updateSchedule) { - var tags = new string[] { "ID=" + item.ID }; + var tags = new string[] { "ID=" + item.ID }; var existing = GetScheduleIDsFromTags(tags); if (schedule == null && existing.Any()) DeleteFromDb("Schedule", existing.First(), tr); @@ -584,30 +596,30 @@ namespace Duplicati.Server.Database cur.Repeat = schedule.Repeat; cur.Tags = schedule.Tags; cur.Time = schedule.Time; - + schedule = cur; } else { schedule.ID = -1; } - + schedule.Tags = tags; AddOrUpdateSchedule(schedule, tr); } } - + tr.Commit(); FIXMEGlobal.IncrementLastDataUpdateID(); FIXMEGlobal.StatusEventNotifyer.SignalNewEvent(); } } } - + internal void AddOrUpdateSchedule(ISchedule item) { - lock(m_lock) - using(var tr = m_connection.BeginTransaction()) + lock (m_lock) + using (var tr = m_connection.BeginTransaction()) { AddOrUpdateSchedule(item, tr); tr.Commit(); @@ -615,10 +627,10 @@ namespace Duplicati.Server.Database FIXMEGlobal.StatusEventNotifyer.SignalNewEvent(); } } - + private void AddOrUpdateSchedule(ISchedule item, System.Data.IDbTransaction tr) { - lock(m_lock) + lock (m_lock) { bool update = item.ID >= 0; OverwriteAndUpdateDb( @@ -637,9 +649,9 @@ namespace Duplicati.Server.Database n.Rule ?? "", update ? (object)item.ID : null }); - + if (!update) - using(var cmd = m_connection.CreateCommand()) + using (var cmd = m_connection.CreateCommand()) { cmd.Transaction = tr; cmd.CommandText = @"SELECT last_insert_rowid();"; @@ -652,10 +664,10 @@ namespace Duplicati.Server.Database { if (ID < 0) return; - - lock(m_lock) + + lock (m_lock) { - using(var tr = m_connection.BeginTransaction()) + using (var tr = m_connection.BeginTransaction()) { var existing = GetScheduleIDsFromTags(new string[] { "ID=" + ID.ToString() }); if (existing.Any()) @@ -669,7 +681,7 @@ namespace Duplicati.Server.Database DeleteFromDb("Source", ID, "BackupID", tr); DeleteFromDb("Backup", ID, tr); - + tr.Commit(); } } @@ -677,7 +689,7 @@ namespace Duplicati.Server.Database FIXMEGlobal.IncrementLastDataUpdateID(); FIXMEGlobal.StatusEventNotifyer.SignalNewEvent(); } - + public void DeleteBackup(IBackup backup) { if (backup.IsTemporary) @@ -685,32 +697,33 @@ namespace Duplicati.Server.Database else DeleteBackup(long.Parse(backup.ID)); } - + public void DeleteSchedule(long ID) { if (ID < 0) return; - - lock(m_lock) + + lock (m_lock) DeleteFromDb("Schedule", ID); - + FIXMEGlobal.IncrementLastDataUpdateID(); FIXMEGlobal.StatusEventNotifyer.SignalNewEvent(); } - + public void DeleteSchedule(ISchedule schedule) { DeleteSchedule(schedule.ID); } - + public IBackup[] Backups { get { - lock(m_lock) + lock (m_lock) { var lst = ReadFromDb( - (rd) => (IBackup)new Backup() { + (rd) => (IBackup)new Backup() + { ID = ConvertToInt64(rd, 0).ToString(), Name = ConvertToString(rd, 1), Description = ConvertToString(rd, 2), @@ -720,23 +733,24 @@ namespace Duplicati.Server.Database }, @"SELECT ""ID"", ""Name"", ""Description"", ""Tags"", ""TargetURL"", ""DBPath"" FROM ""Backup"" ") .ToArray(); - - foreach(var n in lst) + + foreach (var n in lst) n.Metadata = GetMetadata(long.Parse(n.ID)); - - + + return lst; } } } - + public ISchedule[] Schedules { get { - lock(m_lock) + lock (m_lock) return ReadFromDb( - (rd) => (ISchedule)new Schedule() { + (rd) => (ISchedule)new Schedule() + { ID = ConvertToInt64(rd, 0), Tags = (ConvertToString(rd, 1) ?? "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), Time = ConvertToDateTime(rd, 2), @@ -746,16 +760,16 @@ namespace Duplicati.Server.Database }, @"SELECT ""ID"", ""Tags"", ""Time"", ""Repeat"", ""LastRun"", ""Rule"" FROM ""Schedule"" ") .ToArray(); - } + } } - - + + public IFilter[] Filters { get { return GetFilters(ANY_BACKUP_ID); } set { SetFilters(value, ANY_BACKUP_ID); } } - + public ISetting[] Settings { get { return GetSettings(ANY_BACKUP_ID); } @@ -764,13 +778,13 @@ namespace Duplicati.Server.Database public INotification[] GetNotifications() { - lock(m_lock) + lock (m_lock) return ReadFromDb(null).Cast().ToArray(); } public bool DismissNotification(long id) { - lock(m_lock) + lock (m_lock) { var notifications = GetNotifications(); var cur = notifications.FirstOrDefault(x => x.ID == id); @@ -790,7 +804,7 @@ namespace Duplicati.Server.Database public void RegisterNotification(Serialization.NotificationType type, string title, string message, Exception ex, string backupid, string action, string logid, string messageid, string logtag, Func conflicthandler) { - lock(m_lock) + lock (m_lock) { var notification = new Notification() { @@ -810,7 +824,7 @@ namespace Duplicati.Server.Database var conflictResult = conflicthandler(notification, GetNotifications()); if (conflictResult == null) return; - + if (conflictResult != notification) DeleteFromDb(typeof(Notification).Name, conflictResult.ID); @@ -829,7 +843,7 @@ namespace Duplicati.Server.Database //Workaround to clean up the database after invalid settings update public void FixInvalidBackupId() { - using(var cmd = m_connection.CreateCommand()) + using (var cmd = m_connection.CreateCommand()) using (var tr = m_connection.BeginTransaction()) { cmd.Transaction = tr; @@ -858,7 +872,7 @@ namespace Duplicati.Server.Database public string[] GetUISettingsSchemes() { - lock(m_lock) + lock (m_lock) return ReadFromDb( (rd) => ConvertToString(rd, 0) ?? "", @"SELECT DISTINCT ""Scheme"" FROM ""UIStorage""") @@ -867,33 +881,34 @@ namespace Duplicati.Server.Database public IDictionary GetUISettings(string scheme) { - lock(m_lock) + lock (m_lock) return ReadFromDb( (rd) => new KeyValuePair( ConvertToString(rd, 0) ?? "", ConvertToString(rd, 1) ?? "" ), - @"SELECT ""Key"", ""Value"" FROM ""UIStorage"" WHERE ""Scheme"" = ?", + @"SELECT ""Key"", ""Value"" FROM ""UIStorage"" WHERE ""Scheme"" = ?", scheme) .GroupBy(x => x.Key) .ToDictionary(x => x.Key, x => x.Last().Value); } - + public void SetUISettings(string scheme, IDictionary values, System.Data.IDbTransaction transaction = null) { - lock(m_lock) - using(var tr = transaction == null ? m_connection.BeginTransaction() : null) + lock (m_lock) + using (var tr = transaction == null ? m_connection.BeginTransaction() : null) { OverwriteAndUpdateDb( tr, @"DELETE FROM ""UIStorage"" WHERE ""Scheme"" = ?", new object[] { scheme }, values, @"INSERT INTO ""UIStorage"" (""Scheme"", ""Key"", ""Value"") VALUES (?, ?, ?)", - (f) => { + (f) => + { return new object[] { scheme, f.Key ?? "", f.Value ?? "" }; } - ); - + ); + if (tr != null) tr.Commit(); } @@ -922,19 +937,20 @@ namespace Duplicati.Server.Database public TempFile[] GetTempFiles() { - lock(m_lock) + lock (m_lock) return ReadFromDb(null).ToArray(); } public void DeleteTempFile(long id) { - lock(m_lock) + lock (m_lock) DeleteFromDb(typeof(TempFile).Name, id); } public long RegisterTempFile(string origin, string path, DateTime expires) { - var tempfile = new TempFile() { + var tempfile = new TempFile() + { Timestamp = DateTime.Now, Origin = origin, Path = path, @@ -950,8 +966,8 @@ namespace Duplicati.Server.Database { var t = Library.Utility.Utility.NormalizeDateTimeToEpochSeconds(purgeDate); - using(var tr = m_connection.BeginTransaction()) - using(var cmd = m_connection.CreateCommand()) + using (var tr = m_connection.BeginTransaction()) + using (var cmd = m_connection.CreateCommand()) { cmd.Transaction = tr; cmd.CommandText = @"DELETE FROM ""ErrorLog"" WHERE ""Timestamp"" < ?"; @@ -962,7 +978,7 @@ namespace Duplicati.Server.Database tr.Commit(); } } - + private static DateTime ConvertToDateTime(System.Data.IDataReader rd, int index) { var unixTime = ConvertToInt64(rd, index); @@ -973,7 +989,7 @@ namespace Duplicati.Server.Database { return ConvertToInt64(rd, index) == 1; } - + private static string ConvertToString(System.Data.IDataReader rd, int index) { var r = rd.GetValue(index); @@ -996,13 +1012,13 @@ namespace Duplicati.Server.Database private static long ExecuteScalarInt64(System.Data.IDbCommand cmd, long defaultValue = -1) { - using(var rd = cmd.ExecuteReader()) + using (var rd = cmd.ExecuteReader()) return rd.Read() ? ConvertToInt64(rd, 0) : defaultValue; } private static string ExecuteScalarString(System.Data.IDbCommand cmd) { - using(var rd = cmd.ExecuteReader()) + using (var rd = cmd.ExecuteReader()) return rd.Read() ? ConvertToString(rd, 0) : null; } @@ -1029,9 +1045,9 @@ namespace Duplicati.Server.Database // New function that allows to delete rows from tables with arbitrary identifier values (e.g. ID or BackupID) private bool DeleteFromDb(string tablename, long id, string identifier, System.Data.IDbTransaction transaction = null) { - if (transaction == null) + if (transaction == null) { - using(var tr = m_connection.BeginTransaction()) + using (var tr = m_connection.BeginTransaction()) { var r = DeleteFromDb(tablename, id, tr); tr.Commit(); @@ -1040,14 +1056,14 @@ namespace Duplicati.Server.Database } else { - using(var cmd = m_connection.CreateCommand()) + using (var cmd = m_connection.CreateCommand()) { cmd.Transaction = transaction; cmd.CommandText = string.Format(@"DELETE FROM ""{0}"" WHERE ""{1}""=?", tablename, identifier); var p = cmd.CreateParameter(); p.Value = id; cmd.Parameters.Add(p); - + var r = cmd.ExecuteNonQuery(); // Roll back the transaction if more than 1 ID was deleted. Multiple "BackupID" rows being deleted isn't a problem. if (identifier == "ID" && r > 1) @@ -1056,24 +1072,24 @@ namespace Duplicati.Server.Database } } } - + private static IEnumerable Read(System.Data.IDbCommand cmd, Func f) { - using(var rd = cmd.ExecuteReader()) - while(rd.Read()) + using (var rd = cmd.ExecuteReader()) + while (rd.Read()) yield return f(rd); } - + private static IEnumerable Read(System.Data.IDataReader rd, Func f) { - while(rd.Read()) + while (rd.Read()) yield return f(); } private System.Reflection.PropertyInfo[] GetORMFields() { - var flags = - System.Reflection.BindingFlags.FlattenHierarchy | + var flags = + System.Reflection.BindingFlags.FlattenHierarchy | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public; @@ -1084,10 +1100,10 @@ namespace Duplicati.Server.Database typeof(DateTime) }; - return + return (from n in typeof(T).GetProperties(flags) - where supportedPropertyTypes.Contains(n.PropertyType) || n.PropertyType.IsEnum - select n).ToArray(); + where supportedPropertyTypes.Contains(n.PropertyType) || n.PropertyType.IsEnum + select n).ToArray(); } private IEnumerable ReadFromDb(string whereclause, params object[] args) @@ -1102,26 +1118,27 @@ namespace Duplicati.Server.Database whereclause ?? "" ); - return ReadFromDb((rd) => { - var item = Activator.CreateInstance(); - for(var i = 0; i < properties.Length; i++) - { - var prop = properties[i]; + return ReadFromDb((rd) => + { + var item = Activator.CreateInstance(); + for (var i = 0; i < properties.Length; i++) + { + var prop = properties[i]; - if (prop.PropertyType.IsEnum) - prop.SetValue(item, ConvertToEnum(prop.PropertyType, rd, i, Enum.GetValues(prop.PropertyType).GetValue(0)), null); - else if (prop.PropertyType == typeof(string)) - prop.SetValue(item, ConvertToString(rd, i), null); - else if (prop.PropertyType == typeof(long)) - prop.SetValue(item, ConvertToInt64(rd, i), null); - else if (prop.PropertyType == typeof(bool)) - prop.SetValue(item, ConvertToBoolean(rd, i), null); - else if (prop.PropertyType == typeof(DateTime)) - prop.SetValue(item, ConvertToDateTime(rd, i), null); - } + if (prop.PropertyType.IsEnum) + prop.SetValue(item, ConvertToEnum(prop.PropertyType, rd, i, Enum.GetValues(prop.PropertyType).GetValue(0)), null); + else if (prop.PropertyType == typeof(string)) + prop.SetValue(item, ConvertToString(rd, i), null); + else if (prop.PropertyType == typeof(long)) + prop.SetValue(item, ConvertToInt64(rd, i), null); + else if (prop.PropertyType == typeof(bool)) + prop.SetValue(item, ConvertToBoolean(rd, i), null); + else if (prop.PropertyType == typeof(DateTime)) + prop.SetValue(item, ConvertToDateTime(rd, i), null); + } - return item; - }, sql, args); + return item; + }, sql, args); } private void OverwriteAndUpdateDb(System.Data.IDbTransaction transaction, string deleteSql, object[] deleteArgs, IEnumerable values, bool updateExisting) @@ -1144,7 +1161,7 @@ namespace Duplicati.Server.Database } else { - + sql = string.Format( @"INSERT INTO ""{0}"" (""{1}"") VALUES ({2})", typeof(T).Name, @@ -1164,12 +1181,12 @@ namespace Duplicati.Server.Database else if (x.PropertyType == typeof(DateTime)) val = Library.Utility.Utility.NormalizeDateTimeToEpochSeconds((DateTime)val); - return val; + return val; }).ToArray(); }); if (!updateExisting && values.Count() == 1 && idfield != null) - using(var cmd = m_connection.CreateCommand()) + using (var cmd = m_connection.CreateCommand()) { cmd.Transaction = transaction; cmd.CommandText = @"SELECT last_insert_rowid();"; @@ -1179,64 +1196,64 @@ namespace Duplicati.Server.Database idfield.SetValue(values.First(), ExecuteScalarInt64(cmd), null); } } - + private IEnumerable ReadFromDb(Func f, string sql, params object[] args) { - using(var cmd = m_connection.CreateCommand()) + using (var cmd = m_connection.CreateCommand()) { cmd.CommandText = sql; if (args != null) - foreach(var a in args) + foreach (var a in args) { var p = cmd.CreateParameter(); p.Value = a; cmd.Parameters.Add(p); } - + return Read(cmd, f).ToArray(); } } - + private void OverwriteAndUpdateDb(System.Data.IDbTransaction transaction, string deleteSql, object[] deleteArgs, IEnumerable values, string insertSql, Func f) { - using(var cmd = m_connection.CreateCommand()) + using (var cmd = m_connection.CreateCommand()) { cmd.Transaction = transaction; - + if (!string.IsNullOrEmpty(deleteSql)) { cmd.CommandText = deleteSql; if (deleteArgs != null) - foreach(var a in deleteArgs) + foreach (var a in deleteArgs) { var p = cmd.CreateParameter(); p.Value = a; cmd.Parameters.Add(p); } - + cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); } - + cmd.CommandText = insertSql; - - foreach(var n in values) + + foreach (var n in values) { var r = f(n); if (r == null) continue; - + while (cmd.Parameters.Count < r.Length) cmd.Parameters.Add(cmd.CreateParameter()); - - for(var i = 0; i < r.Length; i++) + + for (var i = 0; i < r.Length; i++) ((System.Data.IDbDataParameter)cmd.Parameters[i]).Value = r[i]; - + cmd.ExecuteNonQuery(); } } } - + #region IDisposable implementation public void Dispose() { @@ -1257,6 +1274,6 @@ namespace Duplicati.Server.Database } #endregion } - + } diff --git a/Duplicati.Library.RestAPI/Database/Filter.cs b/Duplicati.Library.RestAPI/Database/Filter.cs index 7f14e2bda..904b2bf4c 100644 --- a/Duplicati.Library.RestAPI/Database/Filter.cs +++ b/Duplicati.Library.RestAPI/Database/Filter.cs @@ -1,20 +1,24 @@ -// Copyright (C) 2015, The Duplicati Team +// Copyright (C) 2024, The Duplicati Team +// https://duplicati.com, hello@duplicati.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. -// http://www.duplicati.com, info@duplicati.com -// -// 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; namespace Duplicati.Server.Database diff --git a/Duplicati.Library.RestAPI/Database/Notification.cs b/Duplicati.Library.RestAPI/Database/Notification.cs index 22b507701..a14d4f6c4 100644 --- a/Duplicati.Library.RestAPI/Database/Notification.cs +++ b/Duplicati.Library.RestAPI/Database/Notification.cs @@ -1,20 +1,24 @@ -// Copyright (C) 2015, The Duplicati Team +// Copyright (C) 2024, The Duplicati Team +// https://duplicati.com, hello@duplicati.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. -// http://www.duplicati.com, info@duplicati.com -// -// 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; namespace Duplicati.Server.Database @@ -29,7 +33,7 @@ namespace Duplicati.Server.Database public string Exception { get; set; } public string BackupID { get; set; } public string Action { get; set; } - public DateTime Timestamp { get; set; } + public DateTime Timestamp { get; set; } public string LogEntryID { get; set; } public string MessageID { get; set; } public string MessageLogTag { get; set; } diff --git a/Duplicati.Library.RestAPI/Database/Schedule.cs b/Duplicati.Library.RestAPI/Database/Schedule.cs index 7df817d40..5a9d28202 100644 --- a/Duplicati.Library.RestAPI/Database/Schedule.cs +++ b/Duplicati.Library.RestAPI/Database/Schedule.cs @@ -1,20 +1,24 @@ -// Copyright (C) 2015, The Duplicati Team +// Copyright (C) 2024, The Duplicati Team +// https://duplicati.com, hello@duplicati.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. -// http://www.duplicati.com, info@duplicati.com -// -// 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; using System.Linq; using Duplicati.Server.Serialization.Interface; @@ -29,38 +33,38 @@ namespace Duplicati.Server.Database public string Repeat { get; set; } public DateTime LastRun { get; set; } public string Rule { get; set; } - + public DayOfWeek[] AllowedDays - { + { get { if (string.IsNullOrEmpty(this.Rule)) return null; - - var days = (from n in this.Rule.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries) - where n.StartsWith("AllowedWeekDays=", StringComparison.OrdinalIgnoreCase) - select n.Substring("AllowedWeekDays=".Length).Split(new char[] {','}, StringSplitOptions.RemoveEmptyEntries)) + + var days = (from n in this.Rule.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries) + where n.StartsWith("AllowedWeekDays=", StringComparison.OrdinalIgnoreCase) + select n.Substring("AllowedWeekDays=".Length).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) .FirstOrDefault(); - - + + if (days == null) return null; - return (from n in days + return (from n in days where Enum.TryParse(n, true, out _) select (DayOfWeek)Enum.Parse(typeof(DayOfWeek), n, true)) .ToArray(); } set { - - var parts = - string.IsNullOrEmpty(this.Rule) ? + + var parts = + string.IsNullOrEmpty(this.Rule) ? new string[0] : - (from n in this.Rule.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries) - where !n.StartsWith("AllowedWeekDays=", StringComparison.OrdinalIgnoreCase) - select n); - + (from n in this.Rule.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries) + where !n.StartsWith("AllowedWeekDays=", StringComparison.OrdinalIgnoreCase) + select n); + if (value != null && value.Length != 0) parts = parts.Union(new string[] { "AllowedWeekDays=" + @@ -70,7 +74,7 @@ namespace Duplicati.Server.Database select Enum.GetName(typeof(DayOfWeek), n)).Distinct() ) }).Distinct(); - + this.Rule = string.Join(";", parts); } } diff --git a/Duplicati.Library.RestAPI/Database/ServerSettings.cs b/Duplicati.Library.RestAPI/Database/ServerSettings.cs index 9e446b731..57a0988dc 100644 --- a/Duplicati.Library.RestAPI/Database/ServerSettings.cs +++ b/Duplicati.Library.RestAPI/Database/ServerSettings.cs @@ -1,20 +1,24 @@ -// Copyright (C) 2015, The Duplicati Team +// Copyright (C) 2024, The Duplicati Team +// https://duplicati.com, hello@duplicati.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. -// http://www.duplicati.com, info@duplicati.com -// -// 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; using System.Linq; using System.Collections.Generic; @@ -50,10 +54,10 @@ namespace Duplicati.Server.Database public const string HAS_FIXED_INVALID_BACKUPID = "has-fixed-invalid-backup-id"; public const string UPDATE_CHANNEL = "update-channel"; public const string USAGE_REPORTER_LEVEL = "usage-reporter-level"; - public const string HAS_ASKED_FOR_PASSWORD_PROTECTION = "has-asked-for-password-protection"; + public const string HAS_ASKED_FOR_PASSWORD_PROTECTION = "has-asked-for-password-protection"; public const string DISABLE_TRAY_ICON_LOGIN = "disable-tray-icon-login"; public const string SERVER_ALLOWED_HOSTNAMES = "allowed-hostnames"; - } + } private readonly Dictionary settings; private readonly Connection databaseConnection; @@ -68,12 +72,12 @@ namespace Duplicati.Server.Database public void ReloadSettings() { - lock(databaseConnection.m_lock) + lock (databaseConnection.m_lock) { settings.Clear(); - foreach(var n in typeof(CONST).GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Static).Select(x => (string)x.GetValue(null))) + foreach (var n in typeof(CONST).GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Static).Select(x => (string)x.GetValue(null))) settings[n] = null; - foreach(var n in databaseConnection.GetSettings(Connection.SERVER_SETTINGS_ID)) + foreach (var n in databaseConnection.GetSettings(Connection.SERVER_SETTINGS_ID)) settings[n.Name] = n.Value; } } @@ -83,13 +87,13 @@ namespace Duplicati.Server.Database if (newsettings == null) throw new ArgumentNullException(); - lock(databaseConnection.m_lock) + lock (databaseConnection.m_lock) { m_latestUpdate = null; if (clearExisting) settings.Clear(); - foreach(var k in newsettings) + foreach (var k in newsettings) if (!clearExisting && newsettings[k.Key] == null && k.Key.StartsWith("--", StringComparison.Ordinal)) settings.Remove(k.Key); else @@ -98,44 +102,45 @@ namespace Duplicati.Server.Database } SaveSettings(); - + if (newsettings.Keys.Contains(CONST.SERVER_PASSPHRASE)) GenerateWebserverPasswordTrayIcon(); } - + private void SaveSettings() { databaseConnection.SetSettings( from n in settings - select (Duplicati.Server.Serialization.Interface.ISetting)new Setting() { + select (Duplicati.Server.Serialization.Interface.ISetting)new Setting() + { Filter = "", Name = n.Key, Value = n.Value - }, Database.Connection.SERVER_SETTINGS_ID); + }, Database.Connection.SERVER_SETTINGS_ID); FIXMEGlobal.IncrementLastDataUpdateID(); FIXMEGlobal.StatusEventNotifyer.SignalNewEvent(); - // In case the usage reporter is enabled or disabled, refresh now - FIXMEGlobal.StartOrStopUsageReporter(); + // In case the usage reporter is enabled or disabled, refresh now + FIXMEGlobal.StartOrStopUsageReporter(); // If throttle options were changed, update now FIXMEGlobal.UpdateThrottleSpeeds(); } - + public string StartupDelayDuration { - get + get { return settings[CONST.STARTUP_DELAY]; } set { - lock(databaseConnection.m_lock) + lock (databaseConnection.m_lock) settings[CONST.STARTUP_DELAY] = value; SaveSettings(); } } - + public System.Threading.ThreadPriority? ThreadPriorityOverride { get @@ -143,43 +148,43 @@ namespace Duplicati.Server.Database var tp = settings[CONST.THREAD_PRIORITY]; if (string.IsNullOrEmpty(tp)) return null; - - System.Threading.ThreadPriority r; + + System.Threading.ThreadPriority r; if (Enum.TryParse(tp, true, out r)) return r; - + return null; } set { - lock(databaseConnection.m_lock) + lock (databaseConnection.m_lock) settings[CONST.THREAD_PRIORITY] = value.HasValue ? Enum.GetName(typeof(System.Threading.ThreadPriority), value.Value) : null; } } - + public string DownloadSpeedLimit { - get + get { return settings[CONST.DOWNLOAD_SPEED_LIMIT]; } set { - lock(databaseConnection.m_lock) + lock (databaseConnection.m_lock) settings[CONST.DOWNLOAD_SPEED_LIMIT] = value; SaveSettings(); } } - + public string UploadSpeedLimit { - get + get { return settings[CONST.UPLOAD_SPEED_LIMIT]; } set { - lock(databaseConnection.m_lock) + lock (databaseConnection.m_lock) settings[CONST.UPLOAD_SPEED_LIMIT] = value; SaveSettings(); } @@ -193,7 +198,7 @@ namespace Duplicati.Server.Database } set { - lock(databaseConnection.m_lock) + lock (databaseConnection.m_lock) settings[CONST.IS_FIRST_RUN] = value.ToString(); SaveSettings(); } @@ -221,7 +226,7 @@ namespace Duplicati.Server.Database } set { - lock(databaseConnection.m_lock) + lock (databaseConnection.m_lock) settings[CONST.UNACKED_ERROR] = value.ToString(); SaveSettings(); } @@ -235,7 +240,7 @@ namespace Duplicati.Server.Database } set { - lock(databaseConnection.m_lock) + lock (databaseConnection.m_lock) settings[CONST.UNACKED_WARNING] = value.ToString(); SaveSettings(); } @@ -249,7 +254,7 @@ namespace Duplicati.Server.Database } set { - lock(databaseConnection.m_lock) + lock (databaseConnection.m_lock) settings[CONST.SERVER_PORT_CHANGED] = value.ToString(); SaveSettings(); } @@ -282,7 +287,7 @@ namespace Duplicati.Server.Database } set { - lock(databaseConnection.m_lock) + lock (databaseConnection.m_lock) settings[CONST.LAST_WEBSERVER_PORT] = value.ToString(); SaveSettings(); } @@ -290,7 +295,7 @@ namespace Duplicati.Server.Database public string WebserverPassword { - get + get { return settings[CONST.SERVER_PASSPHRASE]; } @@ -298,7 +303,7 @@ namespace Duplicati.Server.Database public string WebserverPasswordSalt { - get + get { return settings[CONST.SERVER_PASSPHRASE_SALT]; } @@ -308,7 +313,7 @@ namespace Duplicati.Server.Database { if (string.IsNullOrWhiteSpace(password)) { - lock(databaseConnection.m_lock) + lock (databaseConnection.m_lock) { settings[CONST.SERVER_PASSPHRASE] = ""; settings[CONST.SERVER_PASSPHRASE_SALT] = ""; @@ -328,7 +333,7 @@ namespace Duplicati.Server.Database sha256.TransformFinalBlock(buf, 0, buf.Length); var pwd = Convert.ToBase64String(sha256.Hash); - lock(databaseConnection.m_lock) + lock (databaseConnection.m_lock) { settings[CONST.SERVER_PASSPHRASE] = pwd; settings[CONST.SERVER_PASSPHRASE_SALT] = salt; @@ -369,7 +374,7 @@ namespace Duplicati.Server.Database sha256.TransformFinalBlock(buf, 0, buf.Length); pwd = Convert.ToBase64String(sha256.Hash); } - + lock (databaseConnection.m_lock) { settings[CONST.SERVER_PASSPHRASETRAYICON] = password; @@ -381,7 +386,7 @@ namespace Duplicati.Server.Database public DateTime LastUpdateCheck { - get + get { long t; if (long.TryParse(settings[CONST.UPDATE_CHECK_LAST], out t)) @@ -391,7 +396,7 @@ namespace Duplicati.Server.Database } set { - lock(databaseConnection.m_lock) + lock (databaseConnection.m_lock) settings[CONST.UPDATE_CHECK_LAST] = value.ToUniversalTime().Ticks.ToString(); SaveSettings(); } @@ -409,7 +414,7 @@ namespace Duplicati.Server.Database } set { - lock(databaseConnection.m_lock) + lock (databaseConnection.m_lock) settings[CONST.UPDATE_CHECK_INTERVAL] = value; SaveSettings(); FIXMEGlobal.UpdatePoller.Reschedule(); @@ -443,7 +448,7 @@ namespace Duplicati.Server.Database if (m_latestUpdate != null) return m_latestUpdate; - using(var tr = new System.IO.StringReader(settings[CONST.UPDATE_CHECK_NEW_VERSION])) + using (var tr = new System.IO.StringReader(settings[CONST.UPDATE_CHECK_NEW_VERSION])) return m_latestUpdate = Server.Serialization.Serializer.Deserialize(tr); } catch @@ -458,14 +463,14 @@ namespace Duplicati.Server.Database if (value != null) { var sb = new System.Text.StringBuilder(); - using(var tw = new System.IO.StringWriter(sb)) + using (var tw = new System.IO.StringWriter(sb)) Server.Serialization.Serializer.SerializeJson(tw, value); result = sb.ToString(); } m_latestUpdate = value; - lock(databaseConnection.m_lock) + lock (databaseConnection.m_lock) settings[CONST.UPDATE_CHECK_NEW_VERSION] = result; SaveSettings(); @@ -474,13 +479,13 @@ namespace Duplicati.Server.Database public string ServerListenInterface { - get + get { return settings[CONST.SERVER_LISTEN_INTERFACE]; } set { - lock(databaseConnection.m_lock) + lock (databaseConnection.m_lock) settings[CONST.SERVER_LISTEN_INTERFACE] = value; SaveSettings(); } @@ -526,7 +531,7 @@ namespace Duplicati.Server.Database } set { - lock(databaseConnection.m_lock) + lock (databaseConnection.m_lock) settings[CONST.HAS_FIXED_INVALID_BACKUPID] = value.ToString(); SaveSettings(); } @@ -534,13 +539,13 @@ namespace Duplicati.Server.Database public string UpdateChannel { - get + get { return settings[CONST.UPDATE_CHANNEL]; } set { - lock(databaseConnection.m_lock) + lock (databaseConnection.m_lock) settings[CONST.UPDATE_CHANNEL] = value; SaveSettings(); } @@ -548,13 +553,13 @@ namespace Duplicati.Server.Database public string UsageReporterLevel { - get + get { return settings[CONST.USAGE_REPORTER_LEVEL]; } set { - lock(databaseConnection.m_lock) + lock (databaseConnection.m_lock) settings[CONST.USAGE_REPORTER_LEVEL] = value; SaveSettings(); } diff --git a/Duplicati.Library.RestAPI/Database/Setting.cs b/Duplicati.Library.RestAPI/Database/Setting.cs index 84150bf1a..3c5cff529 100644 --- a/Duplicati.Library.RestAPI/Database/Setting.cs +++ b/Duplicati.Library.RestAPI/Database/Setting.cs @@ -1,20 +1,24 @@ -// Copyright (C) 2015, The Duplicati Team +// Copyright (C) 2024, The Duplicati Team +// https://duplicati.com, hello@duplicati.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. -// http://www.duplicati.com, info@duplicati.com -// -// 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; namespace Duplicati.Server.Database diff --git a/Duplicati.Library.RestAPI/Database/TempFile.cs b/Duplicati.Library.RestAPI/Database/TempFile.cs index b652a2920..284403531 100644 --- a/Duplicati.Library.RestAPI/Database/TempFile.cs +++ b/Duplicati.Library.RestAPI/Database/TempFile.cs @@ -1,20 +1,24 @@ -// Copyright (C) 2015, The Duplicati Team +// Copyright (C) 2024, The Duplicati Team +// https://duplicati.com, hello@duplicati.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. -// http://www.duplicati.com, info@duplicati.com -// -// 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; namespace Duplicati.Server.Database diff --git a/Duplicati.Library.RestAPI/LiveControls.cs b/Duplicati.Library.RestAPI/LiveControls.cs index 2171fb754..dd95f1af5 100644 --- a/Duplicati.Library.RestAPI/LiveControls.cs +++ b/Duplicati.Library.RestAPI/LiveControls.cs @@ -1,22 +1,24 @@ -#region Disclaimer / License -// Copyright (C) 2015, The Duplicati Team -// http://www.duplicati.com, info@duplicati.com +// Copyright (C) 2024, The Duplicati Team +// https://duplicati.com, hello@duplicati.com // -// 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. +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: // -// 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. +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. // -// 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 +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + using System; using System.Collections.Generic; using System.Runtime.Versioning; @@ -110,8 +112,8 @@ namespace Duplicati.Server /// /// Gets the current overridden thread priority /// - public System.Threading.ThreadPriority? ThreadPriority - { + public System.Threading.ThreadPriority? ThreadPriority + { get { return m_priority; } set { @@ -127,8 +129,8 @@ namespace Duplicati.Server /// /// Gets the current upload limit in bps /// - public long? UploadLimit - { + public long? UploadLimit + { get { return m_uploadLimit; } set { @@ -144,8 +146,8 @@ namespace Duplicati.Server /// /// Gets the download limit in bps /// - public long? DownloadLimit - { + public long? DownloadLimit + { get { return m_downloadLimit; } set { @@ -180,7 +182,7 @@ namespace Duplicati.Server { long milliseconds = 0; try { milliseconds = (long)Duplicati.Library.Utility.Timeparser.ParseTimeSpan(settings.StartupDelayDuration).TotalMilliseconds; } - catch {} + catch { } if (milliseconds > 0) { @@ -223,7 +225,7 @@ namespace Duplicati.Server /// Event that occurs when the timeout duration is exceeded /// /// The sender of the event - private void m_waitTimer_Tick(object sender) + private void m_waitTimer_Tick(object sender) { lock (m_lock) Resume(); @@ -270,7 +272,7 @@ namespace Duplicati.Server /// public void Pause() { - lock(m_lock) + lock (m_lock) { var fireEvent = m_waitTimeExpiration.Ticks != 0 && m_state == LiveControlState.Paused && StateChanged != null; diff --git a/Duplicati.Library.RestAPI/LogWriteHandler.cs b/Duplicati.Library.RestAPI/LogWriteHandler.cs index 640886f66..1d8259e19 100644 --- a/Duplicati.Library.RestAPI/LogWriteHandler.cs +++ b/Duplicati.Library.RestAPI/LogWriteHandler.cs @@ -1,20 +1,24 @@ -// Copyright (C) 2015, The Duplicati Team +// Copyright (C) 2024, The Duplicati Team +// https://duplicati.com, hello@duplicati.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. -// http://www.duplicati.com, info@duplicati.com -// -// 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; using System.Linq; using Duplicati.Library.Logging; @@ -130,7 +134,7 @@ namespace Duplicati.Server this.ExceptionID = exception.HelpID; else this.ExceptionID = entry.Exception.GetType().FullName; - + } } @@ -150,15 +154,15 @@ namespace Duplicati.Server { m_buffer = new T[size]; if (initial != null) - foreach(var t in initial) + foreach (var t in initial) this.Enqueue(t); } - + public int Length { get { return m_length; } } public void Enqueue(T item) { - lock(m_lock) + lock (m_lock) { m_key++; m_buffer[m_head] = item; @@ -174,7 +178,7 @@ namespace Duplicati.Server public IEnumerator GetEnumerator() { var k = m_key; - for(var i = 0; i < m_length; i++) + for (var i = 0; i < m_length; i++) if (m_key != k) throw new InvalidOperationException("Buffer was modified while reading"); else @@ -190,7 +194,7 @@ namespace Duplicati.Server public T[] FlatArray(Func filter = null) { - lock(m_lock) + lock (m_lock) if (filter == null) return this.ToArray(); else @@ -218,7 +222,7 @@ namespace Duplicati.Server public void RenewTimeout(LogMessageType type) { - lock(m_lock) + lock (m_lock) { m_timeouts[(int)type] = DateTime.Now.AddSeconds(30); m_anytimeouts = true; @@ -245,12 +249,12 @@ namespace Duplicati.Server UpdateLogLevel(); offset = offset.ToUniversalTime(); - lock(m_lock) + lock (m_lock) { if (m_buffer == null) return new LogEntry[0]; - - return m_buffer.FlatArray((x) => x.When > offset && x.Type >= level ); + + return m_buffer.FlatArray((x) => x.When > offset && x.Type >= level); } } @@ -259,18 +263,20 @@ namespace Duplicati.Server RenewTimeout(level); UpdateLogLevel(); - lock(m_lock) + lock (m_lock) { if (m_buffer == null) return new LogEntry[0]; - - var buffer = m_buffer.FlatArray((x) => x.ID > id && x.Type >= level ); + + var buffer = m_buffer.FlatArray((x) => x.ID > id && x.Type >= level); // Return the newest entries - if (buffer.Length > pagesize) { + if (buffer.Length > pagesize) + { var index = buffer.Length - pagesize; return buffer.Skip(index).Take(pagesize).ToArray(); } - else { + else + { return buffer; } } @@ -280,13 +286,13 @@ namespace Duplicati.Server { var i = 0; return (from n in m_timeouts - let ix = i++ - where n > DateTime.Now - select ix).ToArray(); + let ix = i++ + where n > DateTime.Now + select ix).ToArray(); } private void UpdateLogLevel() - { + { m_logLevel = (LogMessageType)(GetActiveTimeouts().Union(new int[] { (int)m_serverloglevel }).Min()); } @@ -296,9 +302,9 @@ namespace Duplicati.Server public void WriteMessage(Duplicati.Library.Logging.LogEntry entry) { - if (entry.Level < m_logLevel) + if (entry.Level < m_logLevel) return; - + if (m_serverfile != null && entry.Level >= m_serverloglevel) try { @@ -308,7 +314,7 @@ namespace Duplicati.Server { } - lock(m_lock) + lock (m_lock) { if (m_anytimeouts) { diff --git a/Duplicati.Library.RestAPI/Scheduler.cs b/Duplicati.Library.RestAPI/Scheduler.cs index 81a8cdf41..07e4d9d5c 100644 --- a/Duplicati.Library.RestAPI/Scheduler.cs +++ b/Duplicati.Library.RestAPI/Scheduler.cs @@ -1,25 +1,26 @@ -#region Disclaimer / License -// Copyright (C) 2015, The Duplicati Team -// http://www.duplicati.com, info@duplicati.com +// Copyright (C) 2024, The Duplicati Team +// https://duplicati.com, hello@duplicati.com // -// 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. +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: // -// 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 +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. // +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + using Duplicati.Server.Serialization.Interface; - -#endregion using System; using System.Collections.Generic; using System.Text; @@ -67,7 +68,7 @@ namespace Duplicati.Server /// The currently scheduled items /// private KeyValuePair[] m_schedule; - + /// /// List of update tasks, used to set the timestamp on the schedule once completed /// @@ -104,13 +105,13 @@ namespace Duplicati.Server /// /// A snapshot copy of the current schedule list /// - public List> Schedule - { - get + public List> Schedule + { + get { lock (m_lock) return m_schedule.ToList(); - } + } } /// @@ -195,26 +196,26 @@ namespace Duplicati.Server throw new Exception(Strings.Scheduler.InvalidTimeSetupError(basetime, repetition, sb.ToString())); } - + return res; } - + private void OnCompleted(WorkerThread worker, Runner.IRunnerData task) { Tuple t = null; - lock(m_lock) + lock (m_lock) { if (task != null && m_updateTasks.TryGetValue(task, out t)) m_updateTasks.Remove(task); } - + if (t != null) { t.Item1.Time = t.Item2; t.Item1.LastRun = t.Item3; FIXMEGlobal.DataConnection.AddOrUpdateSchedule(t.Item1); } - + } private void OnStartingWork(WorkerThread worker, Runner.IRunnerData task) @@ -223,8 +224,8 @@ namespace Duplicati.Server { return; } - - lock(m_lock) + + lock (m_lock) { if (m_updateTasks.TryGetValue(task, out Tuple scheduleInfo)) { @@ -245,10 +246,10 @@ namespace Duplicati.Server { //TODO: As this is executed repeatedly we should cache it // to avoid frequent db lookups - + //Determine schedule list var lst = FIXMEGlobal.DataConnection.Schedules; - foreach(var sc in lst) + foreach (var sc in lst) { if (!string.IsNullOrEmpty(sc.Repeat)) { @@ -267,7 +268,7 @@ namespace Duplicati.Server { start = startkey.Value; } - + try { // Recover from timedrift issues by overriding the dates if the last run date is in the future. @@ -288,15 +289,15 @@ namespace Duplicati.Server { var jobsToRun = new List(); //TODO: Cache this to avoid frequent lookups - foreach(var id in FIXMEGlobal.DataConnection.GetBackupIDsForTags(sc.Tags).Distinct().Select(x => x.ToString())) + foreach (var id in FIXMEGlobal.DataConnection.GetBackupIDsForTags(sc.Tags).Distinct().Select(x => x.ToString())) { //See if it is already queued var tmplst = from n in m_worker.CurrentTasks - where n.Operation == Duplicati.Server.Serialization.DuplicatiOperation.Backup - select n.Backup; + where n.Operation == Duplicati.Server.Serialization.DuplicatiOperation.Backup + select n.Backup; var tastTemp = m_worker.CurrentTask; if (tastTemp != null && tastTemp.Operation == Duplicati.Server.Serialization.DuplicatiOperation.Backup) - tmplst = tmplst.Union(new [] { tastTemp.Backup }); + tmplst = tmplst.Union(new[] { tastTemp.Backup }); //If it is not already in queue, put it there if (!tmplst.Any(x => x.ID == id)) @@ -323,12 +324,12 @@ namespace Duplicati.Server { start = GetNextValidTime(start, new DateTime(Math.Max(DateTime.UtcNow.AddSeconds(1).Ticks, start.AddSeconds(1).Ticks), DateTimeKind.Utc), sc.Repeat, sc.AllowedDays); } - catch(Exception ex) + catch (Exception ex) { FIXMEGlobal.DataConnection.LogError(sc.ID.ToString(), "Scheduler failed to find next date", ex); continue; } - + Server.Runner.IRunnerData lastJob = jobsToRun.LastOrDefault(); if (lastJob != null) { @@ -341,7 +342,7 @@ namespace Duplicati.Server foreach (var job in jobsToRun) m_worker.AddTask(job); - + if (start < DateTime.UtcNow) { //TODO: Report this somehow @@ -349,20 +350,20 @@ namespace Duplicati.Server } } - scheduled[sc.ID] = new KeyValuePair(scticks, start); + scheduled[sc.ID] = new KeyValuePair(scticks, start); } } var existing = lst.ToDictionary(x => x.ID); //Sort them, lock as we assign the m_schedule variable - lock(m_lock) + lock (m_lock) m_schedule = (from n in scheduled - where existing.ContainsKey(n.Key) - orderby n.Value.Value - select new KeyValuePair(n.Value.Value, existing[n.Key])).ToArray(); + where existing.ContainsKey(n.Key) + orderby n.Value.Value + select new KeyValuePair(n.Value.Value, existing[n.Key])).ToArray(); // Remove unused entries - foreach(var c in (from n in scheduled where !existing.ContainsKey(n.Key) select n.Key).ToArray()) + foreach (var c in (from n in scheduled where !existing.ContainsKey(n.Key) select n.Key).ToArray()) scheduled.Remove(c); //Raise event if needed @@ -406,7 +407,7 @@ namespace Duplicati.Server if (allowedDays == null || allowedDays.Length == 0) return true; else - return Array.IndexOf(allowedDays, localTime.DayOfWeek) >= 0; + return Array.IndexOf(allowedDays, localTime.DayOfWeek) >= 0; } } diff --git a/Duplicati.Library.RestAPI/SpecialFolders.cs b/Duplicati.Library.RestAPI/SpecialFolders.cs index 6a83004f1..3bef4eac2 100644 --- a/Duplicati.Library.RestAPI/SpecialFolders.cs +++ b/Duplicati.Library.RestAPI/SpecialFolders.cs @@ -1,20 +1,24 @@ -// Copyright (C) 2015, The Duplicati Team +// Copyright (C) 2024, The Duplicati Team +// https://duplicati.com, hello@duplicati.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. -// http://www.duplicati.com, info@duplicati.com -// -// 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; using System.Linq; using System.Collections.Generic; @@ -31,7 +35,7 @@ namespace Duplicati.Server public static string ExpandEnvironmentVariables(string path) { - foreach(var n in Nodes) + foreach (var n in Nodes) if (path.StartsWith(n.id, StringComparison.Ordinal)) path = path.Replace(n.id, n.resolvedpath); return Environment.ExpandEnvironmentVariables(path); @@ -54,21 +58,21 @@ namespace Duplicati.Server }); } - public static string TranslateToPath(string str) + public static string TranslateToPath(string str) { string res; if (PathMap.TryGetValue(str, out res)) return res; - + return null; } - public static string TranslateToDisplayString(string str) + public static string TranslateToDisplayString(string str) { string res; if (DisplayMap.TryGetValue(str, out res)) return res; - + return null; } @@ -109,11 +113,11 @@ namespace Duplicati.Server { } } - + static SpecialFolders() { var lst = new List(); - + if (OperatingSystem.IsWindows()) { TryAdd(lst, Environment.SpecialFolder.MyDocuments, "%MY_DOCUMENTS%", "My Documents"); @@ -181,7 +185,7 @@ namespace Duplicati.Server // Handle duplicates var result = new Dictionary(); - foreach(var x in sources) + foreach (var x in sources) result[x.Key] = x.Value; return result; diff --git a/Duplicati.Library.RestAPI/UpdatePollThread.cs b/Duplicati.Library.RestAPI/UpdatePollThread.cs index fb3890b67..4584223d2 100644 --- a/Duplicati.Library.RestAPI/UpdatePollThread.cs +++ b/Duplicati.Library.RestAPI/UpdatePollThread.cs @@ -1,20 +1,24 @@ -// Copyright (C) 2015, The Duplicati Team +// Copyright (C) 2024, The Duplicati Team +// https://duplicati.com, hello@duplicati.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. -// http://www.duplicati.com, info@duplicati.com -// -// 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; using System.Linq; using System.Threading; diff --git a/Duplicati/WebserverCore/RestHandlerCore.cs b/Duplicati/WebserverCore/RestHandlerCore.cs index 9d1c41a4e..2543f4363 100644 --- a/Duplicati/WebserverCore/RestHandlerCore.cs +++ b/Duplicati/WebserverCore/RestHandlerCore.cs @@ -1,19 +1,23 @@ -// Copyright (C) 2023, The Duplicati Team -// http://www.duplicati.com, info@duplicati.com -// -// 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 +// Copyright (C) 2024, The Duplicati Team +// https://duplicati.com, hello@duplicati.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. using Amazon.S3; using Duplicati.Library.RestAPI; diff --git a/thirdparty/Signer/README-Setup.txt b/thirdparty/Signer/README-Setup.txt deleted file mode 100644 index d7884d268..000000000 --- a/thirdparty/Signer/README-Setup.txt +++ /dev/null @@ -1,17 +0,0 @@ -To set up Signer on a clean Windows box, install .Net 4.0 Framework: -Microsoft .NET Framework 4 (Web Installer) -http://www.microsoft.com/en-us/download/details.aspx?id=17851 - -Then install 4.0 SDK: -Microsoft Windows SDK for Windows 7 and .NET Framework 4 -http://www.microsoft.com/en-us/download/details.aspx?id=8279 - -Then install VC redist: -Microsoft Visual C++ 2008 Service Pack 1 Redistributable Package MFC Security Update -http://www.microsoft.com/en-us/download/details.aspx?id=26368 - -Then set paths: - -set PATH=%PATH%;C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin - - diff --git a/thirdparty/Signer/Signer.exe b/thirdparty/Signer/Signer.exe deleted file mode 100755 index eae02bc39..000000000 Binary files a/thirdparty/Signer/Signer.exe and /dev/null differ diff --git a/thirdparty/Signer/download.txt b/thirdparty/Signer/download.txt deleted file mode 100755 index 1beaf0f86..000000000 --- a/thirdparty/Signer/download.txt +++ /dev/null @@ -1 +0,0 @@ -https://github.com/mtrojnar/osslsigncode diff --git a/thirdparty/Signer/license.txt b/thirdparty/Signer/license.txt deleted file mode 100755 index 5f2d130b1..000000000 --- a/thirdparty/Signer/license.txt +++ /dev/null @@ -1,458 +0,0 @@ -GNU LESSER GENERAL PUBLIC LICENSE -Version 2.1, February 1999 - -Copyright (C) 1991, 1999 Free Software Foundation, Inc. -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -Everyone is permitted to copy and distribute verbatim copies -of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts -as the successor of the GNU Library Public License, version 2, hence -the version number 2.1.] - -Preamble - -The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - -This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - -When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - -To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - -For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - -We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - -To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - -Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - -Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - -When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - -We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - -For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - -In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - -Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - -The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - -GNU LESSER GENERAL PUBLIC LICENSE -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - -0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - -A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - -The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - -"Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - -1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - -You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - -2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - -a) The modified work must itself be a software library. - -b) You must cause the files modified to carry prominent notices -stating that you changed the files and the date of any change. - -c) You must cause the whole of the work to be licensed at no -charge to all third parties under the terms of this License. - -d) If a facility in the modified Library refers to a function or a -table of data to be supplied by an application program that uses -the facility, other than as an argument passed when the facility -is invoked, then you must make a good faith effort to ensure that, -in the event an application does not supply such function or -table, the facility still operates, and performs whatever part of -its purpose remains meaningful. - -(For example, a function in a library to compute square roots has -a purpose that is entirely well-defined independent of the -application. Therefore, Subsection 2d requires that any -application-supplied function or table used by this function must -be optional: if the application does not supply it, the square -root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - -3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - -Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - -This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - -4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - -If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - -5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - -However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - -When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - -If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - -Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - -6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - -You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - -a) Accompany the work with the complete corresponding -machine-readable source code for the Library including whatever -changes were used in the work (which must be distributed under -Sections 1 and 2 above); and, if the work is an executable linked -with the Library, with the complete machine-readable "work that -uses the Library", as object code and/or source code, so that the -user can modify the Library and then relink to produce a modified -executable containing the modified Library. (It is understood -that the user who changes the contents of definitions files in the -Library will not necessarily be able to recompile the application -to use the modified definitions.) - -b) Use a suitable shared library mechanism for linking with the -Library. A suitable mechanism is one that (1) uses at run time a -copy of the library already present on the user's computer system, -rather than copying library functions into the executable, and (2) -will operate properly with a modified version of the library, if -the user installs one, as long as the modified version is -interface-compatible with the version that the work was made with. - -c) Accompany the work with a written offer, valid for at -least three years, to give the same user the materials -specified in Subsection 6a, above, for a charge no more -than the cost of performing this distribution. - -d) If distribution of the work is made by offering access to copy -from a designated place, offer equivalent access to copy the above -specified materials from the same place. - -e) Verify that the user has already received a copy of these -materials or that you have already sent this user a copy. - -For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - -It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - -7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - -a) Accompany the combined library with a copy of the same work -based on the Library, uncombined with any other library -facilities. This must be distributed under the terms of the -Sections above. - -b) Give prominent notice with the combined library of the fact -that part of it is a work based on the Library, and explaining -where to find the accompanying uncombined form of the same work. - -8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - -9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - -10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - -11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - -12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - -13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - -14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - -NO WARRANTY - -15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - -16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - -END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/thirdparty/Signer/licensedata.json b/thirdparty/Signer/licensedata.json deleted file mode 100644 index 2db570660..000000000 --- a/thirdparty/Signer/licensedata.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "Signer", - "description": "A tool for signing assemblies", - "link": "https://github.com/mtrojnar/osslsigncode/", - "license": "LGPL", - "notes": "Not distributed, only used to sign assemblies" -}