Skip to content

Usenet streaming with a WebDAV server and a SABnzbd-compatible API

C#

Added database schema for NZB blob tracking.

nzbdav-dev5b2e949e5193
diff --git a/backend/Database/DavDatabaseContext.cs b/backend/Database/DavDatabaseContext.cs
index e7d98e2e..f8f0c8ef 100644
--- a/backend/Database/DavDatabaseContext.cs
+++ b/backend/Database/DavDatabaseContext.cs
@@ -39,6 +39,8 @@ public sealed class DavDatabaseContext() : DbContext(Options.Value)
public DbSet<BlobCleanupItem> BlobCleanupItems => Set<BlobCleanupItem>();
public DbSet<HistoryCleanupItem> HistoryCleanupItems => Set<HistoryCleanupItem>();
public DbSet<DavCleanupItem> DavCleanupItems => Set<DavCleanupItem>();
+ public DbSet<NzbName> NzbNames => Set<NzbName>();
+ public DbSet<NzbBlobCleanupItem> NzbBlobCleanupItems => Set<NzbBlobCleanupItem>();
// blob items
public List<DavNzbFile> BlobNzbFiles = [];
@@ -129,6 +131,10 @@ public sealed class DavDatabaseContext() : DbContext(Options.Value)
.ValueGeneratedNever()
.IsRequired(false);
+ e.Property(i => i.NzbBlobId)
+ .ValueGeneratedNever()
+ .IsRequired(false);
+
e.HasIndex(i => new { i.ParentId, i.Name })
.IsUnique();
@@ -139,6 +145,9 @@ public sealed class DavDatabaseContext() : DbContext(Options.Value)
e.HasIndex(i => new { i.HistoryItemId, i.Type, i.CreatedAt });
e.HasIndex(i => new { i.HistoryItemId, i.SubType, i.CreatedAt });
+
+ e.HasIndex(i => i.NzbBlobId)
+ .IsUnique(false);
});
// DavNzbFile
@@ -311,6 +320,9 @@ public sealed class DavDatabaseContext() : DbContext(Options.Value)
e.Property(i => i.DownloadDirId)
.IsRequired(false);
+ e.Property(i => i.NzbBlobId)
+ .IsRequired(false);
+
e.HasIndex(i => new { i.CreatedAt })
.IsUnique(false);
@@ -322,6 +334,9 @@ public sealed class DavDatabaseContext() : DbContext(Options.Value)
e.HasIndex(i => new { i.Category, i.DownloadDirId })
.IsUnique(false);
+
+ e.HasIndex(i => i.NzbBlobId)
+ .IsUnique(false);
});
// QueueNzbContents
@@ -463,6 +478,29 @@ public sealed class DavDatabaseContext() : DbContext(Options.Value)
e.Property(i => i.Id)
.ValueGeneratedNever();
});
+
+ // NzbName
+ b.Entity<NzbName>(e =>
+ {
+ e.ToTable("NzbNames");
+ e.HasKey(i => i.Id);
+
+ e.Property(i => i.Id)
+ .ValueGeneratedNever();
+
+ e.Property(i => i.FileName)
+ .IsRequired();
+ });
+
+ // NzbBlobCleanupItem
+ b.Entity<NzbBlobCleanupItem>(e =>
+ {
+ e.ToTable("NzbBlobCleanupItems");
+ e.HasKey(i => i.Id);
+
+ e.Property(i => i.Id)
+ .ValueGeneratedNever();
+ });
}
public override async Task<int> SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken())
diff --git a/backend/Database/DavDatabaseContextFactory.cs b/backend/Database/DavDatabaseContextFactory.cs
new file mode 100644
index 00000000..569c37a9
--- /dev/null
+++ b/backend/Database/DavDatabaseContextFactory.cs
@@ -0,0 +1,15 @@
+using Microsoft.EntityFrameworkCore.Design;
+
+namespace NzbWebDAV.Database;
+
+/// <summary>
+/// Allows EF Core design-time tools (dotnet-ef) to create a DavDatabaseContext
+/// without bootstrapping the full application host (Program.cs).
+/// </summary>
+public class DavDatabaseContextFactory : IDesignTimeDbContextFactory<DavDatabaseContext>
+{
+ public DavDatabaseContext CreateDbContext(string[] args)
+ {
+ return new DavDatabaseContext();
+ }
+}
diff --git a/backend/Database/Migrations/20260226053712_Add-NzbBlobId-And-NzbNames.Designer.cs b/backend/Database/Migrations/20260226053712_Add-NzbBlobId-And-NzbNames.Designer.cs
new file mode 100644
index 00000000..6b6bf0d3
--- /dev/null
+++ b/backend/Database/Migrations/20260226053712_Add-NzbBlobId-And-NzbNames.Designer.cs
@@ -0,0 +1,451 @@
+// <auto-generated />
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using NzbWebDAV.Database;
+
+#nullable disable
+
+namespace NzbWebDAV.Database.Migrations
+{
+ [DbContext(typeof(DavDatabaseContext))]
+ [Migration("20260226053712_Add-NzbBlobId-And-NzbNames")]
+ partial class AddNzbBlobIdAndNzbNames
+ {
+ /// <inheritdoc />
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "10.0.1");
+
+ modelBuilder.Entity("NzbWebDAV.Database.Models.Account", b =>
+ {
+ b.Property<int>("Type")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Username")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.Property<string>("PasswordHash")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property<string>("RandomSalt")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Type", "Username");
+
+ b.ToTable("Accounts", (string)null);
+ });
+
+ modelBuilder.Entity("NzbWebDAV.Database.Models.BlobCleanupItem", b =>
+ {
+ b.Property<Guid>("Id")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("BlobCleanupItems", (string)null);
+ });
+
+ modelBuilder.Entity("NzbWebDAV.Database.Models.ConfigItem", b =>
+ {
+ b.Property<string>("ConfigName")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("ConfigValue")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("ConfigName");
+
+ b.ToTable("ConfigItems", (string)null);
+ });
+
+ modelBuilder.Entity("NzbWebDAV.Database.Models.DavCleanupItem", b =>
+ {
+ b.Property<Guid>("Id")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("DavCleanupItems", (string)null);
+ });
+
+ modelBuilder.Entity("NzbWebDAV.Database.Models.DavItem", b =>
+ {
+ b.Property<Guid>("Id")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property<Guid?>("FileBlobId")
+ .HasColumnType("TEXT");
+
+ b.Property<long?>("FileSize")
+ .HasColumnType("INTEGER");
+
+ b.Property<Guid?>("HistoryItemId")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("IdPrefix")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property<long?>("LastHealthCheck")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Name")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.Property<long?>("NextHealthCheck")
+ .HasColumnType("INTEGER");
+
+ b.Property<Guid?>("NzbBlobId")
+ .HasColumnType("TEXT");
+
+ b.Property<Guid?>("ParentId")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Path")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property<long?>("ReleaseDate")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SubType")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("Type")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NzbBlobId");
+
+ b.HasIndex("IdPrefix", "Type");
+
+ b.HasIndex("ParentId", "Name")
+ .IsUnique();
+
+ b.HasIndex("HistoryItemId", "SubType", "CreatedAt");
+
+ b.HasIndex("HistoryItemId", "Type", "CreatedAt");
+
+ b.HasIndex("Type", "HistoryItemId", "NextHealthCheck", "ReleaseDate", "Id");
+
+ b.ToTable("DavItems", (string)null);
+ });
+
+ modelBuilder.Entity("NzbWebDAV.Database.Models.DavMultipartFile", b =>
+ {
+ b.Property<Guid>("Id")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Metadata")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("DavMultipartFiles", (string)null);
+ });
+
+ modelBuilder.Entity("NzbWebDAV.Database.Models.DavNzbFile", b =>
+ {
+ b.Property<Guid>("Id")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("SegmentIds")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("DavNzbFiles", (string)null);
+ });
+
+ modelBuilder.Entity("NzbWebDAV.Database.Models.DavRarFile", b =>
+ {
+ b.Property<Guid>("Id")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("RarParts")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("DavRarFiles", (string)null);
+ });
+
+ modelBuilder.Entity("NzbWebDAV.Database.Models.HealthCheckResult", b =>
+ {
+ b.Property<Guid>("Id")
+ .HasColumnType("TEXT");
+
+ b.Property<long>("CreatedAt")
+ .HasColumnType("INTEGER");
+
+ b.Property<Guid>("DavItemId")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Message")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Path")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property<int>("RepairStatus")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("Result")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("CreatedAt");
+
+ b.HasIndex("DavItemId")
+ .HasFilter("\"RepairStatus\" = 3");
+
+ b.HasIndex("Result", "RepairStatus", "CreatedAt");
+
+ b.ToTable("HealthCheckResults", (string)null);
+ });
+
+ modelBuilder.Entity("NzbWebDAV.Database.Models.HealthCheckStat", b =>
+ {
+ b.Property<long>("DateStartInclusive")
+ .HasColumnType("INTEGER");
+
+ b.Property<long>("DateEndExclusive")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("Result")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("RepairStatus")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("Count")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("DateStartInclusive", "DateEndExclusive", "Result", "RepairStatus");
+
+ b.ToTable("HealthCheckStats", (string)null);
+ });
+
+ modelBuilder.Entity("NzbWebDAV.Database.Models.HistoryCleanupItem", b =>
+ {
+ b.Property<Guid>("Id")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("DeleteMountedFiles")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.ToTable("HistoryCleanupItems", (string)null);
+ });
+
+ modelBuilder.Entity("NzbWebDAV.Database.Models.HistoryItem", b =>
+ {
+ b.Property<Guid>("Id")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Category")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property<Guid?>("DownloadDirId")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("DownloadStatus")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("DownloadTimeSeconds")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("FailMessage")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("FileName")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property<string>("JobName")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property<Guid?>("NzbBlobId")
+ .HasColumnType("TEXT");
+
+ b.Property<long>("TotalSegmentBytes")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Category");
+
+ b.HasIndex("CreatedAt");
+
+ b.HasIndex("NzbBlobId");
+
+ b.HasIndex("Category", "CreatedAt");
+
+ b.HasIndex("Category", "DownloadDirId");
+
+ b.ToTable("HistoryItems", (string)null);
+ });
+
+ modelBuilder.Entity("NzbWebDAV.Database.Models.NzbBlobCleanupItem", b =>
+ {
+ b.Property<Guid>("Id")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("NzbBlobCleanupItems", (string)null);
+ });
+
+ modelBuilder.Entity("NzbWebDAV.Database.Models.NzbName", b =>
+ {
+ b.Property<Guid>("Id")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("FileName")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("NzbNames", (string)null);
+ });
+
+ modelBuilder.Entity("NzbWebDAV.Database.Models.QueueItem", b =>
+ {
+ b.Property<Guid>("Id")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Category")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("FileName")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property<string>("JobName")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property<long>("NzbFileSize")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime?>("PauseUntil")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("PostProcessing")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("Priority")
+ .HasColumnType("INTEGER");
+
+ b.Property<long>("TotalSegmentBytes")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Category");
+
+ b.HasIndex("CreatedAt");
+
+ b.HasIndex("FileName")
+ .IsUnique();
+
+ b.HasIndex("Priority");
+
+ b.HasIndex("Priority", "CreatedAt");
+
+ b.HasIndex("Category", "Priority", "CreatedAt");
+
+ b.ToTable("QueueItems", (string)null);
+ });
+
+ modelBuilder.Entity("NzbWebDAV.Database.Models.QueueNzbContents", b =>
+ {
+ b.Property<Guid>("Id")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("NzbContents")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("QueueNzbContents", (string)null);
+ });
+
+ modelBuilder.Entity("NzbWebDAV.Database.Models.DavMultipartFile", b =>
+ {
+ b.HasOne("NzbWebDAV.Database.Models.DavItem", "DavItem")
+ .WithOne()
+ .HasForeignKey("NzbWebDAV.Database.Models.DavMultipartFile", "Id")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("DavItem");
+ });
+
+ modelBuilder.Entity("NzbWebDAV.Database.Models.DavNzbFile", b =>
+ {
+ b.HasOne("NzbWebDAV.Database.Models.DavItem", "DavItem")
+ .WithOne()
+ .HasForeignKey("NzbWebDAV.Database.Models.DavNzbFile", "Id")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("DavItem");
+ });
+
+ modelBuilder.Entity("NzbWebDAV.Database.Models.DavRarFile", b =>
+ {
+ b.HasOne("NzbWebDAV.Database.Models.DavItem", "DavItem")
+ .WithOne()
+ .HasForeignKey("NzbWebDAV.Database.Models.DavRarFile", "Id")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("DavItem");
+ });
+
+ modelBuilder.Entity("NzbWebDAV.Database.Models.QueueNzbContents", b =>
+ {
+ b.HasOne("NzbWebDAV.Database.Models.QueueItem", "QueueItem")
+ .WithOne()
+ .HasForeignKey("NzbWebDAV.Database.Models.QueueNzbContents", "Id")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("QueueItem");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/backend/Database/Migrations/20260226053712_Add-NzbBlobId-And-NzbNames.cs b/backend/Database/Migrations/20260226053712_Add-NzbBlobId-And-NzbNames.cs
new file mode 100644
index 00000000..85a2526a
--- /dev/null
+++ b/backend/Database/Migrations/20260226053712_Add-NzbBlobId-And-NzbNames.cs
@@ -0,0 +1,145 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace NzbWebDAV.Database.Migrations
+{
+ /// <inheritdoc />
+ public partial class AddNzbBlobIdAndNzbNames : Migration
+ {
+ /// <inheritdoc />
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn<Guid>(
+ name: "NzbBlobId",
+ table: "HistoryItems",
+ type: "TEXT",
+ nullable: true);
+
+ migrationBuilder.AddColumn<Guid>(
+ name: "NzbBlobId",
+ table: "DavItems",
+ type: "TEXT",
+ nullable: true);
+
+ migrationBuilder.CreateTable(
+ name: "NzbBlobCleanupItems",
+ columns: table => new
+ {
+ Id = table.Column<Guid>(type: "TEXT", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_NzbBlobCleanupItems", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "NzbNames",
+ columns: table => new
+ {
+ Id = table.Column<Guid>(type: "TEXT", nullable: false),
+ FileName = table.Column<string>(type: "TEXT", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_NzbNames", x => x.Id);
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_HistoryItems_NzbBlobId",
+ table: "HistoryItems",
+ column: "NzbBlobId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_DavItems_NzbBlobId",
+ table: "DavItems",
+ column: "NzbBlobId");
+
+ // Replace the old QueueItems trigger (which inserted into BlobCleanupItems)
+ // with a new one that inserts into NzbBlobCleanupItems instead.
+ migrationBuilder.Sql("DROP TRIGGER IF EXISTS TR_QueueItems_AddBlobCleanup");
+
+ migrationBuilder.Sql(
+ """
+ CREATE TRIGGER TR_QueueItems_AddNzbBlobCleanup
+ AFTER DELETE ON QueueItems
+ BEGIN
+ INSERT OR IGNORE INTO NzbBlobCleanupItems (Id)
+ VALUES (OLD.Id);
+ END
+ """
+ );
+
+ // When a HistoryItem is deleted, schedule its NZB blob for cleanup.
+ migrationBuilder.Sql(
+ """
+ CREATE TRIGGER TR_HistoryItems_Delete_AddNzbBlobCleanup
+ AFTER DELETE ON HistoryItems
+ WHEN OLD.NzbBlobId IS NOT NULL
+ BEGIN
+ INSERT OR IGNORE INTO NzbBlobCleanupItems (Id)
+ VALUES (OLD.NzbBlobId);
+ END
+ """
+ );
+
+ // When a DavItem is deleted, schedule its NZB blob for cleanup.
+ // INSERT OR IGNORE handles the case where multiple DavItems share the
+ // same NzbBlobId (all files from the same download job).
+ migrationBuilder.Sql(
+ """
+ CREATE TRIGGER TR_DavItems_Delete_AddNzbBlobCleanup
+ AFTER DELETE ON DavItems
+ WHEN OLD.NzbBlobId IS NOT NULL
+ BEGIN
+ INSERT OR IGNORE INTO NzbBlobCleanupItems (Id)
+ VALUES (OLD.NzbBlobId);
+ END
+ """
+ );
+ }
+
+ /// <inheritdoc />
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.Sql("DROP TRIGGER IF EXISTS TR_DavItems_Delete_AddNzbBlobCleanup");
+ migrationBuilder.Sql("DROP TRIGGER IF EXISTS TR_HistoryItems_Delete_AddNzbBlobCleanup");
+ migrationBuilder.Sql("DROP TRIGGER IF EXISTS TR_QueueItems_AddNzbBlobCleanup");
+
+ // Restore the original QueueItems trigger
+ migrationBuilder.Sql(
+ """
+ CREATE TRIGGER TR_QueueItems_AddBlobCleanup
+ AFTER DELETE ON QueueItems
+ BEGIN
+ INSERT INTO BlobCleanupItems (Id)
+ VALUES (OLD.Id);
+ END
+ """
+ );
+
+ migrationBuilder.DropTable(
+ name: "NzbBlobCleanupItems");
+
+ migrationBuilder.DropTable(
+ name: "NzbNames");
+
+ migrationBuilder.DropIndex(
+ name: "IX_HistoryItems_NzbBlobId",
+ table: "HistoryItems");
+
+ migrationBuilder.DropIndex(
+ name: "IX_DavItems_NzbBlobId",
+ table: "DavItems");
+
+ migrationBuilder.DropColumn(
+ name: "NzbBlobId",
+ table: "HistoryItems");
+
+ migrationBuilder.DropColumn(
+ name: "NzbBlobId",
+ table: "DavItems");
+ }
+ }
+}
diff --git a/backend/Database/Migrations/DavDatabaseContextModelSnapshot.cs b/backend/Database/Migrations/DavDatabaseContextModelSnapshot.cs
index 92de4181..7ac57c84 100644
--- a/backend/Database/Migrations/DavDatabaseContextModelSnapshot.cs
+++ b/backend/Database/Migrations/DavDatabaseContextModelSnapshot.cs
@@ -105,6 +105,9 @@ namespace NzbWebDAV.Database.Migrations
b.Property<long?>("NextHealthCheck")
.HasColumnType("INTEGER");
+ b.Property<Guid?>("NzbBlobId")
+ .HasColumnType("TEXT");
+
b.Property<Guid?>("ParentId")
.HasColumnType("TEXT");
@@ -123,6 +126,8 @@ namespace NzbWebDAV.Database.Migrations
b.HasKey("Id");
+ b.HasIndex("NzbBlobId");
+
b.HasIndex("IdPrefix", "Type");
b.HasIndex("ParentId", "Name")
@@ -282,6 +287,9 @@ namespace NzbWebDAV.Database.Migrations
.IsRequired()
.HasColumnType("TEXT");
+ b.Property<Guid?>("NzbBlobId")
+ .HasColumnType("TEXT");
+
b.Property<long>("TotalSegmentBytes")
.HasColumnType("INTEGER");
@@ -291,6 +299,8 @@ namespace NzbWebDAV.Database.Migrations
b.HasIndex("CreatedAt");
+ b.HasIndex("NzbBlobId");
+
b.HasIndex("Category", "CreatedAt");
b.HasIndex("Category", "DownloadDirId");
@@ -298,6 +308,30 @@ namespace NzbWebDAV.Database.Migrations
b.ToTable("HistoryItems", (string)null);
});
+ modelBuilder.Entity("NzbWebDAV.Database.Models.NzbBlobCleanupItem", b =>
+ {
+ b.Property<Guid>("Id")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("NzbBlobCleanupItems", (string)null);
+ });
+
+ modelBuilder.Entity("NzbWebDAV.Database.Models.NzbName", b =>
+ {
+ b.Property<Guid>("Id")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("FileName")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("NzbNames", (string)null);
+ });
+
modelBuilder.Entity("NzbWebDAV.Database.Models.QueueItem", b =>
{
b.Property<Guid>("Id")
diff --git a/backend/Database/Models/DavItem.cs b/backend/Database/Models/DavItem.cs
index f559defc..a575ef06 100644
--- a/backend/Database/Models/DavItem.cs
+++ b/backend/Database/Models/DavItem.cs
@@ -21,6 +21,7 @@ public class DavItem
public DateTimeOffset? NextHealthCheck { get; set; }
public Guid? HistoryItemId { get; set; }
public Guid? FileBlobId { get; set; }
+ public Guid? NzbBlobId { get; set; }
public static DavItem New
(
diff --git a/backend/Database/Models/HistoryItem.cs b/backend/Database/Models/HistoryItem.cs
index defa01ae..3657fe57 100644
--- a/backend/Database/Models/HistoryItem.cs
+++ b/backend/Database/Models/HistoryItem.cs
@@ -12,6 +12,7 @@ public class HistoryItem
public int DownloadTimeSeconds { get; set; }
public string? FailMessage { get; set; }
public Guid? DownloadDirId { get; set; }
+ public Guid? NzbBlobId { get; set; }
public enum DownloadStatusOption
{
diff --git a/backend/Database/Models/NzbBlobCleanupItem.cs b/backend/Database/Models/NzbBlobCleanupItem.cs
new file mode 100644
index 00000000..9aceafc3
--- /dev/null
+++ b/backend/Database/Models/NzbBlobCleanupItem.cs
@@ -0,0 +1,6 @@
+namespace NzbWebDAV.Database.Models;
+
+public class NzbBlobCleanupItem
+{
+ public Guid Id { get; set; }
+}
diff --git a/backend/Database/Models/NzbName.cs b/backend/Database/Models/NzbName.cs
new file mode 100644
index 00000000..a2015022
--- /dev/null
+++ b/backend/Database/Models/NzbName.cs
@@ -0,0 +1,7 @@
+namespace NzbWebDAV.Database.Models;
+
+public class NzbName
+{
+ public Guid Id { get; set; }
+ public string FileName { get; set; } = null!;
+}