From 0190f96c8ec99404bcce5078917a1786ede510af Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 10 Oct 2022 15:31:38 -0500 Subject: return the resolved filename, not FileInfo. Add a way to request a scan --- src/slskd/Shares/IShareService.cs | 7 ++++++- src/slskd/Shares/ShareService.cs | 19 +++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/slskd/Shares/IShareService.cs b/src/slskd/Shares/IShareService.cs index 2a18f5b3..f8e2076d 100644 --- a/src/slskd/Shares/IShareService.cs +++ b/src/slskd/Shares/IShareService.cs @@ -60,7 +60,12 @@ namespace slskd.Shares /// /// Thrown when the specified remote filename can not be associated with a configured share. /// - Task ResolveFileAsync(string remoteFilename); + Task ResolveFileAsync(string remoteFilename); + + /// + /// Requests that a share scan is performed. + /// + void RequestScan(); /// /// Searches the cache for the specified and returns the matching files. diff --git a/src/slskd/Shares/ShareService.cs b/src/slskd/Shares/ShareService.cs index 09085b72..2b761965 100644 --- a/src/slskd/Shares/ShareService.cs +++ b/src/slskd/Shares/ShareService.cs @@ -173,7 +173,7 @@ namespace slskd.Shares /// /// Thrown when the specified remote filename can not be associated with a configured share. /// - public Task ResolveFileAsync(string remoteFilename) + public Task ResolveFileAsync(string remoteFilename) { var resolvedFilename = Repository.FindFilename(remoteFilename.LocalizePath()); @@ -182,16 +182,15 @@ namespace slskd.Shares throw new NotFoundException($"The requested filename '{remoteFilename}' could not be resolved to a local file"); } - var fileInfo = new FileInfo(resolvedFilename); - - if (!fileInfo.Exists) - { - // the shared file cache has divered from the physical filesystem; the user needs to perform a scan to reconcile. - State.SetValue(state => state with { ScanPending = true }); - throw new NotFoundException($"The resolved file '{resolvedFilename}' could not be located on disk. A share scan should be performed."); - } + return Task.FromResult(resolvedFilename); + } - return Task.FromResult(fileInfo); + /// + /// Requests that a share scan is performed. + /// + public void RequestScan() + { + State.SetValue(state => state with { ScanPending = true }); } /// -- cgit v1.2.3