From 4c294ea5d8f06384246728b998207c25e35c42e3 Mon Sep 17 00:00:00 2001 From: Carl Johnsen Date: Tue, 13 May 2025 16:16:06 +0200 Subject: [PATCH] Fix docstrings in ReusableTransaction --- .../Main/Database/ReusableTransaction.cs | 41 +++++++++++++++---- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/Duplicati/Library/Main/Database/ReusableTransaction.cs b/Duplicati/Library/Main/Database/ReusableTransaction.cs index 51c09ba42..7052b1a6f 100644 --- a/Duplicati/Library/Main/Database/ReusableTransaction.cs +++ b/Duplicati/Library/Main/Database/ReusableTransaction.cs @@ -29,43 +29,59 @@ using Microsoft.Data.Sqlite; namespace Duplicati.Library.Main.Database; /// -/// Wraps a transaction so it can be comitted and restarted +/// Wraps a transaction so it can be comitted and restarted. /// +/// +/// Creates a new reusable transaction. +/// +/// The database to use. +/// The transaction to use. If null, a new transaction is created. internal class ReusableTransaction(LocalDatabase db, SqliteTransaction? transaction = null) : IDisposable { /// - /// The tag used for logging + /// The tag used for logging. /// private static readonly string LOGTAG = Logging.Log.LogTagFromType(typeof(ReusableTransaction)); /// - /// The database to use + /// The database to use. /// private readonly LocalDatabase m_db = db; /// - /// The current transaction + /// The current transaction. /// private SqliteTransaction m_transaction = transaction ?? db.Connection.BeginTransaction(); /// - /// Creates a new reusable transaction + /// True if the transaction is disposed. /// private bool m_disposed = false; /// - /// The current transaction + /// The current transaction. /// public SqliteTransaction Transaction => m_disposed ? m_transaction : throw new InvalidOperationException("Transaction is disposed"); /// - /// Commits the current transaction and optionally restarts it + /// Commits the current transaction and optionally restarts it. /// - /// The log message to use - /// True if the transaction should be restarted + /// + /// Calls the Async version of this method and awaits it. + /// + /// The log message to use. + /// True if the transaction should be restarted. + /// If the transaction is already Disposed. public void Commit(string? message, bool restart = true) { CommitAsync(message, restart).Await(); } + /// + /// Async version of Commit: + /// + /// The log message to use. + /// True if the transaction should be restarted. + /// An awaitable task. + /// If the transaction is already Disposed. public async Task CommitAsync(string? message, bool restart = true) { if (m_disposed) @@ -82,11 +98,18 @@ internal class ReusableTransaction(LocalDatabase db, SqliteTransaction? transact } /// + /// + /// Calls the Async version of this method and awaits it. + /// public void Dispose() { DisposeAsync().Await(); } + /// + /// Async version of Dispose: + /// + /// An awaitable task. public async Task DisposeAsync() { if (!m_disposed)