aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Application.cs
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2022-09-25 14:36:31 -0500
committerGitHub <noreply@github.com>2022-09-25 14:36:31 -0500
commitcabbd9c2fcb30c6194d25045dd4a9f4bdf6d6e4f (patch)
tree883663596f57ac644c8e23a520fea8219588a060 /src/slskd/Application.cs
parent67bc4bed7726204bd373bd8e784dbb819cc2dadd (diff)
parentb6eebb3f6695c93bce44ceb17725b7342085ae16 (diff)
downloadslskd-cabbd9c2fcb30c6194d25045dd4a9f4bdf6d6e4f.tar.gz
Merge pull request #656 from slskd/cancel-scan
Add the ability to cancel a share scan
Diffstat (limited to 'src/slskd/Application.cs')
-rw-r--r--src/slskd/Application.cs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs
index 20735ead..f517850b 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);
});
}
@@ -383,8 +385,7 @@ namespace slskd
}
else
{
- // todo: should this be forced prior to connection if the cache can't be loaded?
- _ = Shares.StartScanAsync();
+ await Shares.ScanAsync();
}
}
@@ -1023,7 +1024,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();
}
@@ -1033,7 +1034,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);