aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Transfers/TransfersDbContext.cs9
-rw-r--r--src/slskd/Transfers/Types/Batch.cs8
-rw-r--r--src/slskd/Transfers/Types/BatchOptions.cs48
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