Fixed two deprecation issues in USNJournal

This commit is contained in:
Kenneth Skovhede
2024-09-10 08:57:38 +02:00
parent 721c4abe74
commit 092e28811b
+24 -30
View File
@@ -1,23 +1,23 @@
// 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.
// 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 System;
@@ -27,9 +27,7 @@ using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using Duplicati.Library.Common;
using Duplicati.Library.Common.IO;
using Microsoft.Win32.SafeHandles;
@@ -286,7 +284,7 @@ namespace Duplicati.Library.Snapshots
if (m_offset >= m_entryData.Count)
return false;
var entry = GetBufferedEntry(m_bufferPointer, m_offset, out var fileName);
Current = new Record(entry, fileName);
m_offset += entry.RecordLength;
@@ -384,7 +382,7 @@ namespace Duplicati.Library.Snapshots
records.AddRange(EnumerateRecords(entryData)
.TakeWhile(rec => rec.UsnRecord.Usn < m_journal.NextUsn)
.Where(rec => rec.UsnRecord.Usn >= startUsn && (inclusionPredicate == null || inclusionPredicate(rec))));
readData.StartUsn = Marshal.ReadInt64(entryData, 0);
readData.StartUsn = BitConverter.ToInt64(entryData, 0);
}
return records;
@@ -410,7 +408,7 @@ namespace Duplicati.Library.Snapshots
ref enumData, bufferSize, out entryData))
{
var e = Marshal.GetLastWin32Error();
if (e != Win32USN.ERROR_INSUFFICIENT_BUFFER)
if (e != Win32USN.ERROR_INSUFFICIENT_BUFFER)
return null;
// retry, increasing buffer size
@@ -651,7 +649,7 @@ namespace Duplicati.Library.Snapshots
Sort();
// perform binary search
int index = m_records.BinarySearch(usnRecord,
int index = m_records.BinarySearch(usnRecord,
Comparer<Record>.Create(
(left, right) =>
{
@@ -720,9 +718,5 @@ namespace Duplicati.Library.Snapshots
public UsnJournalSoftFailureException(string message, Exception innerException) : base(message, innerException)
{
}
protected UsnJournalSoftFailureException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}