diff options
| author | JP Dillingham <jp@dillingham.me> | 2022-09-24 12:43:36 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2022-09-24 12:43:36 -0500 |
| commit | 1f42f7c52862472e381dc46d8c70c23d1b017468 (patch) | |
| tree | c8d2d1e08966695796358d61a939182d56374dbf /src | |
| parent | d3009fbb67f76337949faa99cd7180d23451f8ca (diff) | |
| download | slskd-1f42f7c52862472e381dc46d8c70c23d1b017468.tar.gz | |
add sync/async overloads, TryCancelScan
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Shares/IShareService.cs | 13 | ||||
| -rw-r--r-- | src/slskd/Shares/ShareService.cs | 21 |
2 files changed, 33 insertions, 1 deletions
diff --git a/src/slskd/Shares/IShareService.cs b/src/slskd/Shares/IShareService.cs index 962d4c1e..12603283 100644 --- a/src/slskd/Shares/IShareService.cs +++ b/src/slskd/Shares/IShareService.cs @@ -70,6 +70,13 @@ namespace slskd.Shares Task<IEnumerable<File>> SearchAsync(SearchQuery query); /// <summary> + /// Scans the configured shares. + /// </summary> + /// <returns>The operation context.</returns> + /// <exception cref="ShareScanInProgressException">Thrown when a scan is already in progress.</exception> + Task ScanAsync(); + + /// <summary> /// Starts a scan of the configured shares. /// </summary> /// <returns>The operation context.</returns> @@ -77,6 +84,12 @@ namespace slskd.Shares Task StartScanAsync(); /// <summary> + /// Cancels the currently running scan, if one is running. + /// </summary> + /// <returns>A value indicating whether a scan was cancelled.</returns> + bool TryCancelScan(); + + /// <summary> /// Attempt to load shares from disk. /// </summary> /// <returns>A value indicating whether shares were loaded.</returns> diff --git a/src/slskd/Shares/ShareService.cs b/src/slskd/Shares/ShareService.cs index 96ac4c1c..72a0fea6 100644 --- a/src/slskd/Shares/ShareService.cs +++ b/src/slskd/Shares/ShareService.cs @@ -159,13 +159,32 @@ namespace slskd.Shares } /// <summary> + /// Scans the configured shares. + /// </summary> + /// <returns>The operation context.</returns> + /// <exception cref="ShareScanInProgressException">Thrown when a scan is already in progress.</exception> + public Task ScanAsync() + { + return Cache.FillAsync(Shares, FilterRegexes); + } + + /// <summary> /// Starts a scan of the configured shares. /// </summary> /// <returns>The operation context.</returns> /// <exception cref="ShareScanInProgressException">Thrown when a scan is already in progress.</exception> public Task StartScanAsync() { - return Cache.FillAsync(Shares, FilterRegexes); + return Cache.StartFillAsync(Shares, FilterRegexes); + } + + /// <summary> + /// Cancels the currently running scan, if one is running. + /// </summary> + /// <returns>A value indicating whether a scan was cancelled.</returns> + public bool TryCancelScan() + { + return Cache.TryCancelFill(); } /// <summary> |
