From 43c19eac0b258c852fc10d017daf1ee010f8cdcc Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Thu, 13 Oct 2022 09:43:17 -0500 Subject: differentiate read and read/write repositories. add host collection --- src/slskd/Shares/IShareRepository.cs | 83 ++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 47 deletions(-) (limited to 'src/slskd/Shares/IShareRepository.cs') 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; /// - /// Writeable persistent storage of shared files and metadata. + /// Persistent storage of shared files and metadata. /// - public interface IShareRepository : IReadOnlyShareRepository + public interface IShareRepository { /// - /// Creates a new database. + /// Gets the connection string for this repository. /// - /// - /// Creates tables using 'IF NOT EXISTS', so this is idempotent unless 'discardExisting` is specified, in which case - /// tables are explicitly dropped prior to creation. - /// - /// An optional value that determines whether the existing database should be discarded. - void Create(bool discardExisting = false); + string ConnectionString { get; } /// - /// Inserts a directory. + /// Counts the number of directories in the database. /// - /// The fully qualified local name of the directory. - /// The timestamp to assign to the record. - void InsertDirectory(string name, long timestamp); + /// The optional directory prefix used for counting subdirectories. + /// The number of directories. + int CountDirectories(string parentDirectory = null); /// - /// Inserts a file. + /// Counts the number of files in the database. /// - /// The fully qualified remote path of the file. - /// The fully qualified local path of the file. - /// The timestamp at which the file was last modified, according to the host OS. - /// The Soulseek.File instance representing the file. - /// The timestamp to assign to the record. - void InsertFile(string maskedFilename, string originalFilename, DateTime touchedAt, File file, long timestamp); + /// The optional directory prefix used for counting files in a subdirectory. + /// The number of files. + int CountFiles(string parentDirectory = null); /// - /// Inserts a scan record at the specified . + /// Finds the filename of the file matching the specified . /// - /// The timestamp associated with the scan. - /// The options snapshot at the start of the scan. - void InsertScan(long timestamp, Options.SharesOptions options); - - /// - /// Backs the current database up to the database at the specified . - /// - /// The connection string of the destination database. - void BackupTo(string connectionString); + /// The fully qualified remote path of the file. + /// The filename, if found. + string FindFilename(string maskedFilename); /// - /// Restores the current database from the database at the specified . + /// Lists all directories. /// - /// The connection string of the source database. - void RestoreFrom(string connectionString); + /// The optional directory prefix used for listing subdirectories. + /// The list of directories. + IEnumerable ListDirectories(string parentDirectory = null); /// - /// Deletes directory records with a timestamp prior to the specified . + /// Lists all files. /// - /// The timestamp before which to delete directories. - /// The number of records deleted. - long PruneDirectories(long olderThanTimestamp); + /// The optional parent directory. + /// A value indicating whether the fully qualified path should be returned. + /// The list of files. + IEnumerable ListFiles(string parentDirectory = null, bool includeFullPath = false); /// - /// Deletes file records with a timestamp prior to the specified . + /// Searches the database for files matching the specified . /// - /// The timestamp before which to delete files. - /// The number of records deleted. - long PruneFiles(long olderThanTimestamp); + /// The search query. + /// The list of matching files. + IEnumerable Search(SearchQuery query); /// - /// Updates the scan started at the specified to set the . + /// Attempts to validate the database at the specified , or the + /// default . /// - /// The timestamp associated with the scan. - /// The timestamp at the conclusion of the scan. - void UpdateScan(long timestamp, long end); + /// The connection string of the database to validate. + /// A value indicating whether the database is valid. + bool TryValidate(string connectionString = null); } -} \ No newline at end of file +} -- cgit v1.2.3