aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2022-09-28 10:37:49 -0500
committerJP Dillingham <jp@dillingham.me>2022-09-28 10:37:49 -0500
commit5e0fd03418b9093b0a8c2fce7f8cce8010defc87 (patch)
tree3f6a4181dcd67220fa431e795a85cf99dda24cd4 /src
parent1d4a478aa2b52a042592bca506b629ca249f9f63 (diff)
downloadslskd-5e0fd03418b9093b0a8c2fce7f8cce8010defc87.tar.gz
rename SharedFileCache to ShareScanner
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Shares/ShareScanner.cs (renamed from src/slskd/Shares/SharedFileCache.cs)21
-rw-r--r--src/slskd/Shares/ShareService.cs16
2 files changed, 18 insertions, 19 deletions
diff --git a/src/slskd/Shares/SharedFileCache.cs b/src/slskd/Shares/ShareScanner.cs
index 93a7da59..01ccf4a1 100644
--- a/src/slskd/Shares/SharedFileCache.cs
+++ b/src/slskd/Shares/ShareScanner.cs
@@ -1,4 +1,4 @@
-// <copyright file="SharedFileCache.cs" company="slskd Team">
+// <copyright file="ShareScanner.cs" company="slskd Team">
// Copyright (c) slskd Team. All rights reserved.
//
// This program is free software: you can redistribute it and/or modify
@@ -28,13 +28,12 @@ namespace slskd.Shares
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
- using Microsoft.Data.Sqlite;
using Serilog;
/// <summary>
/// Shared file cache.
/// </summary>
- public interface ISharedFileCache
+ public interface IShareScanner
{
/// <summary>
/// Gets the cache state monitor.
@@ -47,13 +46,13 @@ namespace slskd.Shares
/// <param name="shares">The list of shares from which to fill the cache.</param>
/// <param name="filters">The list of regular expressions used to exclude files or paths from scanning.</param>
/// <returns>The operation context.</returns>
- Task FillAsync(IEnumerable<Share> shares, IEnumerable<Regex> filters);
+ Task ScanAsync(IEnumerable<Share> shares, IEnumerable<Regex> filters);
/// <summary>
/// Cancels the currently running fill operation, if one is running.
/// </summary>
/// <returns>A value indicating whether a fill operation was cancelled.</returns>
- bool TryCancelFill();
+ bool TryCancelScan();
/// <summary>
/// Attempts to load the cache from disk.
@@ -65,15 +64,15 @@ namespace slskd.Shares
/// <summary>
/// Shared file cache.
/// </summary>
- public class SharedFileCache : ISharedFileCache
+ public class ShareScanner : IShareScanner
{
/// <summary>
- /// Initializes a new instance of the <see cref="SharedFileCache"/> class.
+ /// Initializes a new instance of the <see cref="ShareScanner"/> class.
/// </summary>
/// <param name="storageMode"></param>
/// <param name="workerCount"></param>
/// <param name="soulseekFileFactory"></param>
- public SharedFileCache(StorageMode storageMode, int workerCount, ISoulseekFileFactory soulseekFileFactory = null)
+ public ShareScanner(StorageMode storageMode, int workerCount, ISoulseekFileFactory soulseekFileFactory = null)
{
StorageMode = storageMode;
WorkerCount = workerCount;
@@ -88,7 +87,7 @@ namespace slskd.Shares
private StorageMode StorageMode { get; }
private int WorkerCount { get; }
- private ILogger Log { get; } = Serilog.Log.ForContext<SharedFileCache>();
+ private ILogger Log { get; } = Serilog.Log.ForContext<ShareScanner>();
private List<Share> Shares { get; set; }
private ISoulseekFileFactory SoulseekFileFactory { get; }
private IManagedState<SharedFileCacheState> State { get; } = new ManagedState<SharedFileCacheState>();
@@ -102,7 +101,7 @@ namespace slskd.Shares
/// <param name="shares">The list of shares from which to fill the cache.</param>
/// <param name="filters">The list of regular expressions used to exclude files or paths from scanning.</param>
/// <returns>The operation context.</returns>
- public async Task FillAsync(IEnumerable<Share> shares, IEnumerable<Regex> filters)
+ public async Task ScanAsync(IEnumerable<Share> shares, IEnumerable<Regex> filters)
{
// obtain the semaphore, or fail if it can't be obtained immediately, indicating that a scan is running.
if (!await SyncRoot.WaitAsync(millisecondsTimeout: 0))
@@ -360,7 +359,7 @@ namespace slskd.Shares
/// Cancels the currently running fill operation, if one is running.
/// </summary>
/// <returns>A value indicating whether a fill operation was cancelled.</returns>
- public bool TryCancelFill()
+ public bool TryCancelScan()
{
if (CancellationTokenSource != null)
{
diff --git a/src/slskd/Shares/ShareService.cs b/src/slskd/Shares/ShareService.cs
index a0acdda1..decafaa3 100644
--- a/src/slskd/Shares/ShareService.cs
+++ b/src/slskd/Shares/ShareService.cs
@@ -37,16 +37,16 @@ namespace slskd.Shares
/// Initializes a new instance of the <see cref="ShareService"/> class.
/// </summary>
/// <param name="optionsMonitor"></param>
- /// <param name="sharedFileCache"></param>
+ /// <param name="scanner"></param>
public ShareService(
IOptionsMonitor<Options> optionsMonitor,
- ISharedFileCache sharedFileCache = null)
+ IShareScanner scanner = null)
{
- Cache = sharedFileCache ?? new SharedFileCache(
+ Scanner = scanner ?? new ShareScanner(
storageMode: optionsMonitor.CurrentValue.Shares.Cache.StorageMode.ToEnum<StorageMode>(),
workerCount: optionsMonitor.CurrentValue.Shares.Cache.Workers);
- Cache.StateMonitor.OnChange(cacheState =>
+ Scanner.StateMonitor.OnChange(cacheState =>
{
var (previous, current) = cacheState;
@@ -82,7 +82,7 @@ namespace slskd.Shares
/// </summary>
public IStateMonitor<ShareState> StateMonitor => State;
- private ISharedFileCache Cache { get; }
+ private IShareScanner Scanner { get; }
private IShareRepository Repository { get; }
private string LastOptionsHash { get; set; }
private IOptionsMonitor<Options> OptionsMonitor { get; }
@@ -211,7 +211,7 @@ namespace slskd.Shares
/// <exception cref="ShareScanInProgressException">Thrown when a scan is already in progress.</exception>
public Task ScanAsync()
{
- return Cache.FillAsync(Shares, FilterRegexes);
+ return Scanner.ScanAsync(Shares, FilterRegexes);
}
/// <summary>
@@ -234,7 +234,7 @@ namespace slskd.Shares
/// <returns>A value indicating whether a scan was cancelled.</returns>
public bool TryCancelScan()
{
- return Cache.TryCancelFill();
+ return Scanner.TryCancelScan();
}
/// <summary>
@@ -243,7 +243,7 @@ namespace slskd.Shares
/// <returns>A value indicating whether shares were loaded.</returns>
public Task<bool> TryLoadFromDiskAsync()
{
- return Task.FromResult(Cache.TryLoad());
+ return Task.FromResult(Scanner.TryLoad());
}
private void Configure(Options options)