diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Shares/IShareRepository.cs | 3 | ||||
| -rw-r--r-- | src/slskd/Shares/IShareService.cs | 3 | ||||
| -rw-r--r-- | src/slskd/Shares/ShareService.cs | 3 | ||||
| -rw-r--r-- | src/slskd/Shares/SqliteShareRepository.cs | 5 |
4 files changed, 9 insertions, 5 deletions
diff --git a/src/slskd/Shares/IShareRepository.cs b/src/slskd/Shares/IShareRepository.cs index 1ccfeb22..cb6830d6 100644 --- a/src/slskd/Shares/IShareRepository.cs +++ b/src/slskd/Shares/IShareRepository.cs @@ -167,8 +167,9 @@ namespace slskd.Shares /// Searches the database for files matching the specified <paramref name="query"/>. /// </summary> /// <param name="query">The search query.</param> + /// <param name="limit">An optional row limit.</param> /// <returns>The list of matching files.</returns> - IEnumerable<File> Search(SearchQuery query); + IEnumerable<File> Search(SearchQuery query, int? limit = null); /// <summary> /// Attempts to validate the backing database. diff --git a/src/slskd/Shares/IShareService.cs b/src/slskd/Shares/IShareService.cs index 7db9671b..3b379c98 100644 --- a/src/slskd/Shares/IShareService.cs +++ b/src/slskd/Shares/IShareService.cs @@ -109,8 +109,9 @@ namespace slskd.Shares /// Searches the cache for the specified <paramref name="query"/> and returns the matching files. /// </summary> /// <param name="query">The query for which to search.</param> + /// <param name="limit">An optional row limit.</param> /// <returns>The matching files.</returns> - Task<IEnumerable<File>> SearchAsync(SearchQuery query); + Task<IEnumerable<File>> SearchAsync(SearchQuery query, int? limit = null); /// <summary> /// Cancels the currently running scan on the local host, if one is running. diff --git a/src/slskd/Shares/ShareService.cs b/src/slskd/Shares/ShareService.cs index 6068a744..ee63f1bc 100644 --- a/src/slskd/Shares/ShareService.cs +++ b/src/slskd/Shares/ShareService.cs @@ -343,8 +343,9 @@ namespace slskd.Shares /// Searches the cache for the specified <paramref name="query"/> and returns the matching files. /// </summary> /// <param name="query">The query for which to search.</param> + /// <param name="limit">An optional row limit.</param> /// <returns>The matching files.</returns> - public Task<IEnumerable<File>> SearchAsync(SearchQuery query) + public Task<IEnumerable<File>> SearchAsync(SearchQuery query, int? limit = null) { var results = AllRepositories.SelectMany(r => r.Search(query)); diff --git a/src/slskd/Shares/SqliteShareRepository.cs b/src/slskd/Shares/SqliteShareRepository.cs index cb0c331a..1d4e6783 100644 --- a/src/slskd/Shares/SqliteShareRepository.cs +++ b/src/slskd/Shares/SqliteShareRepository.cs @@ -517,8 +517,9 @@ namespace slskd.Shares /// Searches the database for files matching the specified <paramref name="query"/>. /// </summary> /// <param name="query">The search query.</param> + /// <param name="limit">An optional row limit.</param> /// <returns>The list of matching files.</returns> - public IEnumerable<Soulseek.File> Search(SearchQuery query) + public IEnumerable<Soulseek.File> Search(SearchQuery query, int? limit = null) { string Clean(string str) => str.Replace("/", " ") .Replace("\\", " ") @@ -532,7 +533,7 @@ namespace slskd.Shares var sql = $"SELECT files.maskedFilename, files.code, files.size, files.extension, files.attributeJson FROM filenames " + "INNER JOIN files ON filenames.maskedFilename = files.maskedFilename " + $"WHERE filenames MATCH '({match}) {(query.Exclusions.Any() ? $"NOT ({exclusions})" : string.Empty)}' " + - "ORDER BY filenames.maskedFilename ASC;"; + $"ORDER BY filenames.maskedFilename ASC {(limit.HasValue ? $"LIMIT {limit.Value}" : string.Empty)};"; var results = new List<Soulseek.File>(); |
