// Copyright (C) 2026, 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;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
#nullable enable
namespace Duplicati.Library.Main.Database;
///
/// Interface for database operations used by the backend manager.
///
internal interface IBackendManagerDatabase
{
///
/// Logs a remote operation performed on the backend.
///
/// The operation performed.
/// The path involved.
/// Any data relating to the operation.
/// Cancellation token to monitor for cancellation requests.
/// A task that completes when the operation log has been recorded.
Task LogRemoteOperationAsync(string operation, string path, string? data, CancellationToken cancellationToken);
///
/// Updates the state of a remote volume in the database.
///
/// The name of the remote volume to update.
/// The new state of the remote volume.
/// The size of the remote volume in bytes.
/// The hash of the remote volume, or null if not applicable.
/// Cancellation token to monitor for cancellation requests.
/// A task that completes when the remote volume has been updated.
Task UpdateRemoteVolumeAsync(string name, RemoteVolumeState state, long size, string? hash, CancellationToken cancellationToken);
///
/// Updates the state of a remote volume in the database.
///
/// The name of the remote volume to update.
/// The new state of the remote volume.
/// The size of the remote volume in bytes.
/// The hash of the remote volume, or null if not applicable.
/// If true, suppresses cleanup of the remote volume after updating.
/// The time after which the remote volume can be deleted.
/// If true, sets the remote volume as archived.
/// Cancellation token to monitor for cancellation requests.
/// A task that completes when the remote volume has been updated.
Task UpdateRemoteVolumeAsync(string name, RemoteVolumeState state, long size, string? hash, bool suppressCleanup, TimeSpan deleteGraceTime, bool? setArchived, CancellationToken cancellationToken);
///
/// Renames a remote file in the database, preserving its ID links.
///
/// The current name of the remote file.
/// The new name for the remote file.
/// Cancellation token to monitor for cancellation requests.
/// A task that completes when the renaming operation is finished.
Task RenameRemoteFileAsync(string oldname, string newname, CancellationToken cancellationToken);
///
/// Removes multiple remote volumes from the database.
///
/// An enumerable collection of names of remote volumes to remove.
/// Cancellation token to monitor for cancellation requests.
/// A task that completes when the remote volumes have been removed.
Task RemoveRemoteVolumesAsync(IEnumerable names, CancellationToken cancellationToken);
///
/// Commits the current transaction.
///
/// Cancellation token to monitor for cancellation requests.
/// A task that completes when the transaction has been committed.
Task CommitAsync(CancellationToken cancellationToken);
}