aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2022-09-21 20:35:15 -0500
committerJP Dillingham <jp@dillingham.me>2022-09-21 20:35:15 -0500
commitf61ee9c602ba26688db090b0458ab49b768d5170 (patch)
tree0154987b3c9cc6cd01d95ba30f5111ad06e601ca
parent9bbedd6f504e33d908fe52815e9b58bcebf7baa4 (diff)
downloadslskd-f61ee9c602ba26688db090b0458ab49b768d5170.tar.gz
add CreateAsync
-rw-r--r--src/slskd/Shares/IShareService.cs10
-rw-r--r--src/slskd/Shares/ShareService.cs14
2 files changed, 24 insertions, 0 deletions
diff --git a/src/slskd/Shares/IShareService.cs b/src/slskd/Shares/IShareService.cs
index 962d4c1e..7ee39313 100644
--- a/src/slskd/Shares/IShareService.cs
+++ b/src/slskd/Shares/IShareService.cs
@@ -45,6 +45,16 @@ namespace slskd.Shares
Task<IEnumerable<Directory>> BrowseAsync();
/// <summary>
+ /// (Re)Creates the cache.
+ /// </summary>
+ /// <remarks>
+ /// This should generally only be called if <see cref="TryLoadFromDiskAsync"/> has returned false.
+ /// </remarks>
+ /// <param name="discardExisting">A value indicating whether an existing cache should be discarded prior to creation.</param>
+ /// <returns>The operation context.</returns>
+ Task CreateAsync(bool discardExisting = false);
+
+ /// <summary>
/// Returns the contents of the specified <paramref name="directory"/>.
/// </summary>
/// <param name="directory">The directory for which the contents are to be listed.</param>
diff --git a/src/slskd/Shares/ShareService.cs b/src/slskd/Shares/ShareService.cs
index 96ac4c1c..d40be652 100644
--- a/src/slskd/Shares/ShareService.cs
+++ b/src/slskd/Shares/ShareService.cs
@@ -99,6 +99,20 @@ namespace slskd.Shares
}
/// <summary>
+ /// (Re)Creates the cache.
+ /// </summary>
+ /// <remarks>
+ /// This should generally only be called if <see cref="TryLoadFromDiskAsync"/> has returned false.
+ /// </remarks>
+ /// <param name="discardExisting">A value indicating whether an existing cache should be discarded prior to creation.</param>
+ /// <returns>The operation context.</returns>
+ public Task CreateAsync(bool discardExisting = false)
+ {
+ Cache.Create(discardExisting);
+ return Task.CompletedTask;
+ }
+
+ /// <summary>
/// Returns the contents of the specified <paramref name="directory"/>.
/// </summary>
/// <param name="directory">The directory for which the contents are to be listed.</param>