From 5cdb5cc91786c5f49bfa1f136c1c71fc52367110 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Tue, 27 Sep 2022 09:36:29 -0500 Subject: refactor counting functions --- src/slskd/Shares/ShareService.cs | 6 ++++-- src/slskd/Shares/SharedFileCache.cs | 36 ------------------------------------ 2 files changed, 4 insertions(+), 38 deletions(-) (limited to 'src') 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 /// The summary information. 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 @@ -42,20 +42,6 @@ namespace slskd.Shares /// IStateMonitor StateMonitor { get; } - /// - /// 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. /// @@ -133,28 +119,6 @@ namespace slskd.Shares private CancellationTokenSource CancellationTokenSource { get; set; } private IShareRepository Repository { get; } - /// - /// 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 Repository.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 Repository.CountFiles(path); - } - /// /// Scans the configured shares and fills the cache. /// -- cgit v1.2.3