aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Files/FileService.cs
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2023-06-19 22:32:52 -0500
committerJP Dillingham <jp@dillingham.me>2023-06-19 22:32:52 -0500
commite2451a8c1207566851c0baad99a78093441445ae (patch)
treefac64a01b049b6fd715dc5989602008d3be8c49b /src/slskd/Files/FileService.cs
parentf42aeae2f9db1d10e0804c6d798abb608eebe585 (diff)
downloadslskd-e2451a8c1207566851c0baad99a78093441445ae.tar.gz
rough in download listing
Diffstat (limited to 'src/slskd/Files/FileService.cs')
-rw-r--r--src/slskd/Files/FileService.cs22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/slskd/Files/FileService.cs b/src/slskd/Files/FileService.cs
index c38e6ff4..c03183d5 100644
--- a/src/slskd/Files/FileService.cs
+++ b/src/slskd/Files/FileService.cs
@@ -43,18 +43,24 @@ namespace slskd.Files
private IOptionsSnapshot<Options> OptionsSnapshot { get; }
- public async Task<IEnumerable<FileInfo>> ListDownloadedFiles()
+ /// <summary>
+ /// Recursively lists all of the files in the downloads directory, starting from the optional <paramref name="parentDirectory"/>, and
+ /// optionally applying the specified <paramref name="enumerationOptions"/>.
+ /// </summary>
+ /// <param name="parentDirectory">An optional parent directory from which to begin searching.</param>
+ /// <param name="enumerationOptions">Optional enumeration options to apply.</param>
+ /// <returns>The list of found files.</returns>
+ public async Task<IEnumerable<FileInfo>> ListDownloadedFiles(string parentDirectory = null, EnumerationOptions enumerationOptions = null)
{
- var dir = new DirectoryInfo(OptionsSnapshot.Value.Directories.Downloads);
+ var root = OptionsSnapshot.Value.Directories.Downloads;
+ parentDirectory = Path.Combine(root, parentDirectory) ?? root;
+ var dir = new DirectoryInfo(parentDirectory);
+
+ enumerationOptions ??= new EnumerationOptions();
var files = await Task.Run(() =>
{
- return dir.GetFiles("*", new EnumerationOptions
- {
- AttributesToSkip = FileAttributes.Hidden | FileAttributes.System,
- IgnoreInaccessible = false,
- RecurseSubdirectories = true,
- });
+ return dir.GetFiles("*", enumerationOptions);
});
return files.AsEnumerable();