diff --git a/Duplicati/Library/Main/Database/LocalRestoreDatabase.cs b/Duplicati/Library/Main/Database/LocalRestoreDatabase.cs index ba9848873..8f9e21224 100644 --- a/Duplicati/Library/Main/Database/LocalRestoreDatabase.cs +++ b/Duplicati/Library/Main/Database/LocalRestoreDatabase.cs @@ -1067,8 +1067,8 @@ namespace Duplicati.Library.Main.Database m_hasUpdates = true; m_updateFileAsDataVerifiedCommand.SetParameterValue(0, targetfileid); var r = m_updateFileAsDataVerifiedCommand.ExecuteNonQuery(); - if (r <= 0) - throw new Exception("Unexpected reset result"); + if (r != 1) + throw new Exception("Unexpected result when marking file as verified."); } public void SetBlockRestored(long targetfileid, long index, string hash, long size, bool metadata) diff --git a/Duplicati/Library/Main/Operation/RestoreHandler.cs b/Duplicati/Library/Main/Operation/RestoreHandler.cs index 8726eb022..0a5228bbe 100644 --- a/Duplicati/Library/Main/Operation/RestoreHandler.cs +++ b/Duplicati/Library/Main/Operation/RestoreHandler.cs @@ -921,15 +921,23 @@ namespace Duplicati.Library.Main.Operation var currentAttr = m_systemIO.GetFileAttributes(targetpath); if ((currentAttr & System.IO.FileAttributes.ReadOnly) != 0) { // clear readonly attribute - if ((currentfilelength > restorelist.Length) || !fullfilehashmatch) - m_systemIO.SetFileAttributes(targetpath, currentAttr & ~System.IO.FileAttributes.ReadOnly); + if ((currentfilelength > targetfilelength) || !fullfilehashmatch) + { + if (options.Dryrun) + result.AddDryrunMessage(string.Format("Would reset read-only attribute on file: {0}", targetpath)); + else + m_systemIO.SetFileAttributes(targetpath, currentAttr & ~System.IO.FileAttributes.ReadOnly); + } } // Adjust file length if necessary (smaller is ok, will be extended during restore) if (currentfilelength > targetfilelength) { - using (var file = m_systemIO.FileOpenWrite(targetpath)) - file.SetLength(targetfilelength); + if (options.Dryrun) + result.AddDryrunMessage(string.Format("Would truncate file '{0}' to length of {1:N0} bytes", targetpath, targetfilelength)); + else + using (var file = m_systemIO.FileOpenWrite(targetpath)) + file.SetLength(targetfilelength); } }