Usenet streaming with a WebDAV server and a SABnzbd-compatible API
C#
Migrate the blocklisted-extensions setting to the new blocklisted-files format.
nzbdav-dev3c0c6cc62de3
diff --git a/backend/Database/Migrations/20260121033824_Populate-Blocklisted-Files-Setting.Designer.cs b/backend/Database/Migrations/20260121033824_Populate-Blocklisted-Files-Setting.Designer.csnew file mode 100644index 00000000..9ab1d752--- /dev/null+++ b/backend/Database/Migrations/20260121033824_Populate-Blocklisted-Files-Setting.Designer.cs@@ -0,0 +1,396 @@+// <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("20260121033824_Populate-Blocklisted-Files-Setting")]+ partial class PopulateBlocklistedFilesSetting+ {+ /// <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.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.HasIndex("Type", "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.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<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.DavItem", b =>+ {+ b.HasOne("NzbWebDAV.Database.Models.DavItem", "Parent")+ .WithMany("Children")+ .HasForeignKey("ParentId")+ .OnDelete(DeleteBehavior.Cascade);++ b.Navigation("Parent");+ });++ 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");+ });++ modelBuilder.Entity("NzbWebDAV.Database.Models.DavItem", b =>+ {+ b.Navigation("Children");+ });+#pragma warning restore 612, 618+ }+ }+}diff --git a/backend/Database/Migrations/20260121033824_Populate-Blocklisted-Files-Setting.cs b/backend/Database/Migrations/20260121033824_Populate-Blocklisted-Files-Setting.csnew file mode 100644index 00000000..9de4cfd1--- /dev/null+++ b/backend/Database/Migrations/20260121033824_Populate-Blocklisted-Files-Setting.cs@@ -0,0 +1,112 @@+using Microsoft.EntityFrameworkCore.Migrations;++#nullable disable++namespace NzbWebDAV.Database.Migrations+{+ /// <inheritdoc />+ public partial class PopulateBlocklistedFilesSetting : Migration+ {+ /// <inheritdoc />+ protected override void Up(MigrationBuilder migrationBuilder)+ {+ // Transform api.download-extension-blacklist (e.g., ".nfo, .par2, .sfv")+ // into api.download-file-blocklist (e.g., "*.nfo, *.par2, *.sfv")+ migrationBuilder.Sql("""+ WITH RECURSIVE+ source AS (+ SELECT "ConfigValue" AS val+ FROM "ConfigItems"+ WHERE "ConfigName" = 'api.download-extension-blacklist'+ ),+ split(item, rest) AS (+ SELECT+ '',+ val || ','+ FROM source+ WHERE val IS NOT NULL+ UNION ALL+ SELECT+ TRIM(SUBSTR(rest, 1, INSTR(rest, ',') - 1)),+ SUBSTR(rest, INSTR(rest, ',') + 1)+ FROM split+ WHERE rest <> ''+ ),+ transformed AS (+ SELECT+ GROUP_CONCAT('*' || item, ', ') AS new_val+ FROM split+ WHERE item <> ''+ )+ INSERT INTO "ConfigItems" ("ConfigName", "ConfigValue")+ SELECT 'api.download-file-blocklist', new_val+ FROM transformed+ WHERE new_val IS NOT NULL+ AND NOT EXISTS (+ SELECT 1 FROM "ConfigItems"+ WHERE "ConfigName" = 'api.download-file-blocklist'+ );+ """);++ migrationBuilder.Sql("""+ DELETE FROM "ConfigItems"+ WHERE "ConfigName" = 'api.download-extension-blacklist';+ """);+ }++ /// <inheritdoc />+ protected override void Down(MigrationBuilder migrationBuilder)+ {+ // Transform api.download-file-blocklist back to api.download-extension-blacklist+ // Only include items that can be cleanly converted (pattern: *.ext where ext has no wildcards)+ migrationBuilder.Sql("""+ WITH RECURSIVE+ source AS (+ SELECT "ConfigValue" AS val+ FROM "ConfigItems"+ WHERE "ConfigName" = 'api.download-file-blocklist'+ ),+ split(item, rest) AS (+ SELECT+ '',+ val || ','+ FROM source+ WHERE val IS NOT NULL+ UNION ALL+ SELECT+ TRIM(SUBSTR(rest, 1, INSTR(rest, ',') - 1)),+ SUBSTR(rest, INSTR(rest, ',') + 1)+ FROM split+ WHERE rest <> ''+ ),+ cleaned AS (+ SELECT+ SUBSTR(item, 2) AS ext -- Remove leading '*', leaving '.ext'+ FROM split+ WHERE item <> ''+ AND item LIKE '*.%' -- Must start with *.+ AND SUBSTR(item, 3) NOT LIKE '%*%' -- Extension part has no *+ AND SUBSTR(item, 3) NOT LIKE '%?%' -- Extension part has no ?+ ),+ transformed AS (+ SELECT+ GROUP_CONCAT(ext, ', ') AS old_val+ FROM cleaned+ )+ INSERT INTO "ConfigItems" ("ConfigName", "ConfigValue")+ SELECT 'api.download-extension-blacklist', old_val+ FROM transformed+ WHERE old_val IS NOT NULL+ AND NOT EXISTS (+ SELECT 1 FROM "ConfigItems"+ WHERE "ConfigName" = 'api.download-extension-blacklist'+ );+ """);++ migrationBuilder.Sql("""+ DELETE FROM "ConfigItems"+ WHERE "ConfigName" = 'api.download-file-blocklist';+ """);+ }+ }+}diff --git a/backend/Database/Migrations/DavDatabaseContextModelSnapshot.cs b/backend/Database/Migrations/DavDatabaseContextModelSnapshot.csindex 41ee8c55..ed4c89ac 100644--- a/backend/Database/Migrations/DavDatabaseContextModelSnapshot.cs+++ b/backend/Database/Migrations/DavDatabaseContextModelSnapshot.cs@@ -15,7 +15,7 @@ namespace NzbWebDAV.Database.Migrationsprotected override void BuildModel(ModelBuilder modelBuilder){#pragma warning disable 612, 618- modelBuilder.HasAnnotation("ProductVersion", "9.0.4");+ modelBuilder.HasAnnotation("ProductVersion", "10.0.1");modelBuilder.Entity("NzbWebDAV.Database.Models.Account", b =>{diff --git a/backend/Database/Models/ConfigItem.cs b/backend/Database/Models/ConfigItem.csindex 15f76780..4652844d 100644--- a/backend/Database/Models/ConfigItem.cs+++ b/backend/Database/Models/ConfigItem.cs@@ -1,23 +1,7 @@-using System.Collections.Immutable;--namespace NzbWebDAV.Database.Models;+namespace NzbWebDAV.Database.Models;public class ConfigItem{- public static readonly ImmutableHashSet<string> Keys = ImmutableHashSet.Create([- "api.key",- "api.categories",- "usenet.host",- "usenet.port",- "usenet.use-ssl",- "usenet.connections",- "usenet.user",- "usenet.pass",- "webdav.user",- "webdav.pass",- "rclone.mount-dir",- ]);-public string ConfigName { get; set; } = null!;public string ConfigValue { get; set; } = null!;}\ No newline at end of file