From 57a89f124d168e58adeea6b53ce1a0658e80de90 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 23 Sep 2022 08:48:14 -0500 Subject: remove unused CancellationTokenSource --- src/slskd/Common/ChannelReader.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/slskd/Common/ChannelReader.cs b/src/slskd/Common/ChannelReader.cs index a6a8b9a3..daae4ad1 100644 --- a/src/slskd/Common/ChannelReader.cs +++ b/src/slskd/Common/ChannelReader.cs @@ -68,8 +68,7 @@ namespace slskd.Shares Handler = handler; ExceptionHandler = exceptionHandler; - CancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); - CancellationToken = CancellationTokenSource.Token; + CancellationToken = cancellationToken; if (automaticallyStart) { @@ -91,7 +90,6 @@ namespace slskd.Shares private Action Handler { get; } private Action ExceptionHandler { get; } private TaskCompletionSource TaskCompletionSource { get; } = new TaskCompletionSource(); - private CancellationTokenSource CancellationTokenSource { get; } private CancellationToken CancellationToken { get; } private object SyncRoot { get; } = new object(); @@ -114,7 +112,7 @@ namespace slskd.Shares { try { - while (!CancellationTokenSource.Token.IsCancellationRequested && !Channel.Reader.Completion.IsCompleted) + while (!Channel.Reader.Completion.IsCompleted) { var item = await Channel.Reader.ReadAsync(CancellationToken); Handler(item); -- cgit v1.2.3 From 48a4a58a2b81acca34ddf4925db16b04880eb746 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 23 Sep 2022 08:50:27 -0500 Subject: make channel local, handle OperationCanceledException --- src/slskd/Shares/SharedFileCache.cs | 44 ++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/slskd/Shares/SharedFileCache.cs b/src/slskd/Shares/SharedFileCache.cs index b9c09d7e..07dc6ba5 100644 --- a/src/slskd/Shares/SharedFileCache.cs +++ b/src/slskd/Shares/SharedFileCache.cs @@ -63,7 +63,6 @@ namespace slskd.Shares private ISoulseekFileFactory SoulseekFileFactory { get; } private IManagedState State { get; } = new ManagedState(); private SemaphoreSlim SyncRoot { get; } = new SemaphoreSlim(1); - private Channel DirectoryChannel { get; set; } /// /// Returns the contents of the cache. @@ -165,8 +164,6 @@ namespace slskd.Shares Log.Debug("Starting shared file scan"); - await Task.Yield(); - var timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); var sw = new Stopwatch(); @@ -230,7 +227,7 @@ namespace slskd.Shares var filtered = 0; // set up a channel to fan out for directory scanning - DirectoryChannel = Channel.CreateBounded(new BoundedChannelOptions(1000) + var channel = Channel.CreateBounded(new BoundedChannelOptions(1000) { AllowSynchronousContinuations = false, FullMode = BoundedChannelFullMode.Wait, @@ -244,7 +241,7 @@ namespace slskd.Shares foreach (var id in Enumerable.Range(0, WorkerCount)) { workers.Add(new ChannelReader( - channel: DirectoryChannel, + channel: channel, cancellationToken: cancellationToken, handler: (directory) => { @@ -319,39 +316,50 @@ namespace slskd.Shares Log.Debug("Filling DirectoryChannel..."); foreach (var directory in unmaskedDirectories) { - await DirectoryChannel.Writer.WriteAsync(directory); + await channel.Writer.WriteAsync(directory, cancellationToken); } - DirectoryChannel.Writer.Complete(); + channel.Writer.Complete(); Log.Debug("DirectoryChannel filled"); - Log.Debug("Waiting for workers to finish working..."); - await Task.WhenAll(workers.Select(w => w.Completed)); - Log.Debug("All workers finished"); + try + { + Log.Debug("Waiting for workers to finish working..."); + await Task.WhenAll(workers.Select(w => w.Completed)); + Log.Debug("All workers finished"); - Log.Information("Scan found {Files} files (and {Filtered} were filtered) in {Elapsed}ms", cached, filtered, sw.ElapsedMilliseconds - swSnapshot); - swSnapshot = sw.ElapsedMilliseconds; + Log.Information("Scan found {Files} files (and {Filtered} were filtered) in {Elapsed}ms", cached, filtered, sw.ElapsedMilliseconds - swSnapshot); + swSnapshot = sw.ElapsedMilliseconds; - var deletedFiles = DeleteStaleFiles(timestamp); - var deletedDirectories = DeleteStaleDirectories(timestamp); + var deletedFiles = DeleteStaleFiles(timestamp); + var deletedDirectories = DeleteStaleDirectories(timestamp); - Log.Information("Removed or renamed {Files} files and {Directories} directories in {Elapsed}ms", deletedFiles, deletedDirectories, sw.ElapsedMilliseconds - swSnapshot); + Log.Information("Removed or renamed {Files} files and {Directories} directories in {Elapsed}ms", deletedFiles, deletedDirectories, sw.ElapsedMilliseconds - swSnapshot); + } + catch (OperationCanceledException) + { + // important! don't try to delete stale files in this case; unscanned records will have a stale timestamp + Log.Warning("Shared file scan cancelled by user"); + } Log.Debug("Backing up shared file cache database..."); Backup(); Log.Debug("Shared file cache database backup complete"); + var directoryCount = CountDirectories(); + var fileCount = CountFiles(); + State.SetValue(state => state with { Filling = false, Faulted = false, Filled = true, FillProgress = 1, - Directories = CountDirectories(), - Files = CountFiles(), + Directories = directoryCount, + Files = fileCount, }); - Log.Debug($"Shared file cache recreated in {sw.ElapsedMilliseconds}ms. Directories: {unmaskedDirectories.Count}, Files: {cached}"); + Log.Debug($"Shared file cache created or updated in {sw.ElapsedMilliseconds}ms. Directories: {directoryCount}, Files: {fileCount}"); } catch (Exception ex) { -- cgit v1.2.3 From d3009fbb67f76337949faa99cd7180d23451f8ca Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 24 Sep 2022 12:41:17 -0500 Subject: add sync/async overloads for filling, make scans cancellable --- src/slskd/Shares/ISharedFileCache.cs | 23 ++++++++++++++----- src/slskd/Shares/SharedFileCache.cs | 44 ++++++++++++++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/slskd/Shares/ISharedFileCache.cs b/src/slskd/Shares/ISharedFileCache.cs index 52c7783c..af151353 100644 --- a/src/slskd/Shares/ISharedFileCache.cs +++ b/src/slskd/Shares/ISharedFileCache.cs @@ -19,7 +19,6 @@ namespace slskd.Shares { using System.Collections.Generic; using System.Text.RegularExpressions; - using System.Threading; using System.Threading.Tasks; using Soulseek; @@ -42,12 +41,10 @@ namespace slskd.Shares /// /// Scans the configured shares and fills the cache. /// - /// Initiates the scan, then yields execution back to the caller; does not wait for the operation to complete. /// The list of shares from which to fill the cache. /// The list of regular expressions used to exclude files or paths from scanning. - /// The optional cancellation token to monitor. /// The operation context. - Task FillAsync(IEnumerable shares, IEnumerable filters, CancellationToken cancellationToken = default); + Task FillAsync(IEnumerable shares, IEnumerable filters); /// /// Returns the contents of the specified . @@ -62,7 +59,7 @@ namespace slskd.Shares /// /// The fully qualified filename to unmask. /// The unmasked filename. - public string Resolve(string filename); + string Resolve(string filename); /// /// Searches the cache for the specified and returns the matching files. @@ -71,10 +68,24 @@ namespace slskd.Shares /// The matching files. IEnumerable Search(SearchQuery query); + /// + /// Starts a scan of the configured shares and fills the cache. + /// + /// The list of shares from which to fill the cache. + /// The list of regular expressions used to exclude files or paths from scanning. + /// The operation context. + Task StartFillAsync(IEnumerable shares, IEnumerable filters); + + /// + /// Cancels the currently running fill operation, if one is running. + /// + /// A value indicating whether a fill operation was cancelled. + bool TryCancelFill(); + /// /// Attempts to load the cache from disk. /// /// A value indicating whether the load was successful. bool TryLoad(); } -} +} \ No newline at end of file diff --git a/src/slskd/Shares/SharedFileCache.cs b/src/slskd/Shares/SharedFileCache.cs index 07dc6ba5..0fb3c2d0 100644 --- a/src/slskd/Shares/SharedFileCache.cs +++ b/src/slskd/Shares/SharedFileCache.cs @@ -63,6 +63,7 @@ namespace slskd.Shares private ISoulseekFileFactory SoulseekFileFactory { get; } private IManagedState State { get; } = new ManagedState(); private SemaphoreSlim SyncRoot { get; } = new SemaphoreSlim(1); + private CancellationTokenSource CancellationTokenSource { get; set; } /// /// Returns the contents of the cache. @@ -125,14 +126,29 @@ namespace slskd.Shares return directories.Values.OrderBy(d => d.Name); } + /// + /// Starts a scan of the configured shares and fills the cache. + /// + /// The list of shares from which to fill the cache. + /// The list of regular expressions used to exclude files or paths from scanning. + /// The operation context. + public Task StartFillAsync(IEnumerable shares, IEnumerable filters) + { + return FillInternalAsync(shares, filters, continueAsync: true); + } + /// /// Scans the configured shares and fills the cache. /// /// The list of shares from which to fill the cache. /// The list of regular expressions used to exclude files or paths from scanning. - /// The optional cancellation token to monitor for cancellation requests. /// The operation context. - public async Task FillAsync(IEnumerable shares, IEnumerable filters, CancellationToken cancellationToken = default) + public Task FillAsync(IEnumerable shares, IEnumerable filters) + { + return FillInternalAsync(shares, filters, continueAsync: false); + } + + private async Task FillInternalAsync(IEnumerable shares, IEnumerable filters, bool continueAsync = true) { // obtain the semaphore, or fail if it can't be obtained immediately, indicating that a scan is running. if (!await SyncRoot.WaitAsync(millisecondsTimeout: 0)) @@ -141,6 +157,9 @@ namespace slskd.Shares throw new ShareScanInProgressException("Shared files are already being scanned."); } + CancellationTokenSource = new CancellationTokenSource(); + var cancellationToken = CancellationTokenSource.Token; + try { State.SetValue(state => state with @@ -164,6 +183,11 @@ namespace slskd.Shares Log.Debug("Starting shared file scan"); + if (continueAsync) + { + await Task.Yield(); + } + var timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); var sw = new Stopwatch(); @@ -369,6 +393,7 @@ namespace slskd.Shares } finally { + CancellationTokenSource = null; SyncRoot.Release(); } } @@ -462,6 +487,21 @@ namespace slskd.Shares } } + /// + /// Cancels the currently running fill operation, if one is running. + /// + /// A value indicating whether a fill operation was cancelled. + public bool TryCancelFill() + { + if (CancellationTokenSource != null) + { + CancellationTokenSource.Cancel(); + return true; + } + + return false; + } + /// /// Attempts to load the cache from disk. /// -- cgit v1.2.3 From 1f42f7c52862472e381dc46d8c70c23d1b017468 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 24 Sep 2022 12:43:36 -0500 Subject: add sync/async overloads, TryCancelScan --- src/slskd/Shares/IShareService.cs | 13 +++++++++++++ src/slskd/Shares/ShareService.cs | 21 ++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) (limited to 'src') 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 @@ -69,6 +69,13 @@ namespace slskd.Shares /// The matching files. Task> SearchAsync(SearchQuery query); + /// + /// Scans the configured shares. + /// + /// The operation context. + /// Thrown when a scan is already in progress. + Task ScanAsync(); + /// /// Starts a scan of the configured shares. /// @@ -76,6 +83,12 @@ namespace slskd.Shares /// Thrown when a scan is already in progress. Task StartScanAsync(); + /// + /// Cancels the currently running scan, if one is running. + /// + /// A value indicating whether a scan was cancelled. + bool TryCancelScan(); + /// /// Attempt to load shares from disk. /// 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 @@ -158,6 +158,16 @@ namespace slskd.Shares r.Attributes))); } + /// + /// Scans the configured shares. + /// + /// The operation context. + /// Thrown when a scan is already in progress. + public Task ScanAsync() + { + return Cache.FillAsync(Shares, FilterRegexes); + } + /// /// Starts a scan of the configured shares. /// @@ -165,7 +175,16 @@ namespace slskd.Shares /// Thrown when a scan is already in progress. public Task StartScanAsync() { - return Cache.FillAsync(Shares, FilterRegexes); + return Cache.StartFillAsync(Shares, FilterRegexes); + } + + /// + /// Cancels the currently running scan, if one is running. + /// + /// A value indicating whether a scan was cancelled. + public bool TryCancelScan() + { + return Cache.TryCancelFill(); } /// -- cgit v1.2.3 From 388137d3a915490fd6f589e9a5e6ad538f18512e Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 24 Sep 2022 12:43:46 -0500 Subject: add cancellation endpoint --- .../Shares/API/Controllers/SharesController.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src') diff --git a/src/slskd/Shares/API/Controllers/SharesController.cs b/src/slskd/Shares/API/Controllers/SharesController.cs index 12a1c7b2..a8d5ae96 100644 --- a/src/slskd/Shares/API/Controllers/SharesController.cs +++ b/src/slskd/Shares/API/Controllers/SharesController.cs @@ -189,5 +189,26 @@ namespace slskd.Shares.API return Ok(); } + + /// + /// Cancels a share scan, if one is running. + /// + /// + /// The request completed successfully. + /// A share scan was not in progress. + [HttpDelete] + [Route("")] + [Authorize] + [ProducesResponseType(204)] + [ProducesResponseType(404)] + public IActionResult CancelShareScan() + { + if (Shares.TryCancelScan()) + { + return StatusCode(204); + } + + return NotFound(); + } } } -- cgit v1.2.3 From 500ea27c3b9e027ed114d45587dde9108b0912ee Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 24 Sep 2022 12:43:56 -0500 Subject: await scan start --- src/slskd/Application.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index 20735ead..25696de3 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -384,7 +384,7 @@ namespace slskd else { // todo: should this be forced prior to connection if the cache can't be loaded? - _ = Shares.StartScanAsync(); + await Shares.StartScanAsync(); } } -- cgit v1.2.3 From 863030b0f43866c88e5fcebf985f7d8ed87f0247 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 24 Sep 2022 16:18:10 -0500 Subject: use TrySetResult in case of exception --- src/slskd/Common/ChannelReader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Common/ChannelReader.cs b/src/slskd/Common/ChannelReader.cs index daae4ad1..49ebf0cf 100644 --- a/src/slskd/Common/ChannelReader.cs +++ b/src/slskd/Common/ChannelReader.cs @@ -130,7 +130,7 @@ namespace slskd.Shares } finally { - TaskCompletionSource.SetResult(); + TaskCompletionSource.TrySetResult(); } } } -- cgit v1.2.3 From c447c545257721398ac0576c07d4873156c5a19e Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 24 Sep 2022 16:20:21 -0500 Subject: add and use MasterCancellationTokenSource --- src/slskd/Application.cs | 2 ++ src/slskd/Program.cs | 11 +++++++++++ src/slskd/Shares/SharedFileCache.cs | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index 25696de3..abb2e7b3 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -94,6 +94,7 @@ namespace slskd Console.CancelKeyPress += (_, args) => { ShuttingDown = true; + Program.MasterCancellationTokenSource.Cancel(); Log.Warning("Received SIGINT"); }; @@ -102,6 +103,7 @@ namespace slskd PosixSignalRegistration.Create(signal, context => { ShuttingDown = true; + Program.MasterCancellationTokenSource.Cancel(); Log.Fatal("Received {Signal}", signal); }); } diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index e828f242..94624115 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -30,6 +30,7 @@ namespace slskd using System.Security.Cryptography.X509Certificates; using System.Text; using System.Text.Json.Serialization; + using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Builder; @@ -189,6 +190,16 @@ namespace slskd /// public static ConcurrentFixedSizeQueue LogBuffer { get; } = new ConcurrentFixedSizeQueue(size: 100); + /// + /// Gets the master cancellation token source for the program. + /// + /// + /// The token from this source should be used (or linked) to any long-running asynchronous task, so that when the application + /// begins to shut down these tasks also shut down in a timely manner. Actions that control the lifecycle of the program + /// (POSIX signals, a restart from the API, etc) should cancel this source. + /// + public static CancellationTokenSource MasterCancellationTokenSource { get; } = new CancellationTokenSource(); + private static IConfigurationRoot Configuration { get; set; } private static OptionsAtStartup OptionsAtStartup { get; } = new OptionsAtStartup(); private static ILogger Log { get; set; } = new ConsoleWriteLineLogger(); diff --git a/src/slskd/Shares/SharedFileCache.cs b/src/slskd/Shares/SharedFileCache.cs index 0fb3c2d0..dd399e68 100644 --- a/src/slskd/Shares/SharedFileCache.cs +++ b/src/slskd/Shares/SharedFileCache.cs @@ -157,7 +157,7 @@ namespace slskd.Shares throw new ShareScanInProgressException("Shared files are already being scanned."); } - CancellationTokenSource = new CancellationTokenSource(); + CancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(Program.MasterCancellationTokenSource.Token); var cancellationToken = CancellationTokenSource.Token; try -- cgit v1.2.3 From 721a1436960746df84410cfb4b6626f50df62f43 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 24 Sep 2022 16:20:58 -0500 Subject: don't wait for scan to complete on start --- src/slskd/Application.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index abb2e7b3..62138d48 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -386,7 +386,7 @@ namespace slskd else { // todo: should this be forced prior to connection if the cache can't be loaded? - await Shares.StartScanAsync(); + _ = Shares.ScanAsync(); } } -- cgit v1.2.3 From db73de70aa1e3d28707da66271b9962046ebcc8c Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 24 Sep 2022 16:21:20 -0500 Subject: cancel master token on shutdown and reboot --- src/slskd/Core/API/Controllers/ApplicationController.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/slskd/Core/API/Controllers/ApplicationController.cs b/src/slskd/Core/API/Controllers/ApplicationController.cs index ac8be802..7fb914e9 100644 --- a/src/slskd/Core/API/Controllers/ApplicationController.cs +++ b/src/slskd/Core/API/Controllers/ApplicationController.cs @@ -72,6 +72,7 @@ namespace slskd.Core.API [Authorize] public IActionResult Shutdown() { + Program.MasterCancellationTokenSource.Cancel(); Lifetime.StopApplication(); Task.Run(async () => @@ -91,6 +92,7 @@ namespace slskd.Core.API [Authorize] public IActionResult Restart() { + Program.MasterCancellationTokenSource.Cancel(); Process.Start(Process.GetCurrentProcess().MainModule.FileName, Environment.CommandLine); Lifetime.StopApplication(); -- cgit v1.2.3 From 196b88f9970887cbe69d1f0b7d23493204ce5990 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 24 Sep 2022 16:21:40 -0500 Subject: add cancelled to share state --- src/slskd/Core/State.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/slskd/Core/State.cs b/src/slskd/Core/State.cs index 1b798ad3..519f5345 100644 --- a/src/slskd/Core/State.cs +++ b/src/slskd/Core/State.cs @@ -104,6 +104,7 @@ namespace slskd public bool Scanning { get; init; } public bool Ready { get; init; } public bool Faulted { get; init; } + public bool Cancelled { get; init; } public double ScanProgress { get; init; } public int Directories { get; init; } public int Files { get; init; } @@ -126,6 +127,8 @@ namespace slskd /// public bool Faulted { get; init; } = false; + public bool Cancelled { get; init; } = false; + /// /// Gets the current fill progress. /// -- cgit v1.2.3 From c6a06b2d45faeab923865ca4bc2232ff5f7c8326 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 24 Sep 2022 16:21:59 -0500 Subject: don't wait for scan --- src/slskd/Shares/API/Controllers/SharesController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/slskd/Shares/API/Controllers/SharesController.cs b/src/slskd/Shares/API/Controllers/SharesController.cs index a8d5ae96..44d79a18 100644 --- a/src/slskd/Shares/API/Controllers/SharesController.cs +++ b/src/slskd/Shares/API/Controllers/SharesController.cs @@ -176,11 +176,11 @@ namespace slskd.Shares.API [Authorize] [ProducesResponseType(204)] [ProducesResponseType(409)] - public async Task RescanSharesAsync() + public IActionResult RescanSharesAsync() { try { - await Shares.StartScanAsync(); + _ = Shares.ScanAsync(); } catch (ShareScanInProgressException) { -- cgit v1.2.3 From c42c892408faf7481d111e866a654ea37866d94b Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 24 Sep 2022 16:22:26 -0500 Subject: report progress every 1% instead of 5 --- src/slskd/Application.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index 62138d48..4990186e 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -1035,7 +1035,7 @@ namespace slskd var lastProgress = Math.Round(previous.ScanProgress * 100); var currentProgress = Math.Round(current.ScanProgress * 100); - if (lastProgress != currentProgress && Math.Round(currentProgress, 0) % 5d == 0) + if (lastProgress != currentProgress && Math.Round(currentProgress, 0) % 1d == 0) { State.SetValue(s => s with { Shares = current }); Log.Information("Scanned {Percent}% of shared directories. Found {Files} files so far.", currentProgress, current.Files); -- cgit v1.2.3 From 6484666fc88126f3216846409e3f1b81b2a78677 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 24 Sep 2022 16:23:04 -0500 Subject: undo separation of start/scan, improve cancellation logic --- src/slskd/Shares/IShareService.cs | 7 ---- src/slskd/Shares/ISharedFileCache.cs | 8 ----- src/slskd/Shares/ShareService.cs | 13 ++----- src/slskd/Shares/SharedFileCache.cs | 70 +++++++++++++++--------------------- 4 files changed, 31 insertions(+), 67 deletions(-) (limited to 'src') diff --git a/src/slskd/Shares/IShareService.cs b/src/slskd/Shares/IShareService.cs index 12603283..b625286e 100644 --- a/src/slskd/Shares/IShareService.cs +++ b/src/slskd/Shares/IShareService.cs @@ -76,13 +76,6 @@ namespace slskd.Shares /// Thrown when a scan is already in progress. Task ScanAsync(); - /// - /// Starts a scan of the configured shares. - /// - /// The operation context. - /// Thrown when a scan is already in progress. - Task StartScanAsync(); - /// /// Cancels the currently running scan, if one is running. /// diff --git a/src/slskd/Shares/ISharedFileCache.cs b/src/slskd/Shares/ISharedFileCache.cs index af151353..73c9cd56 100644 --- a/src/slskd/Shares/ISharedFileCache.cs +++ b/src/slskd/Shares/ISharedFileCache.cs @@ -68,14 +68,6 @@ namespace slskd.Shares /// The matching files. IEnumerable Search(SearchQuery query); - /// - /// Starts a scan of the configured shares and fills the cache. - /// - /// The list of shares from which to fill the cache. - /// The list of regular expressions used to exclude files or paths from scanning. - /// The operation context. - Task StartFillAsync(IEnumerable shares, IEnumerable filters); - /// /// Cancels the currently running fill operation, if one is running. /// diff --git a/src/slskd/Shares/ShareService.cs b/src/slskd/Shares/ShareService.cs index 72a0fea6..17817b86 100644 --- a/src/slskd/Shares/ShareService.cs +++ b/src/slskd/Shares/ShareService.cs @@ -52,9 +52,10 @@ namespace slskd.Shares State.SetValue(state => state with { // scan is pending if faulted, or if state DIDN'T just transition from filling to not filling AND a scan was already pending - ScanPending = current.Faulted || (!(previous.Filling && !current.Filling) && state.ScanPending), + ScanPending = current.Faulted || current.Cancelled || (!(previous.Filling && !current.Filling) && state.ScanPending), Scanning = current.Filling, Faulted = current.Faulted, + Cancelled = current.Cancelled, Ready = current.Filled, ScanProgress = current.FillProgress, Directories = current.Directories, @@ -168,16 +169,6 @@ namespace slskd.Shares return Cache.FillAsync(Shares, FilterRegexes); } - /// - /// Starts a scan of the configured shares. - /// - /// The operation context. - /// Thrown when a scan is already in progress. - public Task StartScanAsync() - { - return Cache.StartFillAsync(Shares, FilterRegexes); - } - /// /// Cancels the currently running scan, if one is running. /// diff --git a/src/slskd/Shares/SharedFileCache.cs b/src/slskd/Shares/SharedFileCache.cs index dd399e68..17fc5fb5 100644 --- a/src/slskd/Shares/SharedFileCache.cs +++ b/src/slskd/Shares/SharedFileCache.cs @@ -126,29 +126,13 @@ namespace slskd.Shares return directories.Values.OrderBy(d => d.Name); } - /// - /// Starts a scan of the configured shares and fills the cache. - /// - /// The list of shares from which to fill the cache. - /// The list of regular expressions used to exclude files or paths from scanning. - /// The operation context. - public Task StartFillAsync(IEnumerable shares, IEnumerable filters) - { - return FillInternalAsync(shares, filters, continueAsync: true); - } - /// /// Scans the configured shares and fills the cache. /// /// The list of shares from which to fill the cache. /// The list of regular expressions used to exclude files or paths from scanning. /// The operation context. - public Task FillAsync(IEnumerable shares, IEnumerable filters) - { - return FillInternalAsync(shares, filters, continueAsync: false); - } - - private async Task FillInternalAsync(IEnumerable shares, IEnumerable filters, bool continueAsync = true) + public async Task FillAsync(IEnumerable shares, IEnumerable 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)) @@ -160,12 +144,17 @@ namespace slskd.Shares CancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(Program.MasterCancellationTokenSource.Token); var cancellationToken = CancellationTokenSource.Token; + // send control back to the calling context. if we don't do this, the caller will block until + // directories have been enumerated. + await Task.Yield(); + try { State.SetValue(state => state with { Filling = true, Filled = false, + Cancelled = false, FillProgress = 0, Directories = 0, Files = 0, @@ -183,11 +172,6 @@ namespace slskd.Shares Log.Debug("Starting shared file scan"); - if (continueAsync) - { - await Task.Yield(); - } - var timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); var sw = new Stopwatch(); @@ -320,16 +304,7 @@ namespace slskd.Shares cached += addedFiles; Log.Debug("Finished scanning {Directory}: {Added} files added and {Filtered} filtered", directory, addedFiles, filteredFiles); - - try - { - State.SetValue(state => state with { FillProgress = current / (double)unmaskedDirectories.Count, Files = cached }); - } - catch (Exception ex) - { - Log.Error(ex, "Failed to set cache state following scan of {Directory}: {Message}", directory, ex.Message); - throw; - } + State.SetValue(state => state with { FillProgress = current / (double)unmaskedDirectories.Count, Files = cached }); })); } @@ -337,17 +312,28 @@ namespace slskd.Shares workers.ForEach(w => w.Start()); Log.Debug("All workers started"); - Log.Debug("Filling DirectoryChannel..."); - foreach (var directory in unmaskedDirectories) + try { - await channel.Writer.WriteAsync(directory, cancellationToken); - } + try + { + Log.Debug("Filling DirectoryChannel..."); + foreach (var directory in unmaskedDirectories) + { + await channel.Writer.WriteAsync(directory, cancellationToken); + } - channel.Writer.Complete(); - Log.Debug("DirectoryChannel filled"); + Log.Debug("DirectoryChannel filled"); + } + catch (OperationCanceledException) + { + Log.Warning("Shared file scan cancellation requested"); + Log.Debug("DirectoryChannel fill aborted"); + } + finally + { + channel.Writer.Complete(); + } - try - { Log.Debug("Waiting for workers to finish working..."); await Task.WhenAll(workers.Select(w => w.Completed)); Log.Debug("All workers finished"); @@ -363,7 +349,9 @@ namespace slskd.Shares catch (OperationCanceledException) { // important! don't try to delete stale files in this case; unscanned records will have a stale timestamp - Log.Warning("Shared file scan cancelled by user"); + Log.Warning("Shared file scan cancelled successfully"); + + State.SetValue(state => state with { Cancelled = true }); } Log.Debug("Backing up shared file cache database..."); -- cgit v1.2.3 From 9b8d59a93b4661f7e3650e025b725498b9a5567b Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 24 Sep 2022 17:19:20 -0500 Subject: improve shares UI performance --- .../Shares/API/Controllers/SharesController.cs | 38 ++---- src/slskd/Shares/IShareService.cs | 9 +- src/slskd/Shares/ISharedFileCache.cs | 17 ++- src/slskd/Shares/ShareService.cs | 16 ++- src/slskd/Shares/SharedFileCache.cs | 152 +++++++++++++++------ 5 files changed, 162 insertions(+), 70 deletions(-) (limited to 'src') diff --git a/src/slskd/Shares/API/Controllers/SharesController.cs b/src/slskd/Shares/API/Controllers/SharesController.cs index 44d79a18..5f87f900 100644 --- a/src/slskd/Shares/API/Controllers/SharesController.cs +++ b/src/slskd/Shares/API/Controllers/SharesController.cs @@ -57,18 +57,13 @@ namespace slskd.Shares.API [ProducesResponseType(typeof(IEnumerable), 200)] public async Task List() { - var browse = await Shares.BrowseAsync(); + var shares = new List(); - var summary = Shares.Shares.Select(share => + foreach (var share in Shares.Shares) { - var directories = browse.Where(directory => directory.Name.StartsWith(share.RemotePath)); - var fileCount = directories.Aggregate(seed: 0, (sum, directory) => - { - sum += directory.FileCount; - return sum; - }); + var (directories, files) = await Shares.SummarizeShareAsync(share); - return new SummarizedShare() + shares.Add(new SummarizedShare() { Id = share.Id, Alias = share.Alias, @@ -76,12 +71,12 @@ namespace slskd.Shares.API LocalPath = share.LocalPath, Raw = share.Raw, RemotePath = share.RemotePath, - Directories = directories.Count(), - Files = fileCount, - }; - }); + Directories = directories, + Files = files, + }); + } - return Ok(summary); + return Ok(shares); } /// @@ -104,13 +99,7 @@ namespace slskd.Shares.API return NotFound(); } - var browse = await Shares.BrowseAsync(); - var directories = browse.Where(directory => directory.Name.StartsWith(share.RemotePath)); - var fileCount = directories.Aggregate(seed: 0, (sum, directory) => - { - sum += directory.FileCount; - return sum; - }); + var (directories, files) = await Shares.SummarizeShareAsync(share); var summary = new SummarizedShare() { @@ -120,8 +109,8 @@ namespace slskd.Shares.API LocalPath = share.LocalPath, Raw = share.Raw, RemotePath = share.RemotePath, - Directories = directories.Count(), - Files = fileCount, + Directories = directories, + Files = files, }; return Ok(summary); @@ -159,8 +148,7 @@ namespace slskd.Shares.API return NotFound(); } - var contents = (await Shares.BrowseAsync()) - .Where(directory => directory.Name.StartsWith(share.RemotePath)); + var contents = await Shares.BrowseAsync(share); return Ok(contents); } diff --git a/src/slskd/Shares/IShareService.cs b/src/slskd/Shares/IShareService.cs index b625286e..73f6a4ad 100644 --- a/src/slskd/Shares/IShareService.cs +++ b/src/slskd/Shares/IShareService.cs @@ -42,7 +42,7 @@ namespace slskd.Shares /// Returns the entire contents of the share. /// /// The entire contents of the share. - Task> BrowseAsync(); + Task> BrowseAsync(Share share = null); /// /// Returns the contents of the specified . @@ -76,6 +76,13 @@ namespace slskd.Shares /// Thrown when a scan is already in progress. Task ScanAsync(); + /// + /// Gets summary information for the specified . + /// + /// The share to summarize. + /// The summary information. + Task<(int Directories, int Files)> SummarizeShareAsync(Share share); + /// /// Cancels the currently running scan, if one is running. /// diff --git a/src/slskd/Shares/ISharedFileCache.cs b/src/slskd/Shares/ISharedFileCache.cs index 73c9cd56..c59f5bba 100644 --- a/src/slskd/Shares/ISharedFileCache.cs +++ b/src/slskd/Shares/ISharedFileCache.cs @@ -35,8 +35,23 @@ namespace slskd.Shares /// /// Returns the contents of the cache. /// + /// The optional share to which to limit the scope of the browse. /// The contents of the cache. - IEnumerable Browse(); + IEnumerable Browse(Share share = null); + + /// + /// Returns the number of directories in the specified . + /// + /// The share for which the directories are to be counted. + /// The number of directories. + int CountDirectories(Share share); + + /// + /// Returns the number of files in the specified . + /// + /// The share for which the files are to be counted. + /// The number of files. + int CountFiles(Share share); /// /// Scans the configured shares and fills the cache. diff --git a/src/slskd/Shares/ShareService.cs b/src/slskd/Shares/ShareService.cs index 17817b86..4307a98f 100644 --- a/src/slskd/Shares/ShareService.cs +++ b/src/slskd/Shares/ShareService.cs @@ -91,9 +91,9 @@ namespace slskd.Shares /// Returns the entire contents of the share. /// /// The entire contents of the share. - public Task> BrowseAsync() + public Task> BrowseAsync(Share share = null) { - var results = Cache.Browse(); + var results = Cache.Browse(share); var normalizedResults = results.Select(r => new Directory(r.Name.NormalizePath(), r.Files)); return Task.FromResult(normalizedResults); @@ -169,6 +169,18 @@ namespace slskd.Shares return Cache.FillAsync(Shares, FilterRegexes); } + /// + /// Gets summary information for the specified . + /// + /// The share to summarize. + /// The summary information. + public Task<(int Directories, int Files)> SummarizeShareAsync(Share share) + { + var dirs = Cache.CountDirectories(share); + var files = Cache.CountFiles(share); + return Task.FromResult((dirs, files)); + } + /// /// Cancels the currently running scan, if one is running. /// diff --git a/src/slskd/Shares/SharedFileCache.cs b/src/slskd/Shares/SharedFileCache.cs index 17fc5fb5..a10202e2 100644 --- a/src/slskd/Shares/SharedFileCache.cs +++ b/src/slskd/Shares/SharedFileCache.cs @@ -25,6 +25,7 @@ namespace slskd.Shares using System.Data; using System.Diagnostics; using System.Linq; + using System.Security.Cryptography; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Channels; @@ -68,41 +69,30 @@ namespace slskd.Shares /// /// Returns the contents of the cache. /// + /// The optional share to which to limit the scope of the browse. /// The contents of the cache. - public IEnumerable Browse() + public IEnumerable Browse(Share share = null) { var directories = new ConcurrentDictionary(); + string prefix = null; + + if (share != null) + { + prefix = share.RemotePath + Path.DirectorySeparatorChar; + } + // Soulseek requires that each directory in the tree have an entry in the list returned in a browse response. if // missing, files that are nested within directories which contain only directories (no files) are displayed as being // in the root. to get around this, prime a dictionary with all known directories, and an empty Soulseek.Directory. if // there are any files in the directory, this entry will be overwritten with a new Soulseek.Directory containing the // files. if not they'll be left as is. - foreach (var directory in ListDirectories()) + foreach (var directory in ListDirectories(prefix)) { directories.TryAdd(directory, new Directory(directory)); } - var files = new List(); - - using var conn = GetConnection(); - using var cmd = new SqliteCommand("SELECT maskedFilename, code, size, extension, attributeJson FROM files ORDER BY maskedFilename ASC;", conn); - var reader = cmd.ExecuteReader(); - - while (reader.Read()) - { - var filename = reader.GetString(0); - var code = reader.GetInt32(1); - var size = reader.GetInt64(2); - var extension = reader.GetString(3); - var attributeJson = reader.GetString(4); - - var attributeList = attributeJson.FromJson>(); - - var file = new File(code, filename, size, extension, attributeList); - - files.Add(file); - } + var files = ListFiles(prefix, includeFullPath: true); var groups = files .GroupBy(file => Path.GetDirectoryName(file.Filename)) @@ -126,6 +116,28 @@ namespace slskd.Shares return directories.Values.OrderBy(d => d.Name); } + /// + /// Returns the number of directories in the specified . + /// + /// The share for which the directories are to be counted. + /// The number of directories. + public int CountDirectories(Share share) + { + var path = share.RemotePath + Path.DirectorySeparatorChar; + return CountDirectories(path); + } + + /// + /// Returns the number of files in the specified . + /// + /// The share for which the files are to be counted. + /// The number of files. + public int CountFiles(Share share) + { + var path = share.RemotePath + Path.DirectorySeparatorChar; + return CountFiles(path); + } + /// /// Scans the configured shares and fills the cache. /// @@ -623,22 +635,60 @@ namespace slskd.Shares sourceConn.BackupDatabase(backupConn); } - private int CountDirectories() + private int CountDirectories(string prefix = null) { using var conn = GetConnection(); - using var cmd = new SqliteCommand("SELECT COUNT(*) FROM directories;", conn); - var reader = cmd.ExecuteReader(); - reader.Read(); - return reader.GetInt32(0); + + SqliteCommand cmd = default; + + try + { + if (string.IsNullOrEmpty(prefix)) + { + cmd = new SqliteCommand("SELECT COUNT(*) FROM directories;", conn); + } + else + { + cmd = new SqliteCommand("SELECT COUNT(*) FROM directories WHERE name LIKE @prefix || '%'", conn); + cmd.Parameters.AddWithValue("prefix", prefix); + } + + var reader = cmd.ExecuteReader(); + reader.Read(); + return reader.GetInt32(0); + } + finally + { + cmd.Dispose(); + } } - private int CountFiles() + private int CountFiles(string prefix = null) { using var conn = GetConnection(); - using var cmd = new SqliteCommand("SELECT COUNT(*) FROM files;", conn); - var reader = cmd.ExecuteReader(); - reader.Read(); - return reader.GetInt32(0); + + SqliteCommand cmd = default; + + try + { + if (string.IsNullOrEmpty(prefix)) + { + cmd = new SqliteCommand("SELECT COUNT(*) FROM files;", conn); + } + else + { + cmd = new SqliteCommand("SELECT COUNT(*) FROM files WHERE maskedFilename LIKE @prefix || '%'", conn); + cmd.Parameters.AddWithValue("prefix", prefix); + } + + var reader = cmd.ExecuteReader(); + reader.Read(); + return reader.GetInt32(0); + } + finally + { + cmd.Dispose(); + } } private SqliteConnection GetConnection(string connectionString = null) @@ -710,24 +760,42 @@ namespace slskd.Shares return reader.GetInt64(0); } - private IEnumerable ListDirectories() + private IEnumerable ListDirectories(string prefix = null) { var results = new List(); using var conn = GetConnection(); - using var cmd = new SqliteCommand("SELECT name FROM directories ORDER BY name ASC;", conn); - var reader = cmd.ExecuteReader(); + SqliteCommand cmd = default; - while (reader.Read()) + try { - results.Add(reader.GetString(0)); - } + if (string.IsNullOrEmpty(prefix)) + { + cmd = new SqliteCommand("SELECT name FROM directories ORDER BY name ASC;", conn); + } + else + { + cmd = new SqliteCommand("SELECT name from directories WHERE name LIKE @prefix || '%' ORDER BY name ASC;", conn); + cmd.Parameters.AddWithValue("prefix", prefix); + } + + var reader = cmd.ExecuteReader(); + + while (reader.Read()) + { + results.Add(reader.GetString(0)); + } - return results; + return results; + } + finally + { + cmd.Dispose(); + } } - private IEnumerable ListFiles(string directory = null) + private IEnumerable ListFiles(string directory = null, bool includeFullPath = false) { var results = new List(); @@ -758,7 +826,9 @@ namespace slskd.Shares var attributeList = attributeJson.FromJson>(); - var file = new File(code, filename: Path.GetFileName(filename), size, extension, attributeList); + filename = includeFullPath ? filename : Path.GetFileName(filename); + + var file = new File(code, filename, size, extension, attributeList); results.Add(file); } -- cgit v1.2.3 From a4fcf65d451e9c2629f9f113ca06485b7e564f8e Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 24 Sep 2022 17:32:45 -0500 Subject: fix state bug --- src/slskd/Application.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index 4990186e..86d74d4d 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -986,6 +986,8 @@ namespace slskd { var (previous, current) = state; + Console.WriteLine(current); + if (!previous.Scanning && current.Scanning) { // the scan is starting @@ -1025,7 +1027,7 @@ namespace slskd else if (!previous.Ready && current.Ready) { // the share transitioned into ready without completing a scan; it was loaded from disk - State.SetValue(state => state with { Shares = state.Shares with { ScanPending = false } }); + State.SetValue(state => state with { Shares = current with { ScanPending = false } }); Log.Information("Share cache loaded from disk successfully. Sharing {Directories} directories and {Files} files", current.Directories, current.Files); _ = CacheBrowseResponse(); } -- cgit v1.2.3 From 052524a14612d08823b31696d0c35b66bcc066b5 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 24 Sep 2022 17:35:05 -0500 Subject: foce a scan at start if the cache can't be loaded from disk --- src/slskd/Application.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index 86d74d4d..bc3892d9 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -385,8 +385,7 @@ namespace slskd } else { - // todo: should this be forced prior to connection if the cache can't be loaded? - _ = Shares.ScanAsync(); + await Shares.ScanAsync(); } } -- cgit v1.2.3 From 2150d2dd4df17767533f4298c9a9368dba500c25 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 25 Sep 2022 13:57:40 -0500 Subject: add cancel function --- src/web/src/lib/shares.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/web/src/lib/shares.js b/src/web/src/lib/shares.js index 03fac7d6..c400e08e 100644 --- a/src/web/src/lib/shares.js +++ b/src/web/src/lib/shares.js @@ -20,4 +20,8 @@ export const browse = async ({ id } = {}) => { export const rescan = async () => { return (await api.put('/shares')).data; +}; + +export const cancel = async () => { + return (await api.delete('/shares')).data; }; \ No newline at end of file -- cgit v1.2.3 From 374df66d4cc4f9f55a2a0a3e69b50260525060ce Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 25 Sep 2022 14:22:01 -0500 Subject: add a button to cancel a scan, show files and folder counts --- src/web/src/components/System/Shares/index.js | 81 +++++++++++++++++++++------ src/web/src/components/System/System.css | 5 ++ 2 files changed, 69 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/web/src/components/System/Shares/index.js b/src/web/src/components/System/Shares/index.js index ceb5746c..6759ad6f 100644 --- a/src/web/src/components/System/Shares/index.js +++ b/src/web/src/components/System/Shares/index.js @@ -19,10 +19,11 @@ import ShareTable from './ShareTable'; const Index = ({ state = {} } = {}) => { const [loading, setLoading] = useState(true); + const [working, setWorking] = useState(false); const [shares, setShares] = useState([]); const [modal, setModal] = useState(false); - const { scanning, scanProgress, scanPending } = state; + const { scanning, scanProgress, scanPending, directories, files } = state; const scanned = !scanning; useEffect(() => { @@ -47,30 +48,76 @@ const Index = ({ state = {} } = {}) => { } }; + const rescan = async () => { + try { + setWorking(true); + await sharesLib.rescan(); + } catch (error) { + console.error(error); + toast.error(error?.response?.data ?? error?.message ?? error); + } finally { + setWorking(false); + } + }; + + const cancel = async () => { + try { + setWorking(true); + await sharesLib.cancel(); + } catch (error) { + console.error(error); + toast.error(error?.response?.data ?? error?.message ?? error ?? 'Failed to cancel the scan'); + } finally { + setWorking(false); + } + }; + + const ScanButton = () => rescan()} + >Rescan Shares; + + const CancelButton = () => cancel()} + >Cancel Scan; + const shared = shares.filter(share => !share.isExcluded); const excluded = shares.filter(share => share.isExcluded); return ( <> -
- sharesLib.rescan()} - >{scanning ? 'Scanning shares' : 'Rescan Shares'} -
- {Math.round(scanProgress * 100)}%} + loading={loading && } > - - +
+ } + > + + +
+ + +
+
{Math.round(scanProgress * 100)}%
+
Found {files} files in {directories} directories
+
} + > + + +
+ setModal(false)}/> - setModal(false)}/> ); }; diff --git a/src/web/src/components/System/System.css b/src/web/src/components/System/System.css index a8e9cb8e..a463ab08 100644 --- a/src/web/src/components/System/System.css +++ b/src/web/src/components/System/System.css @@ -62,4 +62,9 @@ .share-count-column { width: 110px; +} + +.share-scan-detail { + margin-top: 10px; + font-size: 14px; } \ No newline at end of file -- cgit v1.2.3 From dc251687151e30756d0a8159e3afa0e203900d4e Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 25 Sep 2022 14:22:16 -0500 Subject: print system info at startup --- src/slskd/Program.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index 94624115..03870f0a 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -340,8 +340,10 @@ namespace slskd Log.Warning($"Please report any issues here: {IssuesUrl}"); } + Log.Information("System: .NET {DotNet}, {OS}, {BitNess} bit, {ProcessorCount} processors", Environment.Version, Environment.OSVersion, Environment.Is64BitOperatingSystem ? 64 : 32, Environment.ProcessorCount); + Log.Information("Process ID: {ProcessId} ({BitNess} bit)", ProcessId, Environment.Is64BitProcess ? 64 : 32); + Log.Information("Invocation ID: {InvocationId}", InvocationId); - Log.Information("Process ID: {ProcessId}", ProcessId); Log.Information("Instance Name: {InstanceName}", OptionsAtStartup.InstanceName); // SQLite must have specific capabilities to function properly. this shouldn't be a concern for shrinkwrapped -- cgit v1.2.3 From fa8f8cb6829571cb2d7c1d81b99e88d0e2177195 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 25 Sep 2022 14:22:28 -0500 Subject: remove debug --- src/slskd/Application.cs | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index bc3892d9..f517850b 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -985,8 +985,6 @@ namespace slskd { var (previous, current) = state; - Console.WriteLine(current); - if (!previous.Scanning && current.Scanning) { // the scan is starting -- cgit v1.2.3