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/IReadWriteShareRepository.cs | 96 +++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 src/slskd/Shares/IReadWriteShareRepository.cs (limited to 'src/slskd/Shares/IReadWriteShareRepository.cs') diff --git a/src/slskd/Shares/IReadWriteShareRepository.cs b/src/slskd/Shares/IReadWriteShareRepository.cs new file mode 100644 index 00000000..c6701753 --- /dev/null +++ b/src/slskd/Shares/IReadWriteShareRepository.cs @@ -0,0 +1,96 @@ +// +// Copyright (c) slskd Team. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see https://www.gnu.org/licenses/. +// + +namespace slskd.Shares +{ + using System; + using Soulseek; + + /// + /// Writeable persistent storage of shared files and metadata. + /// + public interface IReadWriteShareRepository : IShareRepository + { + + /// + /// Creates a new database. + /// + /// + /// 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); + + /// + /// Inserts a directory. + /// + /// The fully qualified local name of the directory. + /// The timestamp to assign to the record. + void InsertDirectory(string name, long timestamp); + + /// + /// Inserts a file. + /// + /// 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); + + /// + /// Inserts a scan record at 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); + + /// + /// Restores the current database from the database at the specified . + /// + /// The connection string of the source database. + void RestoreFrom(string connectionString); + + /// + /// Deletes directory records with a timestamp prior to the specified . + /// + /// The timestamp before which to delete directories. + /// The number of records deleted. + long PruneDirectories(long olderThanTimestamp); + + /// + /// Deletes file records with a timestamp prior to the specified . + /// + /// The timestamp before which to delete files. + /// The number of records deleted. + long PruneFiles(long olderThanTimestamp); + + /// + /// Updates the scan started at the specified to set the . + /// + /// The timestamp associated with the scan. + /// The timestamp at the conclusion of the scan. + void UpdateScan(long timestamp, long end); + } +} \ No newline at end of file -- cgit v1.2.3