diff --git a/Duplicati/Library/Main/Database/LocalRestoreDatabase.cs b/Duplicati/Library/Main/Database/LocalRestoreDatabase.cs index 853b38cea..80b052983 100644 --- a/Duplicati/Library/Main/Database/LocalRestoreDatabase.cs +++ b/Duplicati/Library/Main/Database/LocalRestoreDatabase.cs @@ -229,8 +229,7 @@ namespace Duplicati.Library.Main.Database public void UpdateTargetPath(long ID, string newname) { using (var cmd = m_connection.CreateCommand()) - cmd.ExecuteNonQuery(string.Format(@"UPDATE ""{0}"" SET ""TargetPath"" = ? WHERE ""FileID"" = ?", m_tempfiletable), newname, ID); - + cmd.ExecuteNonQuery(string.Format(@"UPDATE ""{0}"" SET ""TargetPath"" = ? WHERE ""ID"" = ?", m_tempfiletable), newname, ID); } public interface IExistingFileBlock diff --git a/Duplicati/Library/Main/Operation/RestoreHandler.cs b/Duplicati/Library/Main/Operation/RestoreHandler.cs index 722a1f04c..e21d55587 100644 --- a/Duplicati/Library/Main/Operation/RestoreHandler.cs +++ b/Duplicati/Library/Main/Operation/RestoreHandler.cs @@ -640,17 +640,19 @@ namespace Duplicati.Library.Main.Operation if (rename) { //Select a new filename - var ext = System.IO.Path.GetExtension(targetpath); - if (ext != null && !ext.StartsWith(".")) + var ext = System.IO.Path.GetExtension(targetpath) ?? ""; + if (!string.IsNullOrEmpty(ext) && !ext.StartsWith(".")) ext = "." + ext; // First we try with a simple date append, assuming that there are not many conflicts there - var newname = System.IO.Path.GetFileNameWithoutExtension(targetpath) + "." + database.RestoreTime.ToLocalTime().ToString("yyyy-mm-dd") + ext; + var newname = System.IO.Path.ChangeExtension(targetpath, null) + "."; + newname += database.RestoreTime.ToLocalTime().ToString("yyyy-mm-dd"); + newname += ext; // If that file exists, go to full timestamp if (System.IO.File.Exists(newname)) { - newname = System.IO.Path.GetFileNameWithoutExtension(targetpath) + "." + database.RestoreTime.ToLocalTime().ToString("yyyymmddThhMMss"); + newname = System.IO.Path.ChangeExtension(targetpath, null) + "." + database.RestoreTime.ToLocalTime().ToString("yyyymmddThhMMss"); var tr = newname + ext; var c = 0; while (System.IO.File.Exists(tr) && c < 1000)