checkpoint
This commit is contained in:
@@ -1,17 +1,29 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.ConstrainedExecution;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Foodsoft.Alpm
|
||||
{
|
||||
internal sealed class SafeCachePackageHandle : SafePackageHandle
|
||||
{
|
||||
internal SafeAlpmHandle SafeAlpmHandle => SafeDatabaseHandle.SafeAlpmHandle;
|
||||
internal SafeDatabaseHandle SafeDatabaseHandle { get; } = null!;
|
||||
internal SafeAlpmHandle SafeAlpmHandle
|
||||
{
|
||||
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
|
||||
[PrePrepareMethod]
|
||||
get => SafeDatabaseHandle.SafeAlpmHandle;
|
||||
}
|
||||
|
||||
internal SafeDatabaseHandle SafeDatabaseHandle
|
||||
{
|
||||
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
|
||||
[PrePrepareMethod]
|
||||
get;
|
||||
} = null!;
|
||||
|
||||
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
|
||||
[PrePrepareMethod]
|
||||
internal SafeCachePackageHandle(IntPtr ptr, SafeDatabaseHandle dbHandle)
|
||||
internal SafeCachePackageHandle(IntPtr ptr, SafeDatabaseHandle parentHandle)
|
||||
: base()
|
||||
{
|
||||
var success = false;
|
||||
@@ -20,10 +32,10 @@ namespace Foodsoft.Alpm
|
||||
try { }
|
||||
finally
|
||||
{
|
||||
dbHandle.DangerousAddRef(ref success);
|
||||
parentHandle.DangerousAddRef(ref success);
|
||||
if (success)
|
||||
{
|
||||
SafeDatabaseHandle = dbHandle;
|
||||
SafeDatabaseHandle = parentHandle;
|
||||
handle = ptr;
|
||||
}
|
||||
}
|
||||
@@ -36,11 +48,5 @@ namespace Foodsoft.Alpm
|
||||
SafeDatabaseHandle.DangerousRelease();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool IsInvalid
|
||||
{
|
||||
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success), PrePrepareMethod]
|
||||
get => handle == IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user