Usenet streaming with a WebDAV server and a SABnzbd-compatible API
C#
Added healthcheck columns to DavItems table.
nzbdav-devb0f88de930b0
diff --git a/backend/Database/DavDatabaseContext.cs b/backend/Database/DavDatabaseContext.csindex 8c5a25ab..3ad98d9d 100644--- a/backend/Database/DavDatabaseContext.cs+++ b/backend/Database/DavDatabaseContext.cs@@ -79,6 +79,27 @@ public sealed class DavDatabaseContext() : DbContext(Options.Value)e.Property(i => i.IdPrefix).IsRequired();+ e.Property(i => i.ReleaseDate)+ .ValueGeneratedNever()+ .HasConversion(+ x => x.HasValue ? x.Value.ToUnixTimeSeconds() : (long?)null,+ x => x.HasValue ? DateTimeOffset.FromUnixTimeSeconds(x.Value) : null+ );++ e.Property(i => i.LastHealthCheck)+ .ValueGeneratedNever()+ .HasConversion(+ x => x.HasValue ? x.Value.ToUnixTimeSeconds() : (long?)null,+ x => x.HasValue ? DateTimeOffset.FromUnixTimeSeconds(x.Value) : null+ );++ e.Property(i => i.NextHealthCheck)+ .ValueGeneratedNever()+ .HasConversion(+ x => x.HasValue ? x.Value.ToUnixTimeSeconds() : (long?)null,+ x => x.HasValue ? DateTimeOffset.FromUnixTimeSeconds(x.Value) : null+ );+e.HasOne(i => i.Parent).WithMany(p => p.Children).HasForeignKey(i => i.ParentId)diff --git a/backend/Database/Migrations/20251010192643_Add-Healthcheck-Columns-To-DavItems.Designer.cs b/backend/Database/Migrations/20251010192643_Add-Healthcheck-Columns-To-DavItems.Designer.csnew file mode 100644index 00000000..65f20d21--- /dev/null+++ b/backend/Database/Migrations/20251010192643_Add-Healthcheck-Columns-To-DavItems.Designer.cs@@ -0,0 +1,280 @@+// <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("20251010192643_Add-Healthcheck-Columns-To-DavItems")]+ partial class AddHealthcheckColumnsToDavItems+ {+ /// <inheritdoc />+ protected override void BuildTargetModel(ModelBuilder modelBuilder)+ {+#pragma warning disable 612, 618+ modelBuilder.HasAnnotation("ProductVersion", "9.0.4");++ 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.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.DavItem", b =>+ {+ b.Property<Guid>("Id")+ .HasColumnType("TEXT");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("TEXT");++ b.Property<long?>("FileSize")+ .HasColumnType("INTEGER");++ 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?>("ParentId")+ .HasColumnType("TEXT");++ b.Property<string>("Path")+ .IsRequired()+ .HasColumnType("TEXT");++ b.Property<long?>("ReleaseDate")+ .HasColumnType("INTEGER");++ b.Property<int>("Type")+ .HasColumnType("INTEGER");++ b.HasKey("Id");++ b.HasIndex("IdPrefix", "Type");++ b.HasIndex("ParentId", "Name")+ .IsUnique();++ b.ToTable("DavItems", (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.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<long>("TotalSegmentBytes")+ .HasColumnType("INTEGER");++ b.HasKey("Id");++ b.HasIndex("Category");++ b.HasIndex("CreatedAt");++ b.HasIndex("Category", "CreatedAt");++ b.HasIndex("Category", "DownloadDirId");++ b.ToTable("HistoryItems", (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<string>("NzbContents")+ .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.DavItem", b =>+ {+ b.HasOne("NzbWebDAV.Database.Models.DavItem", "Parent")+ .WithMany("Children")+ .HasForeignKey("ParentId")+ .OnDelete(DeleteBehavior.Cascade);++ b.Navigation("Parent");+ });++ 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.DavItem", b =>+ {+ b.Navigation("Children");+ });+#pragma warning restore 612, 618+ }+ }+}diff --git a/backend/Database/Migrations/20251010192643_Add-Healthcheck-Columns-To-DavItems.cs b/backend/Database/Migrations/20251010192643_Add-Healthcheck-Columns-To-DavItems.csnew file mode 100644index 00000000..bca21465--- /dev/null+++ b/backend/Database/Migrations/20251010192643_Add-Healthcheck-Columns-To-DavItems.cs@@ -0,0 +1,48 @@+using Microsoft.EntityFrameworkCore.Migrations;++#nullable disable++namespace NzbWebDAV.Database.Migrations+{+ /// <inheritdoc />+ public partial class AddHealthcheckColumnsToDavItems : Migration+ {+ /// <inheritdoc />+ protected override void Up(MigrationBuilder migrationBuilder)+ {+ migrationBuilder.AddColumn<long>(+ name: "LastHealthCheck",+ table: "DavItems",+ type: "INTEGER",+ nullable: true);++ migrationBuilder.AddColumn<long>(+ name: "NextHealthCheck",+ table: "DavItems",+ type: "INTEGER",+ nullable: true);++ migrationBuilder.AddColumn<long>(+ name: "ReleaseDate",+ table: "DavItems",+ type: "INTEGER",+ nullable: true);+ }++ /// <inheritdoc />+ protected override void Down(MigrationBuilder migrationBuilder)+ {+ migrationBuilder.DropColumn(+ name: "LastHealthCheck",+ table: "DavItems");++ migrationBuilder.DropColumn(+ name: "NextHealthCheck",+ table: "DavItems");++ migrationBuilder.DropColumn(+ name: "ReleaseDate",+ table: "DavItems");+ }+ }+}diff --git a/backend/Database/Migrations/DavDatabaseContextModelSnapshot.cs b/backend/Database/Migrations/DavDatabaseContextModelSnapshot.csindex 48795ffa..1bcf2156 100644--- a/backend/Database/Migrations/DavDatabaseContextModelSnapshot.cs+++ b/backend/Database/Migrations/DavDatabaseContextModelSnapshot.cs@@ -68,11 +68,17 @@ namespace NzbWebDAV.Database.Migrations.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?>("ParentId").HasColumnType("TEXT");@@ -80,6 +86,9 @@ namespace NzbWebDAV.Database.Migrations.IsRequired().HasColumnType("TEXT");+ b.Property<long?>("ReleaseDate")+ .HasColumnType("INTEGER");+b.Property<int>("Type").HasColumnType("INTEGER");diff --git a/backend/Database/Models/DavItem.cs b/backend/Database/Models/DavItem.csindex 23e38c6b..ced0e966 100644--- a/backend/Database/Models/DavItem.cs+++ b/backend/Database/Models/DavItem.cs@@ -14,6 +14,9 @@ public class DavItempublic long? FileSize { get; set; }public ItemType Type { get; init; }public string Path { get; init; } = null!;+ public DateTimeOffset? ReleaseDate { get; init; }+ public DateTimeOffset? LastHealthCheck { get; init; }+ public DateTimeOffset? NextHealthCheck { get; init; }public static DavItem New(