aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Shares/IShareRepository.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/slskd/Shares/IShareRepository.cs')
-rw-r--r--src/slskd/Shares/IShareRepository.cs83
1 files changed, 36 insertions, 47 deletions
diff --git a/src/slskd/Shares/IShareRepository.cs b/src/slskd/Shares/IShareRepository.cs
index 59c9537e..87c2c386 100644
--- a/src/slskd/Shares/IShareRepository.cs
+++ b/src/slskd/Shares/IShareRepository.cs
@@ -17,79 +17,68 @@
namespace slskd.Shares
{
- using System;
+ using System.Collections.Generic;
using Soulseek;
/// <summary>
- /// Writeable persistent storage of shared files and metadata.
+ /// Persistent storage of shared files and metadata.
/// </summary>
- public interface IShareRepository : IReadOnlyShareRepository
+ public interface IShareRepository
{
/// <summary>
- /// Creates a new database.
+ /// Gets the connection string for this repository.
/// </summary>
- /// <remarks>
- /// Creates tables using 'IF NOT EXISTS', so this is idempotent unless 'discardExisting` is specified, in which case
- /// tables are explicitly dropped prior to creation.
- /// </remarks>
- /// <param name="discardExisting">An optional value that determines whether the existing database should be discarded.</param>
- void Create(bool discardExisting = false);
+ string ConnectionString { get; }
/// <summary>
- /// Inserts a directory.
+ /// Counts the number of directories in the database.
/// </summary>
- /// <param name="name">The fully qualified local name of the directory.</param>
- /// <param name="timestamp">The timestamp to assign to the record.</param>
- void InsertDirectory(string name, long timestamp);
+ /// <param name="parentDirectory">The optional directory prefix used for counting subdirectories.</param>
+ /// <returns>The number of directories.</returns>
+ int CountDirectories(string parentDirectory = null);
/// <summary>
- /// Inserts a file.
+ /// Counts the number of files in the database.
/// </summary>
- /// <param name="maskedFilename">The fully qualified remote path of the file.</param>
- /// <param name="originalFilename">The fully qualified local path of the file.</param>
- /// <param name="touchedAt">The timestamp at which the file was last modified, according to the host OS.</param>
- /// <param name="file">The Soulseek.File instance representing the file.</param>
- /// <param name="timestamp">The timestamp to assign to the record.</param>
- void InsertFile(string maskedFilename, string originalFilename, DateTime touchedAt, File file, long timestamp);
+ /// <param name="parentDirectory">The optional directory prefix used for counting files in a subdirectory.</param>
+ /// <returns>The number of files.</returns>
+ int CountFiles(string parentDirectory = null);
/// <summary>
- /// Inserts a scan record at the specified <paramref name="timestamp"/>.
+ /// Finds the filename of the file matching the specified <paramref name="maskedFilename"/>.
/// </summary>
- /// <param name="timestamp">The timestamp associated with the scan.</param>
- /// <param name="options">The options snapshot at the start of the scan.</param>
- void InsertScan(long timestamp, Options.SharesOptions options);
-
- /// <summary>
- /// Backs the current database up to the database at the specified <paramref name="connectionString"/>.
- /// </summary>
- /// <param name="connectionString">The connection string of the destination database.</param>
- void BackupTo(string connectionString);
+ /// <param name="maskedFilename">The fully qualified remote path of the file.</param>
+ /// <returns>The filename, if found.</returns>
+ string FindFilename(string maskedFilename);
/// <summary>
- /// Restores the current database from the database at the specified <paramref name="connectionString"/>.
+ /// Lists all directories.
/// </summary>
- /// <param name="connectionString">The connection string of the source database.</param>
- void RestoreFrom(string connectionString);
+ /// <param name="parentDirectory">The optional directory prefix used for listing subdirectories.</param>
+ /// <returns>The list of directories.</returns>
+ IEnumerable<string> ListDirectories(string parentDirectory = null);
/// <summary>
- /// Deletes directory records with a timestamp prior to the specified <paramref name="olderThanTimestamp"/>.
+ /// Lists all files.
/// </summary>
- /// <param name="olderThanTimestamp">The timestamp before which to delete directories.</param>
- /// <returns>The number of records deleted.</returns>
- long PruneDirectories(long olderThanTimestamp);
+ /// <param name="parentDirectory">The optional parent directory.</param>
+ /// <param name="includeFullPath">A value indicating whether the fully qualified path should be returned.</param>
+ /// <returns>The list of files.</returns>
+ IEnumerable<File> ListFiles(string parentDirectory = null, bool includeFullPath = false);
/// <summary>
- /// Deletes file records with a timestamp prior to the specified <paramref name="olderThanTimestamp"/>.
+ /// Searches the database for files matching the specified <paramref name="query"/>.
/// </summary>
- /// <param name="olderThanTimestamp">The timestamp before which to delete files.</param>
- /// <returns>The number of records deleted.</returns>
- long PruneFiles(long olderThanTimestamp);
+ /// <param name="query">The search query.</param>
+ /// <returns>The list of matching files.</returns>
+ IEnumerable<File> Search(SearchQuery query);
/// <summary>
- /// Updates the scan started at the specified <paramref name="timestamp"/> to set the <paramref name="end"/>.
+ /// Attempts to validate the database at the specified <paramref name="connectionString"/>, or the
+ /// default <see cref="ConnectionString"/>.
/// </summary>
- /// <param name="timestamp">The timestamp associated with the scan.</param>
- /// <param name="end">The timestamp at the conclusion of the scan.</param>
- void UpdateScan(long timestamp, long end);
+ /// <param name="connectionString">The connection string of the database to validate.</param>
+ /// <returns>A value indicating whether the database is valid.</returns>
+ bool TryValidate(string connectionString = null);
}
-} \ No newline at end of file
+}