diff options
| author | JP Dillingham <jp@dillingham.me> | 2022-11-05 13:26:58 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2022-11-05 13:26:58 -0500 |
| commit | f92ef3c7a13eeb65ded5a26fda2f261f120eb88e (patch) | |
| tree | 8b2c6041edb27a5372bbdf9b62ff586ed8082b44 /src/slskd | |
| parent | bbfd8de4468bc3e68ea5099e89b9bdad966fa4d8 (diff) | |
| download | slskd-f92ef3c7a13eeb65ded5a26fda2f261f120eb88e.tar.gz | |
only compute local shares
Diffstat (limited to 'src/slskd')
| -rw-r--r-- | src/slskd/Shares/IShareService.cs | 7 | ||||
| -rw-r--r-- | src/slskd/Shares/ShareService.cs | 34 |
2 files changed, 15 insertions, 26 deletions
diff --git a/src/slskd/Shares/IShareService.cs b/src/slskd/Shares/IShareService.cs index dff6a8ce..aea3240a 100644 --- a/src/slskd/Shares/IShareService.cs +++ b/src/slskd/Shares/IShareService.cs @@ -54,13 +54,6 @@ namespace slskd.Shares Task<IEnumerable<Directory>> BrowseAsync(Share share = null); /// <summary> - /// Gets statistical information for the specified <paramref name="share"/>. - /// </summary> - /// <param name="share">The share to summarize.</param> - /// <returns>The summary information.</returns> - Task<(int Directories, int Files)> ComputeShareStatisticsAsync(Share share); - - /// <summary> /// Dumps the local share cache to a file. /// </summary> /// <param name="filename">The destination file.</param> diff --git a/src/slskd/Shares/ShareService.cs b/src/slskd/Shares/ShareService.cs index 76bce57c..109c9593 100644 --- a/src/slskd/Shares/ShareService.cs +++ b/src/slskd/Shares/ShareService.cs @@ -189,23 +189,6 @@ namespace slskd.Shares } /// <summary> - /// Gets summary information for the specified <paramref name="share"/>. - /// </summary> - /// <param name="share">The share to summarize.</param> - /// <returns>The summary information.</returns> - public Task<(int Directories, int Files)> ComputeShareStatisticsAsync(Share share) - { - var prefix = share.RemotePath + (share.RemotePath.EndsWith('\\') ? string.Empty : '\\'); - - var dirs = AllRepositories.Select(r => r.CountDirectories(prefix)).Sum(); - var files = AllRepositories.Select(r => r.CountFiles(prefix)).Sum(); - - share.UpdateStatistics(dirs, files); - - return Task.FromResult((dirs, files)); - } - - /// <summary> /// Dumps the local share cache to a file. /// </summary> /// <param name="filename">The destination file.</param> @@ -336,7 +319,7 @@ namespace slskd.Shares Log.Debug("Shared file cache database backup complete"); Log.Debug("Recomputing share statistics..."); - await Task.WhenAll(Local.Host.Shares.Select(share => ComputeShareStatisticsAsync(share))); + ComputeShareStatistics(); Log.Debug("Share statistics updated"); } @@ -418,7 +401,7 @@ namespace slskd.Shares Local.Repository.EnableKeepalive(true); Log.Debug("Recomputing share statistics..."); - await Task.WhenAll(Local.Host.Shares.Select(share => ComputeShareStatisticsAsync(share))); + ComputeShareStatistics(); Log.Debug("Share statistics updated"); // one of several thigns happened above before we got here: @@ -456,6 +439,19 @@ namespace slskd.Shares } } + private void ComputeShareStatistics() + { + foreach (var share in Local.Host.Shares) + { + var prefix = share.RemotePath + (share.RemotePath.EndsWith('\\') ? string.Empty : '\\'); + + var dirs = Local.Repository.CountDirectories(prefix); + var files = Local.Repository.CountFiles(prefix); + + share.UpdateStatistics(dirs, files); + } + } + private void Configure(Options options) { SyncRoot.Wait(); |
