diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-05-03 18:44:16 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2026-05-03 18:44:16 -0500 |
| commit | d45e33185daf1e0320ce60e3c324dbf3efae49ef (patch) | |
| tree | 9df5b3ac64d212d6987a8aa50ef8a371ed478df5 | |
| parent | 08380a1a150f58839798ca3289aa8b5542f41086 (diff) | |
| download | slskd-d45e33185daf1e0320ce60e3c324dbf3efae49ef.tar.gz | |
rough in options json support
| -rw-r--r-- | src/slskd/Transfers/TransfersDbContext.cs | 9 | ||||
| -rw-r--r-- | src/slskd/Transfers/Types/Batch.cs | 8 | ||||
| -rw-r--r-- | src/slskd/Transfers/Types/BatchOptions.cs | 48 |
3 files changed, 59 insertions, 6 deletions
diff --git a/src/slskd/Transfers/TransfersDbContext.cs b/src/slskd/Transfers/TransfersDbContext.cs index ce2d9f52..699eed6c 100644 --- a/src/slskd/Transfers/TransfersDbContext.cs +++ b/src/slskd/Transfers/TransfersDbContext.cs @@ -33,6 +33,7 @@ namespace slskd.Transfers { using System; + using System.Text.Json; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; @@ -135,6 +136,14 @@ namespace slskd.Transfers .WithOne() .HasForeignKey(t => t.BatchId) .IsRequired(false); + + modelBuilder + .Entity<Batch>() + .Property(b => b.Options) + .HasConversion( + convertToProviderExpression: v => JsonSerializer.Serialize(v, JsonSerializerOptions.Default), + convertFromProviderExpression: v => JsonSerializer.Deserialize<BatchOptions>(v, JsonSerializerOptions.Default)) + .HasColumnType("TEXT"); } } } diff --git a/src/slskd/Transfers/Types/Batch.cs b/src/slskd/Transfers/Types/Batch.cs index 3da583f3..d4234e30 100644 --- a/src/slskd/Transfers/Types/Batch.cs +++ b/src/slskd/Transfers/Types/Batch.cs @@ -91,13 +91,9 @@ public record Batch public ICollection<Transfer> Transfers { get; init; } = null; /// <summary> - /// Gets the optional destination directory for the files in the Batch, relative to the configured - /// download directory. + /// Gets the options for the batch. /// </summary> - /// <remarks> - /// If specified, takes precedence over other configured placement rules. - /// </remarks> - public string DestinationDirectory { get; init; } + public BatchOptions Options { get; init; } /* future: [NotMapped] properties that aggregate values from the associated Transfer records. diff --git a/src/slskd/Transfers/Types/BatchOptions.cs b/src/slskd/Transfers/Types/BatchOptions.cs new file mode 100644 index 00000000..6bacef8c --- /dev/null +++ b/src/slskd/Transfers/Types/BatchOptions.cs @@ -0,0 +1,48 @@ +// <copyright file="BatchOptions.cs" company="JP Dillingham"> +// ▄▄▄▄ ▄▄▄▄ ▄▄▄▄ +// ▄▄▄▄▄▄█ █▄▄▄▄▄█ █▄▄▄▄▄█ █ +// █__ --█ █__ --█ ◄█ - █ +// █▄▄▄▄▄█▄▄█▄▄▄▄▄█▄▄█▄▄█▄▄▄▄▄█ +// ┍━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ━━━━ ━ ━┉ ┉ ┉ +// │ Copyright (c) JP Dillingham. +// │ +// │ This program is free software: you can redistribute it and/or modify +// │ it under the terms of the GNU Affero General Public License as published +// │ by the Free Software Foundation, version 3. +// │ +// │ This program is distributed in the hope that it will be useful, +// │ but WITHOUT ANY WARRANTY; without even the implied warranty of +// │ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// │ GNU Affero General Public License for more details. +// │ +// │ You should have received a copy of the GNU Affero General Public License +// │ along with this program. If not, see https://www.gnu.org/licenses/. +// │ +// │ This program is distributed with Additional Terms pursuant to Section 7 +// │ of the AGPLv3. See the LICENSE file in the root directory of this +// │ project for the complete terms and conditions. +// │ +// │ https://slskd.org +// │ +// ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ╌ ╌╌╌╌ ╌ +// │ SPDX-FileCopyrightText: JP Dillingham +// │ SPDX-License-Identifier: AGPL-3.0-only +// ╰───────────────────────────────────────────╶──── ─ ─── ─ ── ──┈ ┈ +// </copyright> + +namespace slskd.Transfers; + +/// <summary> +/// Options for <see cref="Batch"/>es. +/// </summary> +public record BatchOptions +{ + /// <summary> + /// Gets the optional destination directory for the files in the Batch, relative to the configured + /// download directory. + /// </summary> + /// <remarks> + /// If specified, takes precedence over other configured placement rules. + /// </remarks> + public string Destination { get; init; } +}
\ No newline at end of file |
