diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2022-09-10 17:37:33 -0500 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2022-09-10 17:37:33 -0500 |
| commit | dab9af45aa0d06b882c661fc3cddb6af6f61545e (patch) | |
| tree | ccebee3765dd903d1a61914227b3391cba82886e | |
| parent | 5e11cc0fc0703dc161140b28f7e2cd0f65facf9c (diff) | |
| download | slskd-dab9af45aa0d06b882c661fc3cddb6af6f61545e.tar.gz | |
add cache type
| -rw-r--r-- | config/slskd.example.yml | 3 | ||||
| -rw-r--r-- | src/slskd/Core/Options.cs | 47 |
2 files changed, 22 insertions, 28 deletions
diff --git a/config/slskd.example.yml b/config/slskd.example.yml index 46033bff..1f628077 100644 --- a/config/slskd.example.yml +++ b/config/slskd.example.yml @@ -19,7 +19,8 @@ # - \.ini$ # - Thumbs.db$ # - \.DS_Store$ -# cache_storage: memory +# cache: +# storage_mode: Memory # rooms: # - ~ # global: diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 327036aa..2d561e29 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -200,7 +200,6 @@ namespace slskd /// Gets share options. /// </summary> [Validate] - [RequiresRestart] public SharesOptions Shares { get; init; } = new SharesOptions(); /// <summary> @@ -376,12 +375,26 @@ namespace slskd public string[] Filters { get; init; } = Array.Empty<string>(); /// <summary> - /// Gets the type of storage to use for the share cache. + /// Share caching options. /// </summary> - [Argument(default, "share-cache-storage")] - [EnvironmentVariable("SHARE_CACHE_STORAGE")] - [Description("the type of storage to use for the cache")] - public StorageType CacheStorage { get; init; } = StorageType.Memory; + [Validate] + public ShareCacheOptions Cache { get; init; } = new ShareCacheOptions(); + + /// <summary> + /// Share caching options. + /// </summary> + public class ShareCacheOptions + { + /// <summary> + /// Gets the type of storage to use for the share cache. + /// </summary> + [Argument(default, "share-cache-storage-mode")] + [EnvironmentVariable("SHARE_CACHE_STORAGE_MODE")] + [Description("the type of storage to use for the cache")] + [Enum(typeof(StorageMode))] + [RequiresRestart] + public string StorageMode { get; init; } = slskd.StorageMode.Memory.ToString().ToLowerInvariant(); + } /// <summary> /// Extended validation. @@ -696,7 +709,7 @@ namespace slskd /// <summary> /// Filter options. /// </summary> - public class FiltersOptions : IValidatableObject + public class FiltersOptions { /// <summary> /// Gets search filter options. @@ -705,26 +718,6 @@ namespace slskd public SearchOptions Search { get; init; } = new SearchOptions(); /// <summary> - /// Extended validation. - /// </summary> - /// <param name="validationContext"></param> - /// <returns></returns> - public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) - { - var results = new List<ValidationResult>(); - - foreach (var filter in Share) - { - if (!filter.IsValidRegex()) - { - results.Add(new ValidationResult($"Share filter '{filter}' is not a valid regular expression")); - } - } - - return results; - } - - /// <summary> /// Search filter options. /// </summary> public class SearchOptions : IValidatableObject |
