diff options
| author | JP Dillingham <jp@dillingham.me> | 2022-09-27 09:36:29 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2022-09-27 09:36:29 -0500 |
| commit | 5cdb5cc91786c5f49bfa1f136c1c71fc52367110 (patch) | |
| tree | f4d8ef5ee04921e10f90e0491483bc82f48d13dd | |
| parent | f29414b34b05ab74ecbfa97c03917fb886dc886e (diff) | |
| download | slskd-5cdb5cc91786c5f49bfa1f136c1c71fc52367110.tar.gz | |
refactor counting functions
| -rw-r--r-- | src/slskd/Shares/ShareService.cs | 6 | ||||
| -rw-r--r-- | src/slskd/Shares/SharedFileCache.cs | 36 |
2 files changed, 4 insertions, 38 deletions
diff --git a/src/slskd/Shares/ShareService.cs b/src/slskd/Shares/ShareService.cs index e159237d..e99d048a 100644 --- a/src/slskd/Shares/ShareService.cs +++ b/src/slskd/Shares/ShareService.cs @@ -220,8 +220,10 @@ namespace slskd.Shares /// <returns>The summary information.</returns> public Task<(int Directories, int Files)> SummarizeShareAsync(Share share) { - var dirs = Cache.CountDirectories(share); - var files = Cache.CountFiles(share); + var prefix = share.RemotePath + Path.DirectorySeparatorChar; + + var dirs = Repository.CountDirectories(prefix); + var files = Repository.CountFiles(prefix); return Task.FromResult((dirs, files)); } diff --git a/src/slskd/Shares/SharedFileCache.cs b/src/slskd/Shares/SharedFileCache.cs index 3ff3d10f..190679a8 100644 --- a/src/slskd/Shares/SharedFileCache.cs +++ b/src/slskd/Shares/SharedFileCache.cs @@ -43,20 +43,6 @@ namespace slskd.Shares IStateMonitor<SharedFileCacheState> StateMonitor { get; } /// <summary> - /// Returns the number of directories in the specified <paramref name="share"/>. - /// </summary> - /// <param name="share">The share for which the directories are to be counted.</param> - /// <returns>The number of directories.</returns> - int CountDirectories(Share share); - - /// <summary> - /// Returns the number of files in the specified <paramref name="share"/>. - /// </summary> - /// <param name="share">The share for which the files are to be counted.</param> - /// <returns>The number of files.</returns> - int CountFiles(Share share); - - /// <summary> /// Scans the configured shares and fills the cache. /// </summary> /// <param name="shares">The list of shares from which to fill the cache.</param> @@ -134,28 +120,6 @@ namespace slskd.Shares private IShareRepository Repository { get; } /// <summary> - /// Returns the number of directories in the specified <paramref name="share"/>. - /// </summary> - /// <param name="share">The share for which the directories are to be counted.</param> - /// <returns>The number of directories.</returns> - public int CountDirectories(Share share) - { - var path = share.RemotePath + Path.DirectorySeparatorChar; - return Repository.CountDirectories(path); - } - - /// <summary> - /// Returns the number of files in the specified <paramref name="share"/>. - /// </summary> - /// <param name="share">The share for which the files are to be counted.</param> - /// <returns>The number of files.</returns> - public int CountFiles(Share share) - { - var path = share.RemotePath + Path.DirectorySeparatorChar; - return Repository.CountFiles(path); - } - - /// <summary> /// Scans the configured shares and fills the cache. /// </summary> /// <param name="shares">The list of shares from which to fill the cache.</param> |
