diff options
| author | JP Dillingham <jp@dillingham.me> | 2022-08-22 17:12:11 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2022-08-22 17:12:11 -0500 |
| commit | 0b6992d80fd188fe3b8b816f15a49619867eaf8f (patch) | |
| tree | 44b781d8c98c093ef6df5971baf84ad4d33a3875 /src | |
| parent | 686717cfaafdcfddae9733f2ebdae178aa3fa8c0 (diff) | |
| download | slskd-0b6992d80fd188fe3b8b816f15a49619867eaf8f.tar.gz | |
reorder share scan state handling
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Application.cs | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index f9cb95d2..5a56e110 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -927,23 +927,15 @@ namespace slskd if (!previous.Scanning && current.Scanning) { + // the scan is starting SharesRefreshStarted = DateTime.UtcNow; State.SetValue(s => s with { Shares = current }); Log.Information("Scanning shares"); } - - var lastProgress = Math.Round(previous.ScanProgress * 100); - var currentProgress = Math.Round(current.ScanProgress * 100); - - if (lastProgress != currentProgress && Math.Round(currentProgress, 0) % 10 == 0) - { - State.SetValue(s => s with { Shares = current }); - Log.Information("Scanned {Percent}% of shared directories. Found {Files} files so far.", currentProgress, current.Files); - } - - if (previous.Scanning && !current.Scanning) + else if (previous.Scanning && !current.Scanning) { + // the scan is finishing State.SetValue(s => s with { Shares = current }); if (current.Faulted) @@ -967,6 +959,18 @@ namespace slskd } } } + else + { + // the scan is neither starting nor finishing; progress update + var lastProgress = Math.Round(previous.ScanProgress * 100); + var currentProgress = Math.Round(current.ScanProgress * 100); + + if (lastProgress != currentProgress && Math.Round(currentProgress, 0) % 10d == 0) + { + State.SetValue(s => s with { Shares = current }); + Log.Information("Scanned {Percent}% () of shared directories. Found {Files} files so far.", currentProgress, current.Files); + } + } } private void State_OnChange((State Previous, State Current) state) |
