From 67d4287c0c46bde05c3fbd0e00020c6c42664c6c Mon Sep 17 00:00:00 2001 From: Kevin Date: Wed, 13 Nov 2019 14:42:30 +0900 Subject: [PATCH 01/22] Add HasIcon Column to Package --- src/BaGet.Core/Entities/Package.cs | 1 + ...0191113053926_AddHasIconColumn.Designer.cs | 197 +++++++++++++++++ .../20191113053926_AddHasIconColumn.cs | 40 ++++ .../Migrations/MySqlContextModelSnapshot.cs | 24 ++- ...0191113054029_AddHasIconColumn.Designer.cs | 204 ++++++++++++++++++ .../20191113054029_AddHasIconColumn.cs | 23 ++ .../PostgreSqlContextModelSnapshot.cs | 24 ++- ...0191113054208_AddHasIconColumn.Designer.cs | 203 +++++++++++++++++ .../20191113054208_AddHasIconColumn.cs | 23 ++ .../SqlServerContextModelSnapshot.cs | 24 ++- ...0191113053824_AddHasIconColumn.Designer.cs | 200 +++++++++++++++++ .../20191113053824_AddHasIconColumn.cs | 23 ++ .../Migrations/SqliteContextModelSnapshot.cs | 24 ++- 13 files changed, 966 insertions(+), 44 deletions(-) create mode 100644 src/BaGet.Database.MySql/Migrations/20191113053926_AddHasIconColumn.Designer.cs create mode 100644 src/BaGet.Database.MySql/Migrations/20191113053926_AddHasIconColumn.cs create mode 100644 src/BaGet.Database.PostgreSql/Migrations/20191113054029_AddHasIconColumn.Designer.cs create mode 100644 src/BaGet.Database.PostgreSql/Migrations/20191113054029_AddHasIconColumn.cs create mode 100644 src/BaGet.Database.SqlServer/Migrations/20191113054208_AddHasIconColumn.Designer.cs create mode 100644 src/BaGet.Database.SqlServer/Migrations/20191113054208_AddHasIconColumn.cs create mode 100644 src/BaGet.Database.Sqlite/Migrations/20191113053824_AddHasIconColumn.Designer.cs create mode 100644 src/BaGet.Database.Sqlite/Migrations/20191113053824_AddHasIconColumn.cs diff --git a/src/BaGet.Core/Entities/Package.cs b/src/BaGet.Core/Entities/Package.cs index 269bbeb6e..bcf874506 100644 --- a/src/BaGet.Core/Entities/Package.cs +++ b/src/BaGet.Core/Entities/Package.cs @@ -34,6 +34,7 @@ public NuGetVersion Version public string Description { get; set; } public long Downloads { get; set; } public bool HasReadme { get; set; } + public bool HasIcon { get; set; } public bool IsPrerelease { get; set; } public string Language { get; set; } public bool Listed { get; set; } diff --git a/src/BaGet.Database.MySql/Migrations/20191113053926_AddHasIconColumn.Designer.cs b/src/BaGet.Database.MySql/Migrations/20191113053926_AddHasIconColumn.Designer.cs new file mode 100644 index 000000000..647580e90 --- /dev/null +++ b/src/BaGet.Database.MySql/Migrations/20191113053926_AddHasIconColumn.Designer.cs @@ -0,0 +1,197 @@ +// +using System; +using BaGet.Database.MySql; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace BaGet.Database.MySql.Migrations +{ + [DbContext(typeof(MySqlContext))] + [Migration("20191113053926_AddHasIconColumn")] + partial class AddHasIconColumn + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("BaGet.Core.Package", b => + { + b.Property("Key") + .ValueGeneratedOnAdd(); + + b.Property("Authors") + .HasMaxLength(4000); + + b.Property("Description") + .HasMaxLength(4000); + + b.Property("Downloads"); + + b.Property("HasIcon"); + + b.Property("HasReadme"); + + b.Property("IconUrl") + .HasMaxLength(4000); + + b.Property("Id") + .IsRequired() + .HasMaxLength(128); + + b.Property("IsPrerelease"); + + b.Property("Language") + .HasMaxLength(20); + + b.Property("LicenseUrl") + .HasMaxLength(4000); + + b.Property("Listed"); + + b.Property("MinClientVersion") + .HasMaxLength(44); + + b.Property("NormalizedVersionString") + .IsRequired() + .HasColumnName("Version") + .HasMaxLength(64); + + b.Property("OriginalVersionString") + .HasColumnName("OriginalVersion") + .HasMaxLength(64); + + b.Property("ProjectUrl") + .HasMaxLength(4000); + + b.Property("Published"); + + b.Property("RepositoryType") + .HasMaxLength(100); + + b.Property("RepositoryUrl") + .HasMaxLength(4000); + + b.Property("RequireLicenseAcceptance"); + + b.Property("RowVersion") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate(); + + b.Property("SemVerLevel"); + + b.Property("Summary") + .HasMaxLength(4000); + + b.Property("Tags") + .HasMaxLength(4000); + + b.Property("Title") + .HasMaxLength(256); + + b.HasKey("Key"); + + b.HasIndex("Id"); + + b.HasIndex("Id", "NormalizedVersionString") + .IsUnique(); + + b.ToTable("Packages"); + }); + + modelBuilder.Entity("BaGet.Core.PackageDependency", b => + { + b.Property("Key") + .ValueGeneratedOnAdd(); + + b.Property("Id") + .HasMaxLength(128); + + b.Property("PackageKey"); + + b.Property("TargetFramework") + .HasMaxLength(256); + + b.Property("VersionRange") + .HasMaxLength(256); + + b.HasKey("Key"); + + b.HasIndex("Id"); + + b.HasIndex("PackageKey"); + + b.ToTable("PackageDependencies"); + }); + + modelBuilder.Entity("BaGet.Core.PackageType", b => + { + b.Property("Key") + .ValueGeneratedOnAdd(); + + b.Property("Name") + .HasMaxLength(512); + + b.Property("PackageKey"); + + b.Property("Version") + .HasMaxLength(64); + + b.HasKey("Key"); + + b.HasIndex("Name"); + + b.HasIndex("PackageKey"); + + b.ToTable("PackageTypes"); + }); + + modelBuilder.Entity("BaGet.Core.TargetFramework", b => + { + b.Property("Key") + .ValueGeneratedOnAdd(); + + b.Property("Moniker") + .HasMaxLength(256); + + b.Property("PackageKey"); + + b.HasKey("Key"); + + b.HasIndex("Moniker"); + + b.HasIndex("PackageKey"); + + b.ToTable("TargetFrameworks"); + }); + + modelBuilder.Entity("BaGet.Core.PackageDependency", b => + { + b.HasOne("BaGet.Core.Package", "Package") + .WithMany("Dependencies") + .HasForeignKey("PackageKey"); + }); + + modelBuilder.Entity("BaGet.Core.PackageType", b => + { + b.HasOne("BaGet.Core.Package", "Package") + .WithMany("PackageTypes") + .HasForeignKey("PackageKey") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("BaGet.Core.TargetFramework", b => + { + b.HasOne("BaGet.Core.Package", "Package") + .WithMany("TargetFrameworks") + .HasForeignKey("PackageKey") + .OnDelete(DeleteBehavior.Cascade); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/BaGet.Database.MySql/Migrations/20191113053926_AddHasIconColumn.cs b/src/BaGet.Database.MySql/Migrations/20191113053926_AddHasIconColumn.cs new file mode 100644 index 000000000..d67db93e4 --- /dev/null +++ b/src/BaGet.Database.MySql/Migrations/20191113053926_AddHasIconColumn.cs @@ -0,0 +1,40 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace BaGet.Database.MySql.Migrations +{ + public partial class AddHasIconColumn : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "RowVersion", + table: "Packages", + rowVersion: true, + nullable: true, + oldClrType: typeof(DateTime), + oldNullable: true); + + migrationBuilder.AddColumn( + name: "HasIcon", + table: "Packages", + nullable: false, + defaultValue: false); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "HasIcon", + table: "Packages"); + + migrationBuilder.AlterColumn( + name: "RowVersion", + table: "Packages", + nullable: true, + oldClrType: typeof(DateTime), + oldRowVersion: true, + oldNullable: true); + } + } +} diff --git a/src/BaGet.Database.MySql/Migrations/MySqlContextModelSnapshot.cs b/src/BaGet.Database.MySql/Migrations/MySqlContextModelSnapshot.cs index 1e8e9c526..f84bd9f42 100644 --- a/src/BaGet.Database.MySql/Migrations/MySqlContextModelSnapshot.cs +++ b/src/BaGet.Database.MySql/Migrations/MySqlContextModelSnapshot.cs @@ -14,10 +14,10 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.2.6-servicing-10079") + .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") .HasAnnotation("Relational:MaxIdentifierLength", 64); - modelBuilder.Entity("BaGet.Core.Entities.Package", b => + modelBuilder.Entity("BaGet.Core.Package", b => { b.Property("Key") .ValueGeneratedOnAdd(); @@ -30,6 +30,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Downloads"); + b.Property("HasIcon"); + b.Property("HasReadme"); b.Property("IconUrl") @@ -99,7 +101,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("Packages"); }); - modelBuilder.Entity("BaGet.Core.Entities.PackageDependency", b => + modelBuilder.Entity("BaGet.Core.PackageDependency", b => { b.Property("Key") .ValueGeneratedOnAdd(); @@ -124,7 +126,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("PackageDependencies"); }); - modelBuilder.Entity("BaGet.Core.Entities.PackageType", b => + modelBuilder.Entity("BaGet.Core.PackageType", b => { b.Property("Key") .ValueGeneratedOnAdd(); @@ -146,7 +148,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("PackageTypes"); }); - modelBuilder.Entity("BaGet.Core.Entities.TargetFramework", b => + modelBuilder.Entity("BaGet.Core.TargetFramework", b => { b.Property("Key") .ValueGeneratedOnAdd(); @@ -165,24 +167,24 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("TargetFrameworks"); }); - modelBuilder.Entity("BaGet.Core.Entities.PackageDependency", b => + modelBuilder.Entity("BaGet.Core.PackageDependency", b => { - b.HasOne("BaGet.Core.Entities.Package", "Package") + b.HasOne("BaGet.Core.Package", "Package") .WithMany("Dependencies") .HasForeignKey("PackageKey"); }); - modelBuilder.Entity("BaGet.Core.Entities.PackageType", b => + modelBuilder.Entity("BaGet.Core.PackageType", b => { - b.HasOne("BaGet.Core.Entities.Package", "Package") + b.HasOne("BaGet.Core.Package", "Package") .WithMany("PackageTypes") .HasForeignKey("PackageKey") .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity("BaGet.Core.Entities.TargetFramework", b => + modelBuilder.Entity("BaGet.Core.TargetFramework", b => { - b.HasOne("BaGet.Core.Entities.Package", "Package") + b.HasOne("BaGet.Core.Package", "Package") .WithMany("TargetFrameworks") .HasForeignKey("PackageKey") .OnDelete(DeleteBehavior.Cascade); diff --git a/src/BaGet.Database.PostgreSql/Migrations/20191113054029_AddHasIconColumn.Designer.cs b/src/BaGet.Database.PostgreSql/Migrations/20191113054029_AddHasIconColumn.Designer.cs new file mode 100644 index 000000000..b04d03cb7 --- /dev/null +++ b/src/BaGet.Database.PostgreSql/Migrations/20191113054029_AddHasIconColumn.Designer.cs @@ -0,0 +1,204 @@ +// +using System; +using BaGet.Database.PostgreSql; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +namespace BaGet.Database.PostgreSql.Migrations +{ + [DbContext(typeof(PostgreSqlContext))] + [Migration("20191113054029_AddHasIconColumn")] + partial class AddHasIconColumn + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Npgsql:PostgresExtension:citext", ",,") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) + .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + modelBuilder.Entity("BaGet.Core.Package", b => + { + b.Property("Key") + .ValueGeneratedOnAdd(); + + b.Property("Authors") + .HasMaxLength(4000); + + b.Property("Description") + .HasMaxLength(4000); + + b.Property("Downloads"); + + b.Property("HasIcon"); + + b.Property("HasReadme"); + + b.Property("IconUrl") + .HasMaxLength(4000); + + b.Property("Id") + .IsRequired() + .HasColumnType("citext") + .HasMaxLength(128); + + b.Property("IsPrerelease"); + + b.Property("Language") + .HasMaxLength(20); + + b.Property("LicenseUrl") + .HasMaxLength(4000); + + b.Property("Listed"); + + b.Property("MinClientVersion") + .HasMaxLength(44); + + b.Property("NormalizedVersionString") + .IsRequired() + .HasColumnName("Version") + .HasMaxLength(64); + + b.Property("OriginalVersionString") + .HasColumnName("OriginalVersion") + .HasMaxLength(64); + + b.Property("ProjectUrl") + .HasMaxLength(4000); + + b.Property("Published"); + + b.Property("RepositoryType") + .HasMaxLength(100); + + b.Property("RepositoryUrl") + .HasMaxLength(4000); + + b.Property("RequireLicenseAcceptance"); + + b.Property("RowVersion") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate(); + + b.Property("SemVerLevel"); + + b.Property("Summary") + .HasMaxLength(4000); + + b.Property("Tags") + .HasMaxLength(4000); + + b.Property("Title") + .HasMaxLength(256); + + b.HasKey("Key"); + + b.HasIndex("Id"); + + b.HasIndex("Id", "NormalizedVersionString") + .IsUnique(); + + b.ToTable("Packages"); + }); + + modelBuilder.Entity("BaGet.Core.PackageDependency", b => + { + b.Property("Key") + .ValueGeneratedOnAdd(); + + b.Property("Id") + .HasColumnType("citext") + .HasMaxLength(128); + + b.Property("PackageKey"); + + b.Property("TargetFramework") + .HasMaxLength(256); + + b.Property("VersionRange") + .HasMaxLength(256); + + b.HasKey("Key"); + + b.HasIndex("Id"); + + b.HasIndex("PackageKey"); + + b.ToTable("PackageDependencies"); + }); + + modelBuilder.Entity("BaGet.Core.PackageType", b => + { + b.Property("Key") + .ValueGeneratedOnAdd(); + + b.Property("Name") + .HasColumnType("citext") + .HasMaxLength(512); + + b.Property("PackageKey"); + + b.Property("Version") + .HasMaxLength(64); + + b.HasKey("Key"); + + b.HasIndex("Name"); + + b.HasIndex("PackageKey"); + + b.ToTable("PackageTypes"); + }); + + modelBuilder.Entity("BaGet.Core.TargetFramework", b => + { + b.Property("Key") + .ValueGeneratedOnAdd(); + + b.Property("Moniker") + .HasColumnType("citext") + .HasMaxLength(256); + + b.Property("PackageKey"); + + b.HasKey("Key"); + + b.HasIndex("Moniker"); + + b.HasIndex("PackageKey"); + + b.ToTable("TargetFrameworks"); + }); + + modelBuilder.Entity("BaGet.Core.PackageDependency", b => + { + b.HasOne("BaGet.Core.Package", "Package") + .WithMany("Dependencies") + .HasForeignKey("PackageKey"); + }); + + modelBuilder.Entity("BaGet.Core.PackageType", b => + { + b.HasOne("BaGet.Core.Package", "Package") + .WithMany("PackageTypes") + .HasForeignKey("PackageKey") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("BaGet.Core.TargetFramework", b => + { + b.HasOne("BaGet.Core.Package", "Package") + .WithMany("TargetFrameworks") + .HasForeignKey("PackageKey") + .OnDelete(DeleteBehavior.Cascade); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/BaGet.Database.PostgreSql/Migrations/20191113054029_AddHasIconColumn.cs b/src/BaGet.Database.PostgreSql/Migrations/20191113054029_AddHasIconColumn.cs new file mode 100644 index 000000000..1b672b835 --- /dev/null +++ b/src/BaGet.Database.PostgreSql/Migrations/20191113054029_AddHasIconColumn.cs @@ -0,0 +1,23 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace BaGet.Database.PostgreSql.Migrations +{ + public partial class AddHasIconColumn : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "HasIcon", + table: "Packages", + nullable: false, + defaultValue: false); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "HasIcon", + table: "Packages"); + } + } +} diff --git a/src/BaGet.Database.PostgreSql/Migrations/PostgreSqlContextModelSnapshot.cs b/src/BaGet.Database.PostgreSql/Migrations/PostgreSqlContextModelSnapshot.cs index b8277d233..ce719b28d 100644 --- a/src/BaGet.Database.PostgreSql/Migrations/PostgreSqlContextModelSnapshot.cs +++ b/src/BaGet.Database.PostgreSql/Migrations/PostgreSqlContextModelSnapshot.cs @@ -17,10 +17,10 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder .HasAnnotation("Npgsql:PostgresExtension:citext", ",,") .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) - .HasAnnotation("ProductVersion", "2.2.6-servicing-10079") + .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") .HasAnnotation("Relational:MaxIdentifierLength", 63); - modelBuilder.Entity("BaGet.Core.Entities.Package", b => + modelBuilder.Entity("BaGet.Core.Package", b => { b.Property("Key") .ValueGeneratedOnAdd(); @@ -33,6 +33,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Downloads"); + b.Property("HasIcon"); + b.Property("HasReadme"); b.Property("IconUrl") @@ -103,7 +105,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("Packages"); }); - modelBuilder.Entity("BaGet.Core.Entities.PackageDependency", b => + modelBuilder.Entity("BaGet.Core.PackageDependency", b => { b.Property("Key") .ValueGeneratedOnAdd(); @@ -129,7 +131,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("PackageDependencies"); }); - modelBuilder.Entity("BaGet.Core.Entities.PackageType", b => + modelBuilder.Entity("BaGet.Core.PackageType", b => { b.Property("Key") .ValueGeneratedOnAdd(); @@ -152,7 +154,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("PackageTypes"); }); - modelBuilder.Entity("BaGet.Core.Entities.TargetFramework", b => + modelBuilder.Entity("BaGet.Core.TargetFramework", b => { b.Property("Key") .ValueGeneratedOnAdd(); @@ -172,24 +174,24 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("TargetFrameworks"); }); - modelBuilder.Entity("BaGet.Core.Entities.PackageDependency", b => + modelBuilder.Entity("BaGet.Core.PackageDependency", b => { - b.HasOne("BaGet.Core.Entities.Package", "Package") + b.HasOne("BaGet.Core.Package", "Package") .WithMany("Dependencies") .HasForeignKey("PackageKey"); }); - modelBuilder.Entity("BaGet.Core.Entities.PackageType", b => + modelBuilder.Entity("BaGet.Core.PackageType", b => { - b.HasOne("BaGet.Core.Entities.Package", "Package") + b.HasOne("BaGet.Core.Package", "Package") .WithMany("PackageTypes") .HasForeignKey("PackageKey") .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity("BaGet.Core.Entities.TargetFramework", b => + modelBuilder.Entity("BaGet.Core.TargetFramework", b => { - b.HasOne("BaGet.Core.Entities.Package", "Package") + b.HasOne("BaGet.Core.Package", "Package") .WithMany("TargetFrameworks") .HasForeignKey("PackageKey") .OnDelete(DeleteBehavior.Cascade); diff --git a/src/BaGet.Database.SqlServer/Migrations/20191113054208_AddHasIconColumn.Designer.cs b/src/BaGet.Database.SqlServer/Migrations/20191113054208_AddHasIconColumn.Designer.cs new file mode 100644 index 000000000..64de879b5 --- /dev/null +++ b/src/BaGet.Database.SqlServer/Migrations/20191113054208_AddHasIconColumn.Designer.cs @@ -0,0 +1,203 @@ +// +using System; +using BaGet.Database.SqlServer; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace BaGet.Database.SqlServer.Migrations +{ + [DbContext(typeof(SqlServerContext))] + [Migration("20191113054208_AddHasIconColumn")] + partial class AddHasIconColumn + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("BaGet.Core.Package", b => + { + b.Property("Key") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Authors") + .HasMaxLength(4000); + + b.Property("Description") + .HasMaxLength(4000); + + b.Property("Downloads"); + + b.Property("HasIcon"); + + b.Property("HasReadme"); + + b.Property("IconUrl") + .HasMaxLength(4000); + + b.Property("Id") + .IsRequired() + .HasMaxLength(128); + + b.Property("IsPrerelease"); + + b.Property("Language") + .HasMaxLength(20); + + b.Property("LicenseUrl") + .HasMaxLength(4000); + + b.Property("Listed"); + + b.Property("MinClientVersion") + .HasMaxLength(44); + + b.Property("NormalizedVersionString") + .IsRequired() + .HasColumnName("Version") + .HasMaxLength(64); + + b.Property("OriginalVersionString") + .HasColumnName("OriginalVersion") + .HasMaxLength(64); + + b.Property("ProjectUrl") + .HasMaxLength(4000); + + b.Property("Published"); + + b.Property("RepositoryType") + .HasMaxLength(100); + + b.Property("RepositoryUrl") + .HasMaxLength(4000); + + b.Property("RequireLicenseAcceptance"); + + b.Property("RowVersion") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate(); + + b.Property("SemVerLevel"); + + b.Property("Summary") + .HasMaxLength(4000); + + b.Property("Tags") + .HasMaxLength(4000); + + b.Property("Title") + .HasMaxLength(256); + + b.HasKey("Key"); + + b.HasIndex("Id"); + + b.HasIndex("Id", "NormalizedVersionString") + .IsUnique(); + + b.ToTable("Packages"); + }); + + modelBuilder.Entity("BaGet.Core.PackageDependency", b => + { + b.Property("Key") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Id") + .HasMaxLength(128); + + b.Property("PackageKey"); + + b.Property("TargetFramework") + .HasMaxLength(256); + + b.Property("VersionRange") + .HasMaxLength(256); + + b.HasKey("Key"); + + b.HasIndex("Id"); + + b.HasIndex("PackageKey"); + + b.ToTable("PackageDependencies"); + }); + + modelBuilder.Entity("BaGet.Core.PackageType", b => + { + b.Property("Key") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Name") + .HasMaxLength(512); + + b.Property("PackageKey"); + + b.Property("Version") + .HasMaxLength(64); + + b.HasKey("Key"); + + b.HasIndex("Name"); + + b.HasIndex("PackageKey"); + + b.ToTable("PackageTypes"); + }); + + modelBuilder.Entity("BaGet.Core.TargetFramework", b => + { + b.Property("Key") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Moniker") + .HasMaxLength(256); + + b.Property("PackageKey"); + + b.HasKey("Key"); + + b.HasIndex("Moniker"); + + b.HasIndex("PackageKey"); + + b.ToTable("TargetFrameworks"); + }); + + modelBuilder.Entity("BaGet.Core.PackageDependency", b => + { + b.HasOne("BaGet.Core.Package", "Package") + .WithMany("Dependencies") + .HasForeignKey("PackageKey"); + }); + + modelBuilder.Entity("BaGet.Core.PackageType", b => + { + b.HasOne("BaGet.Core.Package", "Package") + .WithMany("PackageTypes") + .HasForeignKey("PackageKey") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("BaGet.Core.TargetFramework", b => + { + b.HasOne("BaGet.Core.Package", "Package") + .WithMany("TargetFrameworks") + .HasForeignKey("PackageKey") + .OnDelete(DeleteBehavior.Cascade); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/BaGet.Database.SqlServer/Migrations/20191113054208_AddHasIconColumn.cs b/src/BaGet.Database.SqlServer/Migrations/20191113054208_AddHasIconColumn.cs new file mode 100644 index 000000000..c2866dc18 --- /dev/null +++ b/src/BaGet.Database.SqlServer/Migrations/20191113054208_AddHasIconColumn.cs @@ -0,0 +1,23 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace BaGet.Database.SqlServer.Migrations +{ + public partial class AddHasIconColumn : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "HasIcon", + table: "Packages", + nullable: false, + defaultValue: false); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "HasIcon", + table: "Packages"); + } + } +} diff --git a/src/BaGet.Database.SqlServer/Migrations/SqlServerContextModelSnapshot.cs b/src/BaGet.Database.SqlServer/Migrations/SqlServerContextModelSnapshot.cs index 1bea77cf8..6fe519511 100644 --- a/src/BaGet.Database.SqlServer/Migrations/SqlServerContextModelSnapshot.cs +++ b/src/BaGet.Database.SqlServer/Migrations/SqlServerContextModelSnapshot.cs @@ -15,11 +15,11 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.2.6-servicing-10079") + .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") .HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - modelBuilder.Entity("BaGet.Core.Entities.Package", b => + modelBuilder.Entity("BaGet.Core.Package", b => { b.Property("Key") .ValueGeneratedOnAdd() @@ -33,6 +33,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Downloads"); + b.Property("HasIcon"); + b.Property("HasReadme"); b.Property("IconUrl") @@ -102,7 +104,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("Packages"); }); - modelBuilder.Entity("BaGet.Core.Entities.PackageDependency", b => + modelBuilder.Entity("BaGet.Core.PackageDependency", b => { b.Property("Key") .ValueGeneratedOnAdd() @@ -128,7 +130,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("PackageDependencies"); }); - modelBuilder.Entity("BaGet.Core.Entities.PackageType", b => + modelBuilder.Entity("BaGet.Core.PackageType", b => { b.Property("Key") .ValueGeneratedOnAdd() @@ -151,7 +153,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("PackageTypes"); }); - modelBuilder.Entity("BaGet.Core.Entities.TargetFramework", b => + modelBuilder.Entity("BaGet.Core.TargetFramework", b => { b.Property("Key") .ValueGeneratedOnAdd() @@ -171,24 +173,24 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("TargetFrameworks"); }); - modelBuilder.Entity("BaGet.Core.Entities.PackageDependency", b => + modelBuilder.Entity("BaGet.Core.PackageDependency", b => { - b.HasOne("BaGet.Core.Entities.Package", "Package") + b.HasOne("BaGet.Core.Package", "Package") .WithMany("Dependencies") .HasForeignKey("PackageKey"); }); - modelBuilder.Entity("BaGet.Core.Entities.PackageType", b => + modelBuilder.Entity("BaGet.Core.PackageType", b => { - b.HasOne("BaGet.Core.Entities.Package", "Package") + b.HasOne("BaGet.Core.Package", "Package") .WithMany("PackageTypes") .HasForeignKey("PackageKey") .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity("BaGet.Core.Entities.TargetFramework", b => + modelBuilder.Entity("BaGet.Core.TargetFramework", b => { - b.HasOne("BaGet.Core.Entities.Package", "Package") + b.HasOne("BaGet.Core.Package", "Package") .WithMany("TargetFrameworks") .HasForeignKey("PackageKey") .OnDelete(DeleteBehavior.Cascade); diff --git a/src/BaGet.Database.Sqlite/Migrations/20191113053824_AddHasIconColumn.Designer.cs b/src/BaGet.Database.Sqlite/Migrations/20191113053824_AddHasIconColumn.Designer.cs new file mode 100644 index 000000000..c65618c4b --- /dev/null +++ b/src/BaGet.Database.Sqlite/Migrations/20191113053824_AddHasIconColumn.Designer.cs @@ -0,0 +1,200 @@ +// +using System; +using BaGet.Database.Sqlite; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace BaGet.Database.Sqlite.Migrations +{ + [DbContext(typeof(SqliteContext))] + [Migration("20191113053824_AddHasIconColumn")] + partial class AddHasIconColumn + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.2.4-servicing-10062"); + + modelBuilder.Entity("BaGet.Core.Package", b => + { + b.Property("Key") + .ValueGeneratedOnAdd(); + + b.Property("Authors") + .HasMaxLength(4000); + + b.Property("Description") + .HasMaxLength(4000); + + b.Property("Downloads"); + + b.Property("HasIcon"); + + b.Property("HasReadme"); + + b.Property("IconUrl") + .HasMaxLength(4000); + + b.Property("Id") + .IsRequired() + .HasColumnType("TEXT COLLATE NOCASE") + .HasMaxLength(128); + + b.Property("IsPrerelease"); + + b.Property("Language") + .HasMaxLength(20); + + b.Property("LicenseUrl") + .HasMaxLength(4000); + + b.Property("Listed"); + + b.Property("MinClientVersion") + .HasMaxLength(44); + + b.Property("NormalizedVersionString") + .IsRequired() + .HasColumnName("Version") + .HasMaxLength(64); + + b.Property("OriginalVersionString") + .HasColumnName("OriginalVersion") + .HasMaxLength(64); + + b.Property("ProjectUrl") + .HasMaxLength(4000); + + b.Property("Published"); + + b.Property("RepositoryType") + .HasMaxLength(100); + + b.Property("RepositoryUrl") + .HasMaxLength(4000); + + b.Property("RequireLicenseAcceptance"); + + b.Property("RowVersion") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate(); + + b.Property("SemVerLevel"); + + b.Property("Summary") + .HasMaxLength(4000); + + b.Property("Tags") + .HasMaxLength(4000); + + b.Property("Title") + .HasMaxLength(256); + + b.HasKey("Key"); + + b.HasIndex("Id"); + + b.HasIndex("Id", "NormalizedVersionString") + .IsUnique(); + + b.ToTable("Packages"); + }); + + modelBuilder.Entity("BaGet.Core.PackageDependency", b => + { + b.Property("Key") + .ValueGeneratedOnAdd(); + + b.Property("Id") + .HasColumnType("TEXT COLLATE NOCASE") + .HasMaxLength(128); + + b.Property("PackageKey"); + + b.Property("TargetFramework") + .HasMaxLength(256); + + b.Property("VersionRange") + .HasMaxLength(256); + + b.HasKey("Key"); + + b.HasIndex("Id"); + + b.HasIndex("PackageKey"); + + b.ToTable("PackageDependencies"); + }); + + modelBuilder.Entity("BaGet.Core.PackageType", b => + { + b.Property("Key") + .ValueGeneratedOnAdd(); + + b.Property("Name") + .HasColumnType("TEXT COLLATE NOCASE") + .HasMaxLength(512); + + b.Property("PackageKey"); + + b.Property("Version") + .HasMaxLength(64); + + b.HasKey("Key"); + + b.HasIndex("Name"); + + b.HasIndex("PackageKey"); + + b.ToTable("PackageTypes"); + }); + + modelBuilder.Entity("BaGet.Core.TargetFramework", b => + { + b.Property("Key") + .ValueGeneratedOnAdd(); + + b.Property("Moniker") + .HasColumnType("TEXT COLLATE NOCASE") + .HasMaxLength(256); + + b.Property("PackageKey"); + + b.HasKey("Key"); + + b.HasIndex("Moniker"); + + b.HasIndex("PackageKey"); + + b.ToTable("TargetFrameworks"); + }); + + modelBuilder.Entity("BaGet.Core.PackageDependency", b => + { + b.HasOne("BaGet.Core.Package", "Package") + .WithMany("Dependencies") + .HasForeignKey("PackageKey"); + }); + + modelBuilder.Entity("BaGet.Core.PackageType", b => + { + b.HasOne("BaGet.Core.Package", "Package") + .WithMany("PackageTypes") + .HasForeignKey("PackageKey") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("BaGet.Core.TargetFramework", b => + { + b.HasOne("BaGet.Core.Package", "Package") + .WithMany("TargetFrameworks") + .HasForeignKey("PackageKey") + .OnDelete(DeleteBehavior.Cascade); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/BaGet.Database.Sqlite/Migrations/20191113053824_AddHasIconColumn.cs b/src/BaGet.Database.Sqlite/Migrations/20191113053824_AddHasIconColumn.cs new file mode 100644 index 000000000..41038f8bb --- /dev/null +++ b/src/BaGet.Database.Sqlite/Migrations/20191113053824_AddHasIconColumn.cs @@ -0,0 +1,23 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace BaGet.Database.Sqlite.Migrations +{ + public partial class AddHasIconColumn : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "HasIcon", + table: "Packages", + nullable: false, + defaultValue: false); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "HasIcon", + table: "Packages"); + } + } +} diff --git a/src/BaGet.Database.Sqlite/Migrations/SqliteContextModelSnapshot.cs b/src/BaGet.Database.Sqlite/Migrations/SqliteContextModelSnapshot.cs index f2c177023..ab1403a23 100644 --- a/src/BaGet.Database.Sqlite/Migrations/SqliteContextModelSnapshot.cs +++ b/src/BaGet.Database.Sqlite/Migrations/SqliteContextModelSnapshot.cs @@ -14,9 +14,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.2.6-servicing-10079"); + .HasAnnotation("ProductVersion", "2.2.4-servicing-10062"); - modelBuilder.Entity("BaGet.Core.Entities.Package", b => + modelBuilder.Entity("BaGet.Core.Package", b => { b.Property("Key") .ValueGeneratedOnAdd(); @@ -29,6 +29,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Downloads"); + b.Property("HasIcon"); + b.Property("HasReadme"); b.Property("IconUrl") @@ -99,7 +101,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("Packages"); }); - modelBuilder.Entity("BaGet.Core.Entities.PackageDependency", b => + modelBuilder.Entity("BaGet.Core.PackageDependency", b => { b.Property("Key") .ValueGeneratedOnAdd(); @@ -125,7 +127,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("PackageDependencies"); }); - modelBuilder.Entity("BaGet.Core.Entities.PackageType", b => + modelBuilder.Entity("BaGet.Core.PackageType", b => { b.Property("Key") .ValueGeneratedOnAdd(); @@ -148,7 +150,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("PackageTypes"); }); - modelBuilder.Entity("BaGet.Core.Entities.TargetFramework", b => + modelBuilder.Entity("BaGet.Core.TargetFramework", b => { b.Property("Key") .ValueGeneratedOnAdd(); @@ -168,24 +170,24 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("TargetFrameworks"); }); - modelBuilder.Entity("BaGet.Core.Entities.PackageDependency", b => + modelBuilder.Entity("BaGet.Core.PackageDependency", b => { - b.HasOne("BaGet.Core.Entities.Package", "Package") + b.HasOne("BaGet.Core.Package", "Package") .WithMany("Dependencies") .HasForeignKey("PackageKey"); }); - modelBuilder.Entity("BaGet.Core.Entities.PackageType", b => + modelBuilder.Entity("BaGet.Core.PackageType", b => { - b.HasOne("BaGet.Core.Entities.Package", "Package") + b.HasOne("BaGet.Core.Package", "Package") .WithMany("PackageTypes") .HasForeignKey("PackageKey") .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity("BaGet.Core.Entities.TargetFramework", b => + modelBuilder.Entity("BaGet.Core.TargetFramework", b => { - b.HasOne("BaGet.Core.Entities.Package", "Package") + b.HasOne("BaGet.Core.Package", "Package") .WithMany("TargetFrameworks") .HasForeignKey("PackageKey") .OnDelete(DeleteBehavior.Cascade); From fed97d0368bb4b5a9dbc10cb5d09b3d852291af9 Mon Sep 17 00:00:00 2001 From: Kevin Date: Wed, 13 Nov 2019 14:49:05 +0900 Subject: [PATCH 02/22] Update NuGet Packaging & Protocol --- src/BaGet.Core/BaGet.Core.csproj | 2 +- src/BaGet.Protocol/BaGet.Protocol.csproj | 2 +- tests/BaGet.Tests/BaGet.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/BaGet.Core/BaGet.Core.csproj b/src/BaGet.Core/BaGet.Core.csproj index 963a5f776..d866c998e 100644 --- a/src/BaGet.Core/BaGet.Core.csproj +++ b/src/BaGet.Core/BaGet.Core.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/BaGet.Protocol/BaGet.Protocol.csproj b/src/BaGet.Protocol/BaGet.Protocol.csproj index 7bdaaaa55..bdfb06998 100644 --- a/src/BaGet.Protocol/BaGet.Protocol.csproj +++ b/src/BaGet.Protocol/BaGet.Protocol.csproj @@ -10,7 +10,7 @@ - + diff --git a/tests/BaGet.Tests/BaGet.Tests.csproj b/tests/BaGet.Tests/BaGet.Tests.csproj index d375c7756..226251f52 100644 --- a/tests/BaGet.Tests/BaGet.Tests.csproj +++ b/tests/BaGet.Tests/BaGet.Tests.csproj @@ -13,7 +13,7 @@ - + From 608e4de3d9dfe8c5c6f9cfc6e0fe09be6e400339 Mon Sep 17 00:00:00 2001 From: Kevin Date: Wed, 13 Nov 2019 15:10:11 +0900 Subject: [PATCH 03/22] Implement Icon Resource Caching --- .../PackageArchiveReaderExtensions.cs | 11 ++++++ .../Indexing/PackageIndexingService.cs | 12 ++++++ .../Storage/IPackageStorageService.cs | 1 + .../Storage/PackageStorageService.cs | 37 ++++++++++++++++++ .../Services/PackageStorageServiceTests.cs | 38 +++++++++++++++---- 5 files changed, 91 insertions(+), 8 deletions(-) diff --git a/src/BaGet.Core/Extensions/PackageArchiveReaderExtensions.cs b/src/BaGet.Core/Extensions/PackageArchiveReaderExtensions.cs index cfdc5b744..0414ecd35 100644 --- a/src/BaGet.Core/Extensions/PackageArchiveReaderExtensions.cs +++ b/src/BaGet.Core/Extensions/PackageArchiveReaderExtensions.cs @@ -25,6 +25,9 @@ public static class PackageArchiveReaderExtensions public static bool HasReadme(this PackageArchiveReader package) => package.GetFiles().Any(ReadmeFileNames.Contains); + public static bool HasIcon(this PackageArchiveReader package) + => !string.IsNullOrEmpty(package.NuspecReader.GetIcon()); + public async static Task GetReadmeAsync( this PackageArchiveReader package, CancellationToken cancellationToken) @@ -44,6 +47,13 @@ public async static Task GetReadmeAsync( throw new InvalidOperationException("Package does not have a readme!"); } + public async static Task GetIconAsync( + this PackageArchiveReader package, + CancellationToken cancellationToken) + { + return await package.GetStreamAsync(package.NuspecReader.GetIcon(), cancellationToken); + } + public static Package GetPackageMetadata(this PackageArchiveReader packageReader) { var nuspec = packageReader.NuspecReader; @@ -57,6 +67,7 @@ public static Package GetPackageMetadata(this PackageArchiveReader packageReader Authors = ParseAuthors(nuspec.GetAuthors()), Description = nuspec.GetDescription(), HasReadme = packageReader.HasReadme(), + HasIcon = packageReader.HasIcon(), IsPrerelease = nuspec.GetVersion().IsPrerelease, Language = nuspec.GetLanguage() ?? string.Empty, Listed = true, diff --git a/src/BaGet.Core/Indexing/PackageIndexingService.cs b/src/BaGet.Core/Indexing/PackageIndexingService.cs index d60bb408c..b0b9cff3b 100644 --- a/src/BaGet.Core/Indexing/PackageIndexingService.cs +++ b/src/BaGet.Core/Indexing/PackageIndexingService.cs @@ -36,6 +36,7 @@ public async Task IndexAsync(Stream packageStream, Cancel Package package; Stream nuspecStream; Stream readmeStream; + Stream iconStream; try { @@ -54,6 +55,16 @@ public async Task IndexAsync(Stream packageStream, Cancel { readmeStream = null; } + + if (package.HasIcon) + { + iconStream = await packageReader.GetIconAsync(cancellationToken); + iconStream = await iconStream.AsTemporaryFileStreamAsync(); + } + else + { + iconStream = null; + } } } catch (Exception e) @@ -91,6 +102,7 @@ await _storage.SavePackageContentAsync( packageStream, nuspecStream, readmeStream, + iconStream, cancellationToken); } catch (Exception e) diff --git a/src/BaGet.Core/Storage/IPackageStorageService.cs b/src/BaGet.Core/Storage/IPackageStorageService.cs index aefae56c9..e20f53b95 100644 --- a/src/BaGet.Core/Storage/IPackageStorageService.cs +++ b/src/BaGet.Core/Storage/IPackageStorageService.cs @@ -26,6 +26,7 @@ Task SavePackageContentAsync( Stream packageStream, Stream nuspecStream, Stream readmeStream, + Stream iconStream, CancellationToken cancellationToken); /// diff --git a/src/BaGet.Core/Storage/PackageStorageService.cs b/src/BaGet.Core/Storage/PackageStorageService.cs index f1c8f2521..5502e9e39 100644 --- a/src/BaGet.Core/Storage/PackageStorageService.cs +++ b/src/BaGet.Core/Storage/PackageStorageService.cs @@ -15,6 +15,7 @@ public class PackageStorageService : IPackageStorageService private const string PackageContentType = "binary/octet-stream"; private const string NuspecContentType = "text/plain"; private const string ReadmeContentType = "text/markdown"; + private const string IconContentType = "image/png"; private readonly IStorageService _storage; private readonly ILogger _logger; @@ -32,6 +33,7 @@ public async Task SavePackageContentAsync( Stream packageStream, Stream nuspecStream, Stream readmeStream, + Stream iconStream, CancellationToken cancellationToken = default) { package = package ?? throw new ArgumentNullException(nameof(package)); @@ -44,6 +46,7 @@ public async Task SavePackageContentAsync( var packagePath = PackagePath(lowercasedId, lowercasedNormalizedVersion); var nuspecPath = NuspecPath(lowercasedId, lowercasedNormalizedVersion); var readmePath = ReadmePath(lowercasedId, lowercasedNormalizedVersion); + var iconPath = IconPath(lowercasedId, lowercasedNormalizedVersion); _logger.LogInformation( "Storing package {PackageId} {PackageVersion} at {Path}...", @@ -108,6 +111,29 @@ public async Task SavePackageContentAsync( } } + // Store the package's icon, if one exists. + if (iconStream != null) + { + _logger.LogInformation( + "Storing package {PackageId} {PackageVersion} icon at {Path}...", + lowercasedId, + lowercasedNormalizedVersion, + iconPath); + + result = await _storage.PutAsync(iconPath, iconStream, IconContentType, cancellationToken); + if (result == StoragePutResult.Conflict) + { + // TODO: This should be returned gracefully with an enum. + _logger.LogInformation( + "Could not store package {PackageId} {PackageVersion} icon at {Path} due to conflict", + lowercasedId, + lowercasedNormalizedVersion, + iconPath); + + throw new InvalidOperationException($"Failed to store package {lowercasedId} {lowercasedNormalizedVersion} icon"); + } + } + _logger.LogInformation( "Finished storing package {PackageId} {PackageVersion}", lowercasedId, @@ -137,10 +163,12 @@ public async Task DeleteAsync(string id, NuGetVersion version, CancellationToken var packagePath = PackagePath(lowercasedId, lowercasedNormalizedVersion); var nuspecPath = NuspecPath(lowercasedId, lowercasedNormalizedVersion); var readmePath = ReadmePath(lowercasedId, lowercasedNormalizedVersion); + var iconPath = IconPath(lowercasedId, lowercasedNormalizedVersion); await _storage.DeleteAsync(packagePath, cancellationToken); await _storage.DeleteAsync(nuspecPath, cancellationToken); await _storage.DeleteAsync(readmePath, cancellationToken); + await _storage.DeleteAsync(iconPath, cancellationToken); } private async Task GetStreamAsync( @@ -197,5 +225,14 @@ private string ReadmePath(string lowercasedId, string lowercasedNormalizedVersio lowercasedNormalizedVersion, "readme"); } + + private string IconPath(string lowercasedId, string lowercasedNormalizedVersion) + { + return Path.Combine( + PackagesPathPrefix, + lowercasedId, + lowercasedNormalizedVersion, + "icon"); + } } } diff --git a/tests/BaGet.Core.Tests/Services/PackageStorageServiceTests.cs b/tests/BaGet.Core.Tests/Services/PackageStorageServiceTests.cs index 5d36f4646..34073e3fe 100644 --- a/tests/BaGet.Core.Tests/Services/PackageStorageServiceTests.cs +++ b/tests/BaGet.Core.Tests/Services/PackageStorageServiceTests.cs @@ -23,7 +23,8 @@ await Assert.ThrowsAsync( null, packageStream: Stream.Null, nuspecStream: Stream.Null, - readmeStream: Stream.Null)); + readmeStream: Stream.Null, + iconStream: Stream.Null)); } [Fact] @@ -34,7 +35,8 @@ await Assert.ThrowsAsync( _package, packageStream: null, nuspecStream: Stream.Null, - readmeStream: Stream.Null)); + readmeStream: Stream.Null, + iconStream: Stream.Null)); } [Fact] @@ -45,7 +47,8 @@ await Assert.ThrowsAsync( _package, packageStream: Stream.Null, nuspecStream: null, - readmeStream: Stream.Null)); + readmeStream: Stream.Null, + iconStream: Stream.Null)); } [Fact] @@ -57,13 +60,15 @@ public async Task SavesContent() using (var packageStream = StringStream("My package")) using (var nuspecStream = StringStream("My nuspec")) using (var readmeStream = StringStream("My readme")) + using (var iconStream = StringStream("My icon")) { // Act await _target.SavePackageContentAsync( _package, packageStream: packageStream, nuspecStream: nuspecStream, - readmeStream: readmeStream); + readmeStream: readmeStream, + iconStream: iconStream); // Assert Assert.True(_puts.ContainsKey(PackagePath)); @@ -77,6 +82,10 @@ await _target.SavePackageContentAsync( Assert.True(_puts.ContainsKey(ReadmePath)); Assert.Equal("My readme", await ToStringAsync(_puts[ReadmePath].Content)); Assert.Equal("text/markdown", _puts[ReadmePath].ContentType); + + Assert.True(_puts.ContainsKey(IconPath)); + Assert.Equal("My icon", await ToStringAsync(_puts[IconPath].Content)); + Assert.Equal("image/png", _puts[IconPath].ContentType); } } @@ -94,7 +103,8 @@ await _target.SavePackageContentAsync( _package, packageStream: packageStream, nuspecStream: nuspecStream, - readmeStream: null); + readmeStream: null, + iconStream: null); } // Assert @@ -111,13 +121,15 @@ public async Task NormalizesVersionWhenContentIsSaved() using (var packageStream = StringStream("My package")) using (var nuspecStream = StringStream("My nuspec")) using (var readmeStream = StringStream("My readme")) + using (var iconStream = StringStream("My icon")) { // Act await _target.SavePackageContentAsync( _package, packageStream: packageStream, nuspecStream: nuspecStream, - readmeStream: readmeStream); + readmeStream: readmeStream, + iconStream: iconStream); } // Assert @@ -135,12 +147,14 @@ public async Task DoesNotThrowIfContentAlreadyExistsAndContentsMatch() using (var packageStream = StringStream("My package")) using (var nuspecStream = StringStream("My nuspec")) using (var readmeStream = StringStream("My readme")) + using (var iconStream = StringStream("My icon")) { await _target.SavePackageContentAsync( _package, packageStream: packageStream, nuspecStream: nuspecStream, - readmeStream: readmeStream); + readmeStream: readmeStream, + iconStream: iconStream); // Assert Assert.True(_puts.ContainsKey(PackagePath)); @@ -154,6 +168,10 @@ await _target.SavePackageContentAsync( Assert.True(_puts.ContainsKey(ReadmePath)); Assert.Equal("My readme", await ToStringAsync(_puts[ReadmePath].Content)); Assert.Equal("text/markdown", _puts[ReadmePath].ContentType); + + Assert.True(_puts.ContainsKey(IconPath)); + Assert.Equal("My icon", await ToStringAsync(_puts[IconPath].Content)); + Assert.Equal("image/icon", _puts[IconPath].ContentType); } } @@ -166,6 +184,7 @@ public async Task ThrowsIfContentAlreadyExistsButContentsDoNotMatch() using (var packageStream = StringStream("My package")) using (var nuspecStream = StringStream("My nuspec")) using (var readmeStream = StringStream("My readme")) + using (var iconStream = StringStream("My icon")) { // Act await Assert.ThrowsAsync(() => @@ -173,7 +192,8 @@ await Assert.ThrowsAsync(() => _package, packageStream: packageStream, nuspecStream: nuspecStream, - readmeStream: readmeStream)); + readmeStream: readmeStream, + iconStream: iconStream)); } } } @@ -332,6 +352,8 @@ public FactsBase() protected string NuspecPath => Path.Combine("packages", "my.package", "1.2.3", "my.package.nuspec"); protected string ReadmePath => Path.Combine("packages", "my.package", "1.2.3", "readme"); + protected string IconPath => Path.Combine("packages", "my.package", "1.2.3", "icon"); + protected Stream StringStream(string input) { var bytes = Encoding.ASCII.GetBytes(input); From 6645483292317b0b75294cdea1cef68b3df5510f Mon Sep 17 00:00:00 2001 From: Kevin Date: Wed, 13 Nov 2019 15:16:28 +0900 Subject: [PATCH 04/22] Implement DownloadIcon Route --- .../Controllers/PackageContentController.cs | 16 ++++++++++++++++ .../Extensions/IRouteBuilderExtensions.cs | 7 ++++++- src/BaGet.Core.Server/Routes.cs | 1 + .../Content/DefaultPackageContentService.cs | 14 ++++++++++++++ src/BaGet.Core/Content/IPackageContentService.cs | 16 +++++++++++++++- src/BaGet.Core/Storage/IPackageStorageService.cs | 3 +++ src/BaGet.Core/Storage/PackageStorageService.cs | 5 +++++ 7 files changed, 60 insertions(+), 2 deletions(-) diff --git a/src/BaGet.Core.Server/Controllers/PackageContentController.cs b/src/BaGet.Core.Server/Controllers/PackageContentController.cs index adf7a38ae..8b88bd609 100644 --- a/src/BaGet.Core.Server/Controllers/PackageContentController.cs +++ b/src/BaGet.Core.Server/Controllers/PackageContentController.cs @@ -79,5 +79,21 @@ public async Task DownloadReadmeAsync(string id, string version, return File(readmeStream, "text/markdown"); } + + public async Task DownloadIconAsync(string id, string version, CancellationToken cancellationToken) + { + if (!NuGetVersion.TryParse(version, out var nugetVersion)) + { + return NotFound(); + } + + var iconStream = await _content.GetPackageIconStreamOrNullAsync(id, nugetVersion, cancellationToken); + if (iconStream == null) + { + return NotFound(); + } + + return File(iconStream, "image/png"); + } } } diff --git a/src/BaGet.Core.Server/Extensions/IRouteBuilderExtensions.cs b/src/BaGet.Core.Server/Extensions/IRouteBuilderExtensions.cs index a83a0d6f4..48b57119f 100644 --- a/src/BaGet.Core.Server/Extensions/IRouteBuilderExtensions.cs +++ b/src/BaGet.Core.Server/Extensions/IRouteBuilderExtensions.cs @@ -49,7 +49,7 @@ public static IRouteBuilder MapSymbolRoutes(this IRouteBuilder routes) name: Routes.SymbolDownloadRouteName, template: "api/download/symbols/{file}/{key}/{file2}", defaults: new { controller = "Symbol", action = "Get" }); - + routes.MapRoute( name: Routes.SymbolDownloadRouteName, template: "api/download/symbols/{prefix}/{file}/{key}/{file2}", @@ -116,6 +116,11 @@ public static IRouteBuilder MapPackageContentRoutes(this IRouteBuilder routes) template: "v3/package/{id}/{version}/readme", defaults: new { controller = "PackageContent", action = "DownloadReadmeAsync" }); + routes.MapRoute( + name: Routes.PackageDownloadIconRouteName, + template: "v3/package/{id}/{version}/icon", + defaults: new { controller = "PackageContent", action = "DownloadIconAsync" }); + return routes; } } diff --git a/src/BaGet.Core.Server/Routes.cs b/src/BaGet.Core.Server/Routes.cs index ae5ac0b30..a833b25f8 100644 --- a/src/BaGet.Core.Server/Routes.cs +++ b/src/BaGet.Core.Server/Routes.cs @@ -16,6 +16,7 @@ public class Routes public const string PackageDownloadRouteName = "package-download"; public const string PackageDownloadManifestRouteName = "package-download-manifest"; public const string PackageDownloadReadmeRouteName = "package-download-readme"; + public const string PackageDownloadIconRouteName = "package-download-icon"; public const string SymbolDownloadRouteName = "symbol-download"; } } diff --git a/src/BaGet.Core/Content/DefaultPackageContentService.cs b/src/BaGet.Core/Content/DefaultPackageContentService.cs index b829275c4..53223a5a5 100644 --- a/src/BaGet.Core/Content/DefaultPackageContentService.cs +++ b/src/BaGet.Core/Content/DefaultPackageContentService.cs @@ -100,5 +100,19 @@ public async Task GetPackageReadmeStreamOrNullAsync(string id, NuGetVers return await _storage.GetReadmeStreamAsync(id, version, cancellationToken); } + + public async Task GetPackageIconStreamOrNullAsync(string id, NuGetVersion version, CancellationToken cancellationToken = default) + { + // Allow read-through caching if it is configured. + await _mirror.MirrorAsync(id, version, cancellationToken); + + var package = await _packages.FindOrNullAsync(id, version, includeUnlisted: true, cancellationToken); + if (!package.HasIcon) + { + return null; + } + + return await _storage.GetIconStreamAsync(id, version, cancellationToken); + } } } diff --git a/src/BaGet.Core/Content/IPackageContentService.cs b/src/BaGet.Core/Content/IPackageContentService.cs index 3edce290f..331c62e51 100644 --- a/src/BaGet.Core/Content/IPackageContentService.cs +++ b/src/BaGet.Core/Content/IPackageContentService.cs @@ -8,7 +8,7 @@ namespace BaGet.Core.Content { /// /// The Package Content resource, used to download NuGet packages and to fetch other metadata. - /// + /// /// See: https://docs.microsoft.com/en-us/nuget/api/package-base-address-resource /// public interface IPackageContentService @@ -67,5 +67,19 @@ Task GetPackageReadmeStreamOrNullAsync( string id, NuGetVersion version, CancellationToken cancellationToken); + + /// + /// Download a package's icon, or null if the package or icon does not exist. + /// + /// The package id. + /// The package's version. + /// A token to cancel the task. + /// + /// The package's icon stream, or null if the package or icon does not exist. The stream may not be seekable. + /// + Task GetPackageIconStreamOrNullAsync( + string id, + NuGetVersion version, + CancellationToken cancellationToken); } } diff --git a/src/BaGet.Core/Storage/IPackageStorageService.cs b/src/BaGet.Core/Storage/IPackageStorageService.cs index e20f53b95..e7608a952 100644 --- a/src/BaGet.Core/Storage/IPackageStorageService.cs +++ b/src/BaGet.Core/Storage/IPackageStorageService.cs @@ -19,6 +19,7 @@ public interface IPackageStorageService /// The package's nupkg stream. /// The package's nuspec stream. /// The package's readme stream, or null if none. + /// The package's icon stream, or null if none. /// /// Task SavePackageContentAsync( @@ -56,6 +57,8 @@ Task SavePackageContentAsync( /// The package's readme stream. Task GetReadmeStreamAsync(string id, NuGetVersion version, CancellationToken cancellationToken); + Task GetIconStreamAsync(string id, NuGetVersion version, CancellationToken cancellationToken); + /// /// Remove a package's content from storage. This operation SHOULD succeed /// even if the package does not exist. diff --git a/src/BaGet.Core/Storage/PackageStorageService.cs b/src/BaGet.Core/Storage/PackageStorageService.cs index 5502e9e39..8b21e8146 100644 --- a/src/BaGet.Core/Storage/PackageStorageService.cs +++ b/src/BaGet.Core/Storage/PackageStorageService.cs @@ -155,6 +155,11 @@ public async Task GetReadmeStreamAsync(string id, NuGetVersion version, return await GetStreamAsync(id, version, ReadmePath, cancellationToken); } + public async Task GetIconStreamAsync(string id, NuGetVersion version, CancellationToken cancellationToken) + { + return await GetStreamAsync(id, version, IconPath, cancellationToken); + } + public async Task DeleteAsync(string id, NuGetVersion version, CancellationToken cancellationToken) { var lowercasedId = id.ToLowerInvariant(); From c0d102eb9245e6bee30eea6fe60465dee1f47a68 Mon Sep 17 00:00:00 2001 From: Kevin Date: Wed, 13 Nov 2019 15:40:52 +0900 Subject: [PATCH 05/22] Implement IconUrl Cache Override --- src/BaGet.Azure/Search/AzureSearchService.cs | 2 +- src/BaGet.Azure/Table/PackageEntity.cs | 1 + src/BaGet.Azure/Table/TableOperationBuilder.cs | 1 + src/BaGet.Azure/Table/TablePackageService.cs | 1 + src/BaGet.Azure/Table/TableSearchService.cs | 2 +- src/BaGet.Core.Server/BaGetUrlGenerator.cs | 16 ++++++++++++++++ src/BaGet.Core/IUrlGenerator.cs | 7 +++++++ src/BaGet.Core/Metadata/RegistrationBuilder.cs | 2 +- src/BaGet.Core/Search/DatabaseSearchService.cs | 2 +- 9 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/BaGet.Azure/Search/AzureSearchService.cs b/src/BaGet.Azure/Search/AzureSearchService.cs index dfff48263..a76d66dc8 100644 --- a/src/BaGet.Azure/Search/AzureSearchService.cs +++ b/src/BaGet.Azure/Search/AzureSearchService.cs @@ -102,7 +102,7 @@ public async Task SearchAsync( Version = document.Version, Description = document.Description, Authors = document.Authors, - IconUrl = document.IconUrl, + IconUrl = !string.IsNullOrEmpty(document.IconUrl) ? document.IconUrl : _url.GetPackageIconDownloadUrl(document.Id, new NuGetVersion(document.Version)), LicenseUrl = document.LicenseUrl, ProjectUrl = document.ProjectUrl, RegistrationIndexUrl = _url.GetRegistrationIndexUrl(document.Id), diff --git a/src/BaGet.Azure/Table/PackageEntity.cs b/src/BaGet.Azure/Table/PackageEntity.cs index 57fbb8a58..6b993d7dd 100644 --- a/src/BaGet.Azure/Table/PackageEntity.cs +++ b/src/BaGet.Azure/Table/PackageEntity.cs @@ -22,6 +22,7 @@ public PackageEntity() public string Description { get; set; } public long Downloads { get; set; } public bool HasReadme { get; set; } + public bool HasIcon { get; set; } public bool IsPrerelease { get; set; } public string Language { get; set; } public bool Listed { get; set; } diff --git a/src/BaGet.Azure/Table/TableOperationBuilder.cs b/src/BaGet.Azure/Table/TableOperationBuilder.cs index 15e71ef21..827aa9c14 100644 --- a/src/BaGet.Azure/Table/TableOperationBuilder.cs +++ b/src/BaGet.Azure/Table/TableOperationBuilder.cs @@ -29,6 +29,7 @@ public TableOperation AddPackage(Package package) Description = package.Description, Downloads = package.Downloads, HasReadme = package.HasReadme, + HasIcon = package.HasIcon, IsPrerelease = package.IsPrerelease, Language = package.Language, Listed = package.Listed, diff --git a/src/BaGet.Azure/Table/TablePackageService.cs b/src/BaGet.Azure/Table/TablePackageService.cs index 7483cce92..ea94a9f68 100644 --- a/src/BaGet.Azure/Table/TablePackageService.cs +++ b/src/BaGet.Azure/Table/TablePackageService.cs @@ -230,6 +230,7 @@ private Package AsPackage(PackageEntity entity) Description = entity.Description, Downloads = entity.Downloads, HasReadme = entity.HasReadme, + HasIcon = entity.HasIcon, IsPrerelease = entity.IsPrerelease, Language = entity.Language, Listed = entity.Listed, diff --git a/src/BaGet.Azure/Table/TableSearchService.cs b/src/BaGet.Azure/Table/TableSearchService.cs index 5d1ca0c0e..b975b4f97 100644 --- a/src/BaGet.Azure/Table/TableSearchService.cs +++ b/src/BaGet.Azure/Table/TableSearchService.cs @@ -243,7 +243,7 @@ private SearchResult ToSearchResult(IReadOnlyList packages) Version = latest.NormalizedVersion, Description = latest.Description, Authors = JsonConvert.DeserializeObject(latest.Authors), - IconUrl = latest.IconUrl, + IconUrl = !string.IsNullOrEmpty(latest.IconUrl) ? latest.IconUrl : _url.GetPackageIconDownloadUrl(latest.Id, new NuGetVersion(versions.FirstOrDefault()?.Version)), LicenseUrl = latest.LicenseUrl, ProjectUrl = latest.ProjectUrl, RegistrationIndexUrl = _url.GetRegistrationIndexUrl(latest.Id), diff --git a/src/BaGet.Core.Server/BaGetUrlGenerator.cs b/src/BaGet.Core.Server/BaGetUrlGenerator.cs index 5488358b3..af16522b9 100644 --- a/src/BaGet.Core.Server/BaGetUrlGenerator.cs +++ b/src/BaGet.Core.Server/BaGetUrlGenerator.cs @@ -126,6 +126,22 @@ public string GetPackageManifestDownloadUrl(string id, NuGetVersion version) }); } + public string GetPackageIconDownloadUrl(string id, NuGetVersion version) + { + id = id.ToLowerInvariant(); + var versionString = version.ToNormalizedString().ToLowerInvariant(); + + return _linkGenerator.GetUriByRouteValues( + _httpContextAccessor.HttpContext, + Routes.PackageDownloadIconRouteName, + values: new + { + Id = id, + Version = versionString, + Id2 = id, + }); + } + private string AbsoluteUrl(string relativePath) { var request = _httpContextAccessor.HttpContext.Request; diff --git a/src/BaGet.Core/IUrlGenerator.cs b/src/BaGet.Core/IUrlGenerator.cs index 99a3e3e47..13ad12ec5 100644 --- a/src/BaGet.Core/IUrlGenerator.cs +++ b/src/BaGet.Core/IUrlGenerator.cs @@ -88,5 +88,12 @@ public interface IUrlGenerator /// The package's ID /// The package's version string GetPackageManifestDownloadUrl(string id, NuGetVersion version); + + /// + /// Get the URL to download a package icon. + /// + /// The package's ID + /// The package's version + string GetPackageIconDownloadUrl(string id, NuGetVersion version); } } diff --git a/src/BaGet.Core/Metadata/RegistrationBuilder.cs b/src/BaGet.Core/Metadata/RegistrationBuilder.cs index be1cc368b..402d5bda7 100644 --- a/src/BaGet.Core/Metadata/RegistrationBuilder.cs +++ b/src/BaGet.Core/Metadata/RegistrationBuilder.cs @@ -71,7 +71,7 @@ private RegistrationIndexPageItem ToRegistrationIndexPageItem(Package package) = Description = package.Description, Downloads = package.Downloads, HasReadme = package.HasReadme, - IconUrl = package.IconUrlString, + IconUrl = !string.IsNullOrEmpty(package.IconUrlString) ? package.IconUrlString : _url.GetPackageIconDownloadUrl(package.Id, package.Version), Language = package.Language, LicenseUrl = package.LicenseUrlString, Listed = package.Listed, diff --git a/src/BaGet.Core/Search/DatabaseSearchService.cs b/src/BaGet.Core/Search/DatabaseSearchService.cs index 87102dcc2..362935c20 100644 --- a/src/BaGet.Core/Search/DatabaseSearchService.cs +++ b/src/BaGet.Core/Search/DatabaseSearchService.cs @@ -77,7 +77,7 @@ public async Task SearchAsync( Version = latest.Version.ToFullString(), Description = latest.Description, Authors = latest.Authors, - IconUrl = latest.IconUrlString, + IconUrl = !string.IsNullOrEmpty(latest.IconUrlString) ? latest.IconUrlString : _url.GetPackageIconDownloadUrl(latest.Id, latest.Version), LicenseUrl = latest.LicenseUrlString, ProjectUrl = latest.ProjectUrlString, RegistrationIndexUrl = _url.GetRegistrationIndexUrl(latest.Id), From e32d108ef5af9c4e521bb3ac562592f00065e0a6 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Sun, 9 Feb 2020 16:21:25 -0800 Subject: [PATCH 06/22] Updates --- src/BaGet.Azure/Search/AzureSearchService.cs | 6 +++++- src/BaGet.Azure/Search/IndexActionBuilder.cs | 1 + src/BaGet.Azure/Search/PackageDocument.cs | 1 + src/BaGet.Azure/Table/TableSearchService.cs | 6 +++++- src/BaGet.Core.Server/BaGetUrlGenerator.cs | 3 +-- src/BaGet.Core/Indexing/PackageIndexingService.cs | 1 + src/BaGet.Core/Search/DatabaseSearchService.cs | 5 ++++- src/Directory.Build.props | 2 +- 8 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/BaGet.Azure/Search/AzureSearchService.cs b/src/BaGet.Azure/Search/AzureSearchService.cs index a76d66dc8..c1d9bffa1 100644 --- a/src/BaGet.Azure/Search/AzureSearchService.cs +++ b/src/BaGet.Azure/Search/AzureSearchService.cs @@ -96,13 +96,17 @@ public async Task SearchAsync( }); } + var iconUrl = document.HasIcon + ? _url.GetPackageIconDownloadUrl(document.Id, NuGetVersion.Parse(document.Version)) + : document.IconUrl; + results.Add(new SearchResult { PackageId = document.Id, Version = document.Version, Description = document.Description, Authors = document.Authors, - IconUrl = !string.IsNullOrEmpty(document.IconUrl) ? document.IconUrl : _url.GetPackageIconDownloadUrl(document.Id, new NuGetVersion(document.Version)), + IconUrl = iconUrl, LicenseUrl = document.LicenseUrl, ProjectUrl = document.ProjectUrl, RegistrationIndexUrl = _url.GetRegistrationIndexUrl(document.Id), diff --git a/src/BaGet.Azure/Search/IndexActionBuilder.cs b/src/BaGet.Azure/Search/IndexActionBuilder.cs index a33e88807..95363588a 100644 --- a/src/BaGet.Azure/Search/IndexActionBuilder.cs +++ b/src/BaGet.Azure/Search/IndexActionBuilder.cs @@ -79,6 +79,7 @@ private IReadOnlyList> AddOrUpdatePackage( document.Version = latest.Version.ToFullString(); document.Description = latest.Description; document.Authors = latest.Authors; + document.HasIcon = latest.HasIcon; document.IconUrl = latest.IconUrlString; document.LicenseUrl = latest.LicenseUrlString; document.ProjectUrl = latest.ProjectUrlString; diff --git a/src/BaGet.Azure/Search/PackageDocument.cs b/src/BaGet.Azure/Search/PackageDocument.cs index a98f2a90a..a4cc79e4f 100644 --- a/src/BaGet.Azure/Search/PackageDocument.cs +++ b/src/BaGet.Azure/Search/PackageDocument.cs @@ -23,6 +23,7 @@ public class PackageDocument : KeyedDocument [IsSearchable] public string Description { get; set; } public string[] Authors { get; set; } + public bool HasIcon { get; set; } public string IconUrl { get; set; } public string LicenseUrl { get; set; } public string ProjectUrl { get; set; } diff --git a/src/BaGet.Azure/Table/TableSearchService.cs b/src/BaGet.Azure/Table/TableSearchService.cs index b975b4f97..3d38e674d 100644 --- a/src/BaGet.Azure/Table/TableSearchService.cs +++ b/src/BaGet.Azure/Table/TableSearchService.cs @@ -237,13 +237,17 @@ private SearchResult ToSearchResult(IReadOnlyList packages) } } + var iconUrl = latest.HasIcon + ? _url.GetPackageIconDownloadUrl(latest.Id, latestVersion) + : latest.IconUrl; + return new SearchResult { PackageId = latest.Id, Version = latest.NormalizedVersion, Description = latest.Description, Authors = JsonConvert.DeserializeObject(latest.Authors), - IconUrl = !string.IsNullOrEmpty(latest.IconUrl) ? latest.IconUrl : _url.GetPackageIconDownloadUrl(latest.Id, new NuGetVersion(versions.FirstOrDefault()?.Version)), + IconUrl = iconUrl, LicenseUrl = latest.LicenseUrl, ProjectUrl = latest.ProjectUrl, RegistrationIndexUrl = _url.GetRegistrationIndexUrl(latest.Id), diff --git a/src/BaGet.Core.Server/BaGetUrlGenerator.cs b/src/BaGet.Core.Server/BaGetUrlGenerator.cs index af16522b9..bfcc399ea 100644 --- a/src/BaGet.Core.Server/BaGetUrlGenerator.cs +++ b/src/BaGet.Core.Server/BaGetUrlGenerator.cs @@ -137,8 +137,7 @@ public string GetPackageIconDownloadUrl(string id, NuGetVersion version) values: new { Id = id, - Version = versionString, - Id2 = id, + Version = versionString }); } diff --git a/src/BaGet.Core/Indexing/PackageIndexingService.cs b/src/BaGet.Core/Indexing/PackageIndexingService.cs index b0b9cff3b..f38843bd2 100644 --- a/src/BaGet.Core/Indexing/PackageIndexingService.cs +++ b/src/BaGet.Core/Indexing/PackageIndexingService.cs @@ -13,6 +13,7 @@ public class PackageIndexingService : IPackageIndexingService private readonly IPackageService _packages; private readonly IPackageStorageService _storage; private readonly ISearchIndexer _search; + private readonly IUrlGenerator _url; private readonly IOptionsSnapshot _options; private readonly ILogger _logger; diff --git a/src/BaGet.Core/Search/DatabaseSearchService.cs b/src/BaGet.Core/Search/DatabaseSearchService.cs index c52f0f713..1c213a86f 100644 --- a/src/BaGet.Core/Search/DatabaseSearchService.cs +++ b/src/BaGet.Core/Search/DatabaseSearchService.cs @@ -70,6 +70,9 @@ public async Task SearchAsync( { var versions = package.OrderByDescending(p => p.Version).ToList(); var latest = versions.First(); + var iconUrl = latest.HasIcon + ? _url.GetPackageIconDownloadUrl(latest.Id, latest.Version) + : latest.IconUrlString; result.Add(new SearchResult { @@ -77,7 +80,7 @@ public async Task SearchAsync( Version = latest.Version.ToFullString(), Description = latest.Description, Authors = latest.Authors, - IconUrl = !string.IsNullOrEmpty(latest.IconUrlString) ? latest.IconUrlString : _url.GetPackageIconDownloadUrl(latest.Id, latest.Version), + IconUrl = iconUrl, LicenseUrl = latest.LicenseUrlString, ProjectUrl = latest.ProjectUrlString, RegistrationIndexUrl = _url.GetRegistrationIndexUrl(latest.Id), diff --git a/src/Directory.Build.props b/src/Directory.Build.props index ec5bb2652..11d010673 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -30,7 +30,7 @@ 3.1.1 3.1.1 3.1.1 - 5.0.0-rtm.5856 + 5.4.0 From 5f0a54797fd24b0e3860c34038e8e34542e02d57 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Sun, 9 Feb 2020 16:23:58 -0800 Subject: [PATCH 07/22] Updates --- src/BaGet.Core.Server/Controllers/PackageContentController.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/BaGet.Core.Server/Controllers/PackageContentController.cs b/src/BaGet.Core.Server/Controllers/PackageContentController.cs index 8b88bd609..0b78b29a8 100644 --- a/src/BaGet.Core.Server/Controllers/PackageContentController.cs +++ b/src/BaGet.Core.Server/Controllers/PackageContentController.cs @@ -1,3 +1,4 @@ + using System; using System.Threading; using System.Threading.Tasks; @@ -93,7 +94,7 @@ public async Task DownloadIconAsync(string id, string version, Ca return NotFound(); } - return File(iconStream, "image/png"); + return File(iconStream, contentType: ""); } } } From b642661c1fba303854783c9bf14f2dfc4e1bb2a9 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Sun, 9 Feb 2020 16:25:55 -0800 Subject: [PATCH 08/22] Updates --- src/BaGet.Core/Storage/PackageStorageService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BaGet.Core/Storage/PackageStorageService.cs b/src/BaGet.Core/Storage/PackageStorageService.cs index f3f573e1b..f096384bd 100644 --- a/src/BaGet.Core/Storage/PackageStorageService.cs +++ b/src/BaGet.Core/Storage/PackageStorageService.cs @@ -15,7 +15,7 @@ public class PackageStorageService : IPackageStorageService private const string PackageContentType = "binary/octet-stream"; private const string NuspecContentType = "text/plain"; private const string ReadmeContentType = "text/markdown"; - private const string IconContentType = "image/png"; + private const string IconContentType = ""; private readonly IStorageService _storage; private readonly ILogger _logger; From c2e1a647a5349764ddcd18e48279e54e9f19bb94 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Sun, 9 Feb 2020 16:30:00 -0800 Subject: [PATCH 09/22] Updates --- src/BaGet.Azure/Search/AzureSearchService.cs | 2 +- src/BaGet.Azure/Search/IndexActionBuilder.cs | 2 +- src/BaGet.Azure/Search/PackageDocument.cs | 2 +- src/BaGet.Azure/Table/PackageEntity.cs | 2 +- src/BaGet.Azure/Table/TableOperationBuilder.cs | 2 +- src/BaGet.Azure/Table/TablePackageService.cs | 2 +- src/BaGet.Azure/Table/TableSearchService.cs | 2 +- src/BaGet.Core/Content/DefaultPackageContentService.cs | 2 +- src/BaGet.Core/Entities/Package.cs | 2 +- src/BaGet.Core/Extensions/PackageArchiveReaderExtensions.cs | 4 ++-- src/BaGet.Core/Indexing/PackageIndexingService.cs | 2 +- src/BaGet.Core/Search/DatabaseSearchService.cs | 2 +- tests/Directory.Build.props | 2 +- 13 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/BaGet.Azure/Search/AzureSearchService.cs b/src/BaGet.Azure/Search/AzureSearchService.cs index c1d9bffa1..bbddb2ab5 100644 --- a/src/BaGet.Azure/Search/AzureSearchService.cs +++ b/src/BaGet.Azure/Search/AzureSearchService.cs @@ -96,7 +96,7 @@ public async Task SearchAsync( }); } - var iconUrl = document.HasIcon + var iconUrl = document.HasEmbeddedIcon ? _url.GetPackageIconDownloadUrl(document.Id, NuGetVersion.Parse(document.Version)) : document.IconUrl; diff --git a/src/BaGet.Azure/Search/IndexActionBuilder.cs b/src/BaGet.Azure/Search/IndexActionBuilder.cs index 95363588a..4888e0349 100644 --- a/src/BaGet.Azure/Search/IndexActionBuilder.cs +++ b/src/BaGet.Azure/Search/IndexActionBuilder.cs @@ -79,7 +79,7 @@ private IReadOnlyList> AddOrUpdatePackage( document.Version = latest.Version.ToFullString(); document.Description = latest.Description; document.Authors = latest.Authors; - document.HasIcon = latest.HasIcon; + document.HasEmbeddedIcon = latest.HasEmbeddedIcon; document.IconUrl = latest.IconUrlString; document.LicenseUrl = latest.LicenseUrlString; document.ProjectUrl = latest.ProjectUrlString; diff --git a/src/BaGet.Azure/Search/PackageDocument.cs b/src/BaGet.Azure/Search/PackageDocument.cs index a4cc79e4f..65c1c3b68 100644 --- a/src/BaGet.Azure/Search/PackageDocument.cs +++ b/src/BaGet.Azure/Search/PackageDocument.cs @@ -23,7 +23,7 @@ public class PackageDocument : KeyedDocument [IsSearchable] public string Description { get; set; } public string[] Authors { get; set; } - public bool HasIcon { get; set; } + public bool HasEmbeddedIcon { get; set; } public string IconUrl { get; set; } public string LicenseUrl { get; set; } public string ProjectUrl { get; set; } diff --git a/src/BaGet.Azure/Table/PackageEntity.cs b/src/BaGet.Azure/Table/PackageEntity.cs index af621b3b6..46e9a053d 100644 --- a/src/BaGet.Azure/Table/PackageEntity.cs +++ b/src/BaGet.Azure/Table/PackageEntity.cs @@ -22,7 +22,7 @@ public PackageEntity() public string Description { get; set; } public long Downloads { get; set; } public bool HasReadme { get; set; } - public bool HasIcon { get; set; } + public bool HasEmbeddedIcon { get; set; } public bool IsPrerelease { get; set; } public string Language { get; set; } public bool Listed { get; set; } diff --git a/src/BaGet.Azure/Table/TableOperationBuilder.cs b/src/BaGet.Azure/Table/TableOperationBuilder.cs index dec62e7e9..db4742ad4 100644 --- a/src/BaGet.Azure/Table/TableOperationBuilder.cs +++ b/src/BaGet.Azure/Table/TableOperationBuilder.cs @@ -29,7 +29,7 @@ public TableOperation AddPackage(Package package) Description = package.Description, Downloads = package.Downloads, HasReadme = package.HasReadme, - HasIcon = package.HasIcon, + HasEmbeddedIcon = package.HasEmbeddedIcon, IsPrerelease = package.IsPrerelease, Language = package.Language, Listed = package.Listed, diff --git a/src/BaGet.Azure/Table/TablePackageService.cs b/src/BaGet.Azure/Table/TablePackageService.cs index a440c6dae..9af6bab12 100644 --- a/src/BaGet.Azure/Table/TablePackageService.cs +++ b/src/BaGet.Azure/Table/TablePackageService.cs @@ -230,7 +230,7 @@ private Package AsPackage(PackageEntity entity) Description = entity.Description, Downloads = entity.Downloads, HasReadme = entity.HasReadme, - HasIcon = entity.HasIcon, + HasEmbeddedIcon = entity.HasEmbeddedIcon, IsPrerelease = entity.IsPrerelease, Language = entity.Language, Listed = entity.Listed, diff --git a/src/BaGet.Azure/Table/TableSearchService.cs b/src/BaGet.Azure/Table/TableSearchService.cs index 3d38e674d..8872ff527 100644 --- a/src/BaGet.Azure/Table/TableSearchService.cs +++ b/src/BaGet.Azure/Table/TableSearchService.cs @@ -237,7 +237,7 @@ private SearchResult ToSearchResult(IReadOnlyList packages) } } - var iconUrl = latest.HasIcon + var iconUrl = latest.HasEmbeddedIcon ? _url.GetPackageIconDownloadUrl(latest.Id, latestVersion) : latest.IconUrl; diff --git a/src/BaGet.Core/Content/DefaultPackageContentService.cs b/src/BaGet.Core/Content/DefaultPackageContentService.cs index 53223a5a5..011714b78 100644 --- a/src/BaGet.Core/Content/DefaultPackageContentService.cs +++ b/src/BaGet.Core/Content/DefaultPackageContentService.cs @@ -107,7 +107,7 @@ public async Task GetPackageIconStreamOrNullAsync(string id, NuGetVersio await _mirror.MirrorAsync(id, version, cancellationToken); var package = await _packages.FindOrNullAsync(id, version, includeUnlisted: true, cancellationToken); - if (!package.HasIcon) + if (!package.HasEmbeddedIcon) { return null; } diff --git a/src/BaGet.Core/Entities/Package.cs b/src/BaGet.Core/Entities/Package.cs index 6315cbd88..f9d64cceb 100644 --- a/src/BaGet.Core/Entities/Package.cs +++ b/src/BaGet.Core/Entities/Package.cs @@ -34,7 +34,7 @@ public NuGetVersion Version public string Description { get; set; } public long Downloads { get; set; } public bool HasReadme { get; set; } - public bool HasIcon { get; set; } + public bool HasEmbeddedIcon { get; set; } public bool IsPrerelease { get; set; } public string ReleaseNotes { get; set; } public string Language { get; set; } diff --git a/src/BaGet.Core/Extensions/PackageArchiveReaderExtensions.cs b/src/BaGet.Core/Extensions/PackageArchiveReaderExtensions.cs index c22b9ad64..7402bb4e3 100644 --- a/src/BaGet.Core/Extensions/PackageArchiveReaderExtensions.cs +++ b/src/BaGet.Core/Extensions/PackageArchiveReaderExtensions.cs @@ -25,7 +25,7 @@ public static class PackageArchiveReaderExtensions public static bool HasReadme(this PackageArchiveReader package) => package.GetFiles().Any(ReadmeFileNames.Contains); - public static bool HasIcon(this PackageArchiveReader package) + public static bool HasEmbeddedIcon(this PackageArchiveReader package) => !string.IsNullOrEmpty(package.NuspecReader.GetIcon()); public async static Task GetReadmeAsync( @@ -67,7 +67,7 @@ public static Package GetPackageMetadata(this PackageArchiveReader packageReader Authors = ParseAuthors(nuspec.GetAuthors()), Description = nuspec.GetDescription(), HasReadme = packageReader.HasReadme(), - HasIcon = packageReader.HasIcon(), + HasEmbeddedIcon = packageReader.HasEmbeddedIcon(), IsPrerelease = nuspec.GetVersion().IsPrerelease, Language = nuspec.GetLanguage() ?? string.Empty, ReleaseNotes = nuspec.GetReleaseNotes() ?? string.Empty, diff --git a/src/BaGet.Core/Indexing/PackageIndexingService.cs b/src/BaGet.Core/Indexing/PackageIndexingService.cs index f38843bd2..f8cac6fb6 100644 --- a/src/BaGet.Core/Indexing/PackageIndexingService.cs +++ b/src/BaGet.Core/Indexing/PackageIndexingService.cs @@ -57,7 +57,7 @@ public async Task IndexAsync(Stream packageStream, Cancel readmeStream = null; } - if (package.HasIcon) + if (package.HasEmbeddedIcon) { iconStream = await packageReader.GetIconAsync(cancellationToken); iconStream = await iconStream.AsTemporaryFileStreamAsync(); diff --git a/src/BaGet.Core/Search/DatabaseSearchService.cs b/src/BaGet.Core/Search/DatabaseSearchService.cs index 1c213a86f..ebebae693 100644 --- a/src/BaGet.Core/Search/DatabaseSearchService.cs +++ b/src/BaGet.Core/Search/DatabaseSearchService.cs @@ -70,7 +70,7 @@ public async Task SearchAsync( { var versions = package.OrderByDescending(p => p.Version).ToList(); var latest = versions.First(); - var iconUrl = latest.HasIcon + var iconUrl = latest.HasEmbeddedIcon ? _url.GetPackageIconDownloadUrl(latest.Id, latest.Version) : latest.IconUrlString; diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index 1dec614f6..bece70dc0 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -15,7 +15,7 @@ 3.0.2 4.10.0 12.0.2 - 5.0.0-rtm.5856 + 5.4.0 2.4.1 From 69ac04f7e80009767ab98f783e95d2d0d9d899ac Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Sun, 9 Feb 2020 16:36:35 -0800 Subject: [PATCH 10/22] Fix test --- tests/BaGet.Core.Tests/Services/PackageStorageServiceTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/BaGet.Core.Tests/Services/PackageStorageServiceTests.cs b/tests/BaGet.Core.Tests/Services/PackageStorageServiceTests.cs index 34073e3fe..49805ff82 100644 --- a/tests/BaGet.Core.Tests/Services/PackageStorageServiceTests.cs +++ b/tests/BaGet.Core.Tests/Services/PackageStorageServiceTests.cs @@ -85,7 +85,7 @@ await _target.SavePackageContentAsync( Assert.True(_puts.ContainsKey(IconPath)); Assert.Equal("My icon", await ToStringAsync(_puts[IconPath].Content)); - Assert.Equal("image/png", _puts[IconPath].ContentType); + Assert.Equal("", _puts[IconPath].ContentType); } } From 484b2ecdd6b82417973f9a19e94faae74d01a688 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Sun, 9 Feb 2020 16:41:08 -0800 Subject: [PATCH 11/22] Fix warning --- src/BaGet.Protocol/Catalog/NullCatalogClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BaGet.Protocol/Catalog/NullCatalogClient.cs b/src/BaGet.Protocol/Catalog/NullCatalogClient.cs index dac19bf78..b77dc15b0 100644 --- a/src/BaGet.Protocol/Catalog/NullCatalogClient.cs +++ b/src/BaGet.Protocol/Catalog/NullCatalogClient.cs @@ -18,7 +18,7 @@ public Task GetIndexAsync(CancellationToken cancellationToken = de }); } - public async Task GetPageAsync(string pageUrl, CancellationToken cancellationToken = default) + public Task GetPageAsync(string pageUrl, CancellationToken cancellationToken = default) { throw new NotSupportedException($"{nameof(NullCatalogClient)} does not support loading catalog pages."); } From 61147cff620b231e64304cb3759444589d69ca38 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Sun, 9 Feb 2020 16:46:15 -0800 Subject: [PATCH 12/22] Fix build --- src/BaGet.Core/BaGet.Core.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BaGet.Core/BaGet.Core.csproj b/src/BaGet.Core/BaGet.Core.csproj index 7fd3570c6..8c1287492 100644 --- a/src/BaGet.Core/BaGet.Core.csproj +++ b/src/BaGet.Core/BaGet.Core.csproj @@ -12,7 +12,7 @@ - + From 6d8fbd9b996905c7a8209cc4c216e503f598f988 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Sun, 9 Feb 2020 16:46:25 -0800 Subject: [PATCH 13/22] Rebuild migrations --- ...4047_AddHasEmbeddedIconColumn.Designer.cs} | 86 +++++++++++++----- ...0200210004047_AddHasEmbeddedIconColumn.cs} | 13 +-- .../Migrations/MySqlContextModelSnapshot.cs | 78 ++++++++++++---- ...4256_AddHasEmbeddedIconColumn.Designer.cs} | 88 ++++++++++++++----- ...0200210004256_AddHasEmbeddedIconColumn.cs} | 6 +- .../PostgreSqlContextModelSnapshot.cs | 2 +- ...4408_AddHasEmbeddedIconColumn.Designer.cs} | 78 ++++++++++++---- ...0200210004408_AddHasEmbeddedIconColumn.cs} | 6 +- .../SqlServerContextModelSnapshot.cs | 70 +++++++++++---- ...4344_AddHasEmbeddedIconColumn.Designer.cs} | 82 ++++++++++++----- ...0200210004344_AddHasEmbeddedIconColumn.cs} | 6 +- .../Migrations/SqliteContextModelSnapshot.cs | 2 +- 12 files changed, 386 insertions(+), 131 deletions(-) rename src/BaGet.Database.MySql/Migrations/{20191113053926_AddHasIconColumn.Designer.cs => 20200210004047_AddHasEmbeddedIconColumn.Designer.cs} (58%) rename src/BaGet.Database.MySql/Migrations/{20191113053926_AddHasIconColumn.cs => 20200210004047_AddHasEmbeddedIconColumn.cs} (67%) rename src/BaGet.Database.PostgreSql/Migrations/{20191113054029_AddHasIconColumn.Designer.cs => 20200210004256_AddHasEmbeddedIconColumn.Designer.cs} (59%) rename src/BaGet.Database.PostgreSql/Migrations/{20191113054029_AddHasIconColumn.cs => 20200210004256_AddHasEmbeddedIconColumn.cs} (78%) rename src/BaGet.Database.SqlServer/Migrations/{20191113054208_AddHasIconColumn.Designer.cs => 20200210004408_AddHasEmbeddedIconColumn.Designer.cs} (66%) rename src/BaGet.Database.SqlServer/Migrations/{20191113054208_AddHasIconColumn.cs => 20200210004408_AddHasEmbeddedIconColumn.cs} (78%) rename src/BaGet.Database.Sqlite/Migrations/{20191113053824_AddHasIconColumn.Designer.cs => 20200210004344_AddHasEmbeddedIconColumn.Designer.cs} (64%) rename src/BaGet.Database.Sqlite/Migrations/{20191113053824_AddHasIconColumn.cs => 20200210004344_AddHasEmbeddedIconColumn.cs} (78%) diff --git a/src/BaGet.Database.MySql/Migrations/20191113053926_AddHasIconColumn.Designer.cs b/src/BaGet.Database.MySql/Migrations/20200210004047_AddHasEmbeddedIconColumn.Designer.cs similarity index 58% rename from src/BaGet.Database.MySql/Migrations/20191113053926_AddHasIconColumn.Designer.cs rename to src/BaGet.Database.MySql/Migrations/20200210004047_AddHasEmbeddedIconColumn.Designer.cs index 647580e90..4ad121819 100644 --- a/src/BaGet.Database.MySql/Migrations/20191113053926_AddHasIconColumn.Designer.cs +++ b/src/BaGet.Database.MySql/Migrations/20200210004047_AddHasEmbeddedIconColumn.Designer.cs @@ -9,88 +9,118 @@ namespace BaGet.Database.MySql.Migrations { [DbContext(typeof(MySqlContext))] - [Migration("20191113053926_AddHasIconColumn")] - partial class AddHasIconColumn + [Migration("20200210004047_AddHasEmbeddedIconColumn")] + partial class AddHasEmbeddedIconColumn { protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") + .HasAnnotation("ProductVersion", "3.1.1") .HasAnnotation("Relational:MaxIdentifierLength", 64); modelBuilder.Entity("BaGet.Core.Package", b => { b.Property("Key") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("int"); b.Property("Authors") + .HasColumnType("longtext CHARACTER SET utf8mb4") .HasMaxLength(4000); b.Property("Description") + .HasColumnType("longtext CHARACTER SET utf8mb4") .HasMaxLength(4000); - b.Property("Downloads"); + b.Property("Downloads") + .HasColumnType("bigint"); - b.Property("HasIcon"); + b.Property("HasEmbeddedIcon") + .HasColumnType("tinyint(1)"); - b.Property("HasReadme"); + b.Property("HasReadme") + .HasColumnType("tinyint(1)"); b.Property("IconUrl") + .HasColumnType("longtext CHARACTER SET utf8mb4") .HasMaxLength(4000); b.Property("Id") .IsRequired() + .HasColumnType("varchar(128) CHARACTER SET utf8mb4") .HasMaxLength(128); - b.Property("IsPrerelease"); + b.Property("IsPrerelease") + .HasColumnType("tinyint(1)"); b.Property("Language") + .HasColumnType("varchar(20) CHARACTER SET utf8mb4") .HasMaxLength(20); b.Property("LicenseUrl") + .HasColumnType("longtext CHARACTER SET utf8mb4") .HasMaxLength(4000); - b.Property("Listed"); + b.Property("Listed") + .HasColumnType("tinyint(1)"); b.Property("MinClientVersion") + .HasColumnType("varchar(44) CHARACTER SET utf8mb4") .HasMaxLength(44); b.Property("NormalizedVersionString") .IsRequired() .HasColumnName("Version") + .HasColumnType("varchar(64) CHARACTER SET utf8mb4") .HasMaxLength(64); b.Property("OriginalVersionString") .HasColumnName("OriginalVersion") + .HasColumnType("varchar(64) CHARACTER SET utf8mb4") .HasMaxLength(64); b.Property("ProjectUrl") + .HasColumnType("longtext CHARACTER SET utf8mb4") .HasMaxLength(4000); - b.Property("Published"); + b.Property("Published") + .HasColumnType("datetime(6)"); + + b.Property("ReleaseNotes") + .HasColumnName("ReleaseNotes") + .HasColumnType("longtext CHARACTER SET utf8mb4") + .HasMaxLength(4000); b.Property("RepositoryType") + .HasColumnType("varchar(100) CHARACTER SET utf8mb4") .HasMaxLength(100); b.Property("RepositoryUrl") + .HasColumnType("longtext CHARACTER SET utf8mb4") .HasMaxLength(4000); - b.Property("RequireLicenseAcceptance"); + b.Property("RequireLicenseAcceptance") + .HasColumnType("tinyint(1)"); b.Property("RowVersion") .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate(); + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("timestamp(6)"); - b.Property("SemVerLevel"); + b.Property("SemVerLevel") + .HasColumnType("int"); b.Property("Summary") + .HasColumnType("longtext CHARACTER SET utf8mb4") .HasMaxLength(4000); b.Property("Tags") + .HasColumnType("longtext CHARACTER SET utf8mb4") .HasMaxLength(4000); b.Property("Title") + .HasColumnType("varchar(256) CHARACTER SET utf8mb4") .HasMaxLength(256); b.HasKey("Key"); @@ -106,17 +136,22 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("BaGet.Core.PackageDependency", b => { b.Property("Key") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("int"); b.Property("Id") + .HasColumnType("varchar(128) CHARACTER SET utf8mb4") .HasMaxLength(128); - b.Property("PackageKey"); + b.Property("PackageKey") + .HasColumnType("int"); b.Property("TargetFramework") + .HasColumnType("varchar(256) CHARACTER SET utf8mb4") .HasMaxLength(256); b.Property("VersionRange") + .HasColumnType("varchar(256) CHARACTER SET utf8mb4") .HasMaxLength(256); b.HasKey("Key"); @@ -131,14 +166,18 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("BaGet.Core.PackageType", b => { b.Property("Key") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("int"); b.Property("Name") + .HasColumnType("varchar(512) CHARACTER SET utf8mb4") .HasMaxLength(512); - b.Property("PackageKey"); + b.Property("PackageKey") + .HasColumnType("int"); b.Property("Version") + .HasColumnType("varchar(64) CHARACTER SET utf8mb4") .HasMaxLength(64); b.HasKey("Key"); @@ -153,12 +192,15 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("BaGet.Core.TargetFramework", b => { b.Property("Key") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("int"); b.Property("Moniker") + .HasColumnType("varchar(256) CHARACTER SET utf8mb4") .HasMaxLength(256); - b.Property("PackageKey"); + b.Property("PackageKey") + .HasColumnType("int"); b.HasKey("Key"); @@ -181,7 +223,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasOne("BaGet.Core.Package", "Package") .WithMany("PackageTypes") .HasForeignKey("PackageKey") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); modelBuilder.Entity("BaGet.Core.TargetFramework", b => @@ -189,7 +232,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasOne("BaGet.Core.Package", "Package") .WithMany("TargetFrameworks") .HasForeignKey("PackageKey") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); #pragma warning restore 612, 618 } diff --git a/src/BaGet.Database.MySql/Migrations/20191113053926_AddHasIconColumn.cs b/src/BaGet.Database.MySql/Migrations/20200210004047_AddHasEmbeddedIconColumn.cs similarity index 67% rename from src/BaGet.Database.MySql/Migrations/20191113053926_AddHasIconColumn.cs rename to src/BaGet.Database.MySql/Migrations/20200210004047_AddHasEmbeddedIconColumn.cs index d67db93e4..d9b12c931 100644 --- a/src/BaGet.Database.MySql/Migrations/20191113053926_AddHasIconColumn.cs +++ b/src/BaGet.Database.MySql/Migrations/20200210004047_AddHasEmbeddedIconColumn.cs @@ -1,9 +1,10 @@ using System; +using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; namespace BaGet.Database.MySql.Migrations { - public partial class AddHasIconColumn : Migration + public partial class AddHasEmbeddedIconColumn : Migration { protected override void Up(MigrationBuilder migrationBuilder) { @@ -13,10 +14,11 @@ protected override void Up(MigrationBuilder migrationBuilder) rowVersion: true, nullable: true, oldClrType: typeof(DateTime), - oldNullable: true); + oldNullable: true) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn); migrationBuilder.AddColumn( - name: "HasIcon", + name: "HasEmbeddedIcon", table: "Packages", nullable: false, defaultValue: false); @@ -25,7 +27,7 @@ protected override void Up(MigrationBuilder migrationBuilder) protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropColumn( - name: "HasIcon", + name: "HasEmbeddedIcon", table: "Packages"); migrationBuilder.AlterColumn( @@ -34,7 +36,8 @@ protected override void Down(MigrationBuilder migrationBuilder) nullable: true, oldClrType: typeof(DateTime), oldRowVersion: true, - oldNullable: true); + oldNullable: true) + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn); } } } diff --git a/src/BaGet.Database.MySql/Migrations/MySqlContextModelSnapshot.cs b/src/BaGet.Database.MySql/Migrations/MySqlContextModelSnapshot.cs index b69a2cb50..363c445c0 100644 --- a/src/BaGet.Database.MySql/Migrations/MySqlContextModelSnapshot.cs +++ b/src/BaGet.Database.MySql/Migrations/MySqlContextModelSnapshot.cs @@ -14,85 +14,111 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") + .HasAnnotation("ProductVersion", "3.1.1") .HasAnnotation("Relational:MaxIdentifierLength", 64); modelBuilder.Entity("BaGet.Core.Package", b => { b.Property("Key") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("int"); b.Property("Authors") + .HasColumnType("longtext CHARACTER SET utf8mb4") .HasMaxLength(4000); b.Property("Description") + .HasColumnType("longtext CHARACTER SET utf8mb4") .HasMaxLength(4000); - b.Property("Downloads"); + b.Property("Downloads") + .HasColumnType("bigint"); - b.Property("HasIcon"); + b.Property("HasEmbeddedIcon") + .HasColumnType("tinyint(1)"); - b.Property("HasReadme"); + b.Property("HasReadme") + .HasColumnType("tinyint(1)"); b.Property("IconUrl") + .HasColumnType("longtext CHARACTER SET utf8mb4") .HasMaxLength(4000); b.Property("Id") .IsRequired() + .HasColumnType("varchar(128) CHARACTER SET utf8mb4") .HasMaxLength(128); - b.Property("IsPrerelease"); + b.Property("IsPrerelease") + .HasColumnType("tinyint(1)"); b.Property("Language") + .HasColumnType("varchar(20) CHARACTER SET utf8mb4") .HasMaxLength(20); b.Property("LicenseUrl") + .HasColumnType("longtext CHARACTER SET utf8mb4") .HasMaxLength(4000); - b.Property("Listed"); + b.Property("Listed") + .HasColumnType("tinyint(1)"); b.Property("MinClientVersion") + .HasColumnType("varchar(44) CHARACTER SET utf8mb4") .HasMaxLength(44); b.Property("NormalizedVersionString") .IsRequired() .HasColumnName("Version") + .HasColumnType("varchar(64) CHARACTER SET utf8mb4") .HasMaxLength(64); b.Property("OriginalVersionString") .HasColumnName("OriginalVersion") + .HasColumnType("varchar(64) CHARACTER SET utf8mb4") .HasMaxLength(64); b.Property("ProjectUrl") + .HasColumnType("longtext CHARACTER SET utf8mb4") .HasMaxLength(4000); - b.Property("Published"); + b.Property("Published") + .HasColumnType("datetime(6)"); b.Property("ReleaseNotes") .HasColumnName("ReleaseNotes") + .HasColumnType("longtext CHARACTER SET utf8mb4") .HasMaxLength(4000); b.Property("RepositoryType") + .HasColumnType("varchar(100) CHARACTER SET utf8mb4") .HasMaxLength(100); b.Property("RepositoryUrl") + .HasColumnType("longtext CHARACTER SET utf8mb4") .HasMaxLength(4000); - b.Property("RequireLicenseAcceptance"); + b.Property("RequireLicenseAcceptance") + .HasColumnType("tinyint(1)"); b.Property("RowVersion") .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate(); + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("timestamp(6)"); - b.Property("SemVerLevel"); + b.Property("SemVerLevel") + .HasColumnType("int"); b.Property("Summary") + .HasColumnType("longtext CHARACTER SET utf8mb4") .HasMaxLength(4000); b.Property("Tags") + .HasColumnType("longtext CHARACTER SET utf8mb4") .HasMaxLength(4000); b.Property("Title") + .HasColumnType("varchar(256) CHARACTER SET utf8mb4") .HasMaxLength(256); b.HasKey("Key"); @@ -108,17 +134,22 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("BaGet.Core.PackageDependency", b => { b.Property("Key") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("int"); b.Property("Id") + .HasColumnType("varchar(128) CHARACTER SET utf8mb4") .HasMaxLength(128); - b.Property("PackageKey"); + b.Property("PackageKey") + .HasColumnType("int"); b.Property("TargetFramework") + .HasColumnType("varchar(256) CHARACTER SET utf8mb4") .HasMaxLength(256); b.Property("VersionRange") + .HasColumnType("varchar(256) CHARACTER SET utf8mb4") .HasMaxLength(256); b.HasKey("Key"); @@ -133,14 +164,18 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("BaGet.Core.PackageType", b => { b.Property("Key") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("int"); b.Property("Name") + .HasColumnType("varchar(512) CHARACTER SET utf8mb4") .HasMaxLength(512); - b.Property("PackageKey"); + b.Property("PackageKey") + .HasColumnType("int"); b.Property("Version") + .HasColumnType("varchar(64) CHARACTER SET utf8mb4") .HasMaxLength(64); b.HasKey("Key"); @@ -155,12 +190,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("BaGet.Core.TargetFramework", b => { b.Property("Key") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("int"); b.Property("Moniker") + .HasColumnType("varchar(256) CHARACTER SET utf8mb4") .HasMaxLength(256); - b.Property("PackageKey"); + b.Property("PackageKey") + .HasColumnType("int"); b.HasKey("Key"); @@ -183,7 +221,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasOne("BaGet.Core.Package", "Package") .WithMany("PackageTypes") .HasForeignKey("PackageKey") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); modelBuilder.Entity("BaGet.Core.TargetFramework", b => @@ -191,7 +230,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasOne("BaGet.Core.Package", "Package") .WithMany("TargetFrameworks") .HasForeignKey("PackageKey") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); #pragma warning restore 612, 618 } diff --git a/src/BaGet.Database.PostgreSql/Migrations/20191113054029_AddHasIconColumn.Designer.cs b/src/BaGet.Database.PostgreSql/Migrations/20200210004256_AddHasEmbeddedIconColumn.Designer.cs similarity index 59% rename from src/BaGet.Database.PostgreSql/Migrations/20191113054029_AddHasIconColumn.Designer.cs rename to src/BaGet.Database.PostgreSql/Migrations/20200210004256_AddHasEmbeddedIconColumn.Designer.cs index b04d03cb7..aa9cfde3e 100644 --- a/src/BaGet.Database.PostgreSql/Migrations/20191113054029_AddHasIconColumn.Designer.cs +++ b/src/BaGet.Database.PostgreSql/Migrations/20200210004256_AddHasEmbeddedIconColumn.Designer.cs @@ -10,36 +10,44 @@ namespace BaGet.Database.PostgreSql.Migrations { [DbContext(typeof(PostgreSqlContext))] - [Migration("20191113054029_AddHasIconColumn")] - partial class AddHasIconColumn + [Migration("20200210004256_AddHasEmbeddedIconColumn")] + partial class AddHasEmbeddedIconColumn { protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder .HasAnnotation("Npgsql:PostgresExtension:citext", ",,") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) - .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) + .HasAnnotation("ProductVersion", "3.1.1") .HasAnnotation("Relational:MaxIdentifierLength", 63); modelBuilder.Entity("BaGet.Core.Package", b => { b.Property("Key") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); b.Property("Authors") + .HasColumnType("character varying(4000)") .HasMaxLength(4000); b.Property("Description") + .HasColumnType("character varying(4000)") .HasMaxLength(4000); - b.Property("Downloads"); + b.Property("Downloads") + .HasColumnType("bigint"); - b.Property("HasIcon"); + b.Property("HasEmbeddedIcon") + .HasColumnType("boolean"); - b.Property("HasReadme"); + b.Property("HasReadme") + .HasColumnType("boolean"); b.Property("IconUrl") + .HasColumnType("character varying(4000)") .HasMaxLength(4000); b.Property("Id") @@ -47,54 +55,76 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("citext") .HasMaxLength(128); - b.Property("IsPrerelease"); + b.Property("IsPrerelease") + .HasColumnType("boolean"); b.Property("Language") + .HasColumnType("character varying(20)") .HasMaxLength(20); b.Property("LicenseUrl") + .HasColumnType("character varying(4000)") .HasMaxLength(4000); - b.Property("Listed"); + b.Property("Listed") + .HasColumnType("boolean"); b.Property("MinClientVersion") + .HasColumnType("character varying(44)") .HasMaxLength(44); b.Property("NormalizedVersionString") .IsRequired() .HasColumnName("Version") + .HasColumnType("citext") .HasMaxLength(64); b.Property("OriginalVersionString") .HasColumnName("OriginalVersion") + .HasColumnType("character varying(64)") .HasMaxLength(64); b.Property("ProjectUrl") + .HasColumnType("character varying(4000)") .HasMaxLength(4000); - b.Property("Published"); + b.Property("Published") + .HasColumnType("timestamp without time zone"); + + b.Property("ReleaseNotes") + .HasColumnName("ReleaseNotes") + .HasColumnType("character varying(4000)") + .HasMaxLength(4000); b.Property("RepositoryType") + .HasColumnType("character varying(100)") .HasMaxLength(100); b.Property("RepositoryUrl") + .HasColumnType("character varying(4000)") .HasMaxLength(4000); - b.Property("RequireLicenseAcceptance"); + b.Property("RequireLicenseAcceptance") + .HasColumnType("boolean"); b.Property("RowVersion") .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate(); + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("bytea"); - b.Property("SemVerLevel"); + b.Property("SemVerLevel") + .HasColumnType("integer"); b.Property("Summary") + .HasColumnType("character varying(4000)") .HasMaxLength(4000); b.Property("Tags") + .HasColumnType("character varying(4000)") .HasMaxLength(4000); b.Property("Title") + .HasColumnType("character varying(256)") .HasMaxLength(256); b.HasKey("Key"); @@ -110,18 +140,23 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("BaGet.Core.PackageDependency", b => { b.Property("Key") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); b.Property("Id") .HasColumnType("citext") .HasMaxLength(128); - b.Property("PackageKey"); + b.Property("PackageKey") + .HasColumnType("integer"); b.Property("TargetFramework") + .HasColumnType("character varying(256)") .HasMaxLength(256); b.Property("VersionRange") + .HasColumnType("character varying(256)") .HasMaxLength(256); b.HasKey("Key"); @@ -136,15 +171,19 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("BaGet.Core.PackageType", b => { b.Property("Key") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); b.Property("Name") .HasColumnType("citext") .HasMaxLength(512); - b.Property("PackageKey"); + b.Property("PackageKey") + .HasColumnType("integer"); b.Property("Version") + .HasColumnType("character varying(64)") .HasMaxLength(64); b.HasKey("Key"); @@ -159,13 +198,16 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("BaGet.Core.TargetFramework", b => { b.Property("Key") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); b.Property("Moniker") .HasColumnType("citext") .HasMaxLength(256); - b.Property("PackageKey"); + b.Property("PackageKey") + .HasColumnType("integer"); b.HasKey("Key"); @@ -188,7 +230,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasOne("BaGet.Core.Package", "Package") .WithMany("PackageTypes") .HasForeignKey("PackageKey") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); modelBuilder.Entity("BaGet.Core.TargetFramework", b => @@ -196,7 +239,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasOne("BaGet.Core.Package", "Package") .WithMany("TargetFrameworks") .HasForeignKey("PackageKey") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); #pragma warning restore 612, 618 } diff --git a/src/BaGet.Database.PostgreSql/Migrations/20191113054029_AddHasIconColumn.cs b/src/BaGet.Database.PostgreSql/Migrations/20200210004256_AddHasEmbeddedIconColumn.cs similarity index 78% rename from src/BaGet.Database.PostgreSql/Migrations/20191113054029_AddHasIconColumn.cs rename to src/BaGet.Database.PostgreSql/Migrations/20200210004256_AddHasEmbeddedIconColumn.cs index 1b672b835..704cc1cec 100644 --- a/src/BaGet.Database.PostgreSql/Migrations/20191113054029_AddHasIconColumn.cs +++ b/src/BaGet.Database.PostgreSql/Migrations/20200210004256_AddHasEmbeddedIconColumn.cs @@ -2,12 +2,12 @@ namespace BaGet.Database.PostgreSql.Migrations { - public partial class AddHasIconColumn : Migration + public partial class AddHasEmbeddedIconColumn : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( - name: "HasIcon", + name: "HasEmbeddedIcon", table: "Packages", nullable: false, defaultValue: false); @@ -16,7 +16,7 @@ protected override void Up(MigrationBuilder migrationBuilder) protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropColumn( - name: "HasIcon", + name: "HasEmbeddedIcon", table: "Packages"); } } diff --git a/src/BaGet.Database.PostgreSql/Migrations/PostgreSqlContextModelSnapshot.cs b/src/BaGet.Database.PostgreSql/Migrations/PostgreSqlContextModelSnapshot.cs index 172016bc0..36ae9b635 100644 --- a/src/BaGet.Database.PostgreSql/Migrations/PostgreSqlContextModelSnapshot.cs +++ b/src/BaGet.Database.PostgreSql/Migrations/PostgreSqlContextModelSnapshot.cs @@ -38,7 +38,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Downloads") .HasColumnType("bigint"); - b.Property("HasIcon") + b.Property("HasEmbeddedIcon") .HasColumnType("boolean"); b.Property("HasReadme") diff --git a/src/BaGet.Database.SqlServer/Migrations/20191113054208_AddHasIconColumn.Designer.cs b/src/BaGet.Database.SqlServer/Migrations/20200210004408_AddHasEmbeddedIconColumn.Designer.cs similarity index 66% rename from src/BaGet.Database.SqlServer/Migrations/20191113054208_AddHasIconColumn.Designer.cs rename to src/BaGet.Database.SqlServer/Migrations/20200210004408_AddHasEmbeddedIconColumn.Designer.cs index 64de879b5..2bdbefa7a 100644 --- a/src/BaGet.Database.SqlServer/Migrations/20191113054208_AddHasIconColumn.Designer.cs +++ b/src/BaGet.Database.SqlServer/Migrations/20200210004408_AddHasEmbeddedIconColumn.Designer.cs @@ -10,14 +10,14 @@ namespace BaGet.Database.SqlServer.Migrations { [DbContext(typeof(SqlServerContext))] - [Migration("20191113054208_AddHasIconColumn")] - partial class AddHasIconColumn + [Migration("20200210004408_AddHasEmbeddedIconColumn")] + partial class AddHasEmbeddedIconColumn { protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") + .HasAnnotation("ProductVersion", "3.1.1") .HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); @@ -25,75 +25,105 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) { b.Property("Key") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); b.Property("Authors") + .HasColumnType("nvarchar(4000)") .HasMaxLength(4000); b.Property("Description") + .HasColumnType("nvarchar(4000)") .HasMaxLength(4000); - b.Property("Downloads"); + b.Property("Downloads") + .HasColumnType("bigint"); - b.Property("HasIcon"); + b.Property("HasEmbeddedIcon") + .HasColumnType("bit"); - b.Property("HasReadme"); + b.Property("HasReadme") + .HasColumnType("bit"); b.Property("IconUrl") + .HasColumnType("nvarchar(4000)") .HasMaxLength(4000); b.Property("Id") .IsRequired() + .HasColumnType("nvarchar(128)") .HasMaxLength(128); - b.Property("IsPrerelease"); + b.Property("IsPrerelease") + .HasColumnType("bit"); b.Property("Language") + .HasColumnType("nvarchar(20)") .HasMaxLength(20); b.Property("LicenseUrl") + .HasColumnType("nvarchar(4000)") .HasMaxLength(4000); - b.Property("Listed"); + b.Property("Listed") + .HasColumnType("bit"); b.Property("MinClientVersion") + .HasColumnType("nvarchar(44)") .HasMaxLength(44); b.Property("NormalizedVersionString") .IsRequired() .HasColumnName("Version") + .HasColumnType("nvarchar(64)") .HasMaxLength(64); b.Property("OriginalVersionString") .HasColumnName("OriginalVersion") + .HasColumnType("nvarchar(64)") .HasMaxLength(64); b.Property("ProjectUrl") + .HasColumnType("nvarchar(4000)") .HasMaxLength(4000); - b.Property("Published"); + b.Property("Published") + .HasColumnType("datetime2"); + + b.Property("ReleaseNotes") + .HasColumnName("ReleaseNotes") + .HasColumnType("nvarchar(4000)") + .HasMaxLength(4000); b.Property("RepositoryType") + .HasColumnType("nvarchar(100)") .HasMaxLength(100); b.Property("RepositoryUrl") + .HasColumnType("nvarchar(4000)") .HasMaxLength(4000); - b.Property("RequireLicenseAcceptance"); + b.Property("RequireLicenseAcceptance") + .HasColumnType("bit"); b.Property("RowVersion") .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate(); + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); - b.Property("SemVerLevel"); + b.Property("SemVerLevel") + .HasColumnType("int"); b.Property("Summary") + .HasColumnType("nvarchar(4000)") .HasMaxLength(4000); b.Property("Tags") + .HasColumnType("nvarchar(4000)") .HasMaxLength(4000); b.Property("Title") + .HasColumnType("nvarchar(256)") .HasMaxLength(256); b.HasKey("Key"); @@ -110,17 +140,22 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) { b.Property("Key") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); b.Property("Id") + .HasColumnType("nvarchar(128)") .HasMaxLength(128); - b.Property("PackageKey"); + b.Property("PackageKey") + .HasColumnType("int"); b.Property("TargetFramework") + .HasColumnType("nvarchar(256)") .HasMaxLength(256); b.Property("VersionRange") + .HasColumnType("nvarchar(256)") .HasMaxLength(256); b.HasKey("Key"); @@ -136,14 +171,18 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) { b.Property("Key") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); b.Property("Name") + .HasColumnType("nvarchar(512)") .HasMaxLength(512); - b.Property("PackageKey"); + b.Property("PackageKey") + .HasColumnType("int"); b.Property("Version") + .HasColumnType("nvarchar(64)") .HasMaxLength(64); b.HasKey("Key"); @@ -159,12 +198,15 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) { b.Property("Key") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); b.Property("Moniker") + .HasColumnType("nvarchar(256)") .HasMaxLength(256); - b.Property("PackageKey"); + b.Property("PackageKey") + .HasColumnType("int"); b.HasKey("Key"); @@ -187,7 +229,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasOne("BaGet.Core.Package", "Package") .WithMany("PackageTypes") .HasForeignKey("PackageKey") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); modelBuilder.Entity("BaGet.Core.TargetFramework", b => @@ -195,7 +238,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasOne("BaGet.Core.Package", "Package") .WithMany("TargetFrameworks") .HasForeignKey("PackageKey") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); #pragma warning restore 612, 618 } diff --git a/src/BaGet.Database.SqlServer/Migrations/20191113054208_AddHasIconColumn.cs b/src/BaGet.Database.SqlServer/Migrations/20200210004408_AddHasEmbeddedIconColumn.cs similarity index 78% rename from src/BaGet.Database.SqlServer/Migrations/20191113054208_AddHasIconColumn.cs rename to src/BaGet.Database.SqlServer/Migrations/20200210004408_AddHasEmbeddedIconColumn.cs index c2866dc18..1cff5d145 100644 --- a/src/BaGet.Database.SqlServer/Migrations/20191113054208_AddHasIconColumn.cs +++ b/src/BaGet.Database.SqlServer/Migrations/20200210004408_AddHasEmbeddedIconColumn.cs @@ -2,12 +2,12 @@ namespace BaGet.Database.SqlServer.Migrations { - public partial class AddHasIconColumn : Migration + public partial class AddHasEmbeddedIconColumn : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( - name: "HasIcon", + name: "HasEmbeddedIcon", table: "Packages", nullable: false, defaultValue: false); @@ -16,7 +16,7 @@ protected override void Up(MigrationBuilder migrationBuilder) protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropColumn( - name: "HasIcon", + name: "HasEmbeddedIcon", table: "Packages"); } } diff --git a/src/BaGet.Database.SqlServer/Migrations/SqlServerContextModelSnapshot.cs b/src/BaGet.Database.SqlServer/Migrations/SqlServerContextModelSnapshot.cs index f0359889f..229a30020 100644 --- a/src/BaGet.Database.SqlServer/Migrations/SqlServerContextModelSnapshot.cs +++ b/src/BaGet.Database.SqlServer/Migrations/SqlServerContextModelSnapshot.cs @@ -15,7 +15,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") + .HasAnnotation("ProductVersion", "3.1.1") .HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); @@ -23,79 +23,105 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.Property("Key") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); b.Property("Authors") + .HasColumnType("nvarchar(4000)") .HasMaxLength(4000); b.Property("Description") + .HasColumnType("nvarchar(4000)") .HasMaxLength(4000); - b.Property("Downloads"); + b.Property("Downloads") + .HasColumnType("bigint"); - b.Property("HasIcon"); + b.Property("HasEmbeddedIcon") + .HasColumnType("bit"); - b.Property("HasReadme"); + b.Property("HasReadme") + .HasColumnType("bit"); b.Property("IconUrl") + .HasColumnType("nvarchar(4000)") .HasMaxLength(4000); b.Property("Id") .IsRequired() + .HasColumnType("nvarchar(128)") .HasMaxLength(128); - b.Property("IsPrerelease"); + b.Property("IsPrerelease") + .HasColumnType("bit"); b.Property("Language") + .HasColumnType("nvarchar(20)") .HasMaxLength(20); b.Property("LicenseUrl") + .HasColumnType("nvarchar(4000)") .HasMaxLength(4000); - b.Property("Listed"); + b.Property("Listed") + .HasColumnType("bit"); b.Property("MinClientVersion") + .HasColumnType("nvarchar(44)") .HasMaxLength(44); b.Property("NormalizedVersionString") .IsRequired() .HasColumnName("Version") + .HasColumnType("nvarchar(64)") .HasMaxLength(64); b.Property("OriginalVersionString") .HasColumnName("OriginalVersion") + .HasColumnType("nvarchar(64)") .HasMaxLength(64); b.Property("ProjectUrl") + .HasColumnType("nvarchar(4000)") .HasMaxLength(4000); - b.Property("Published"); + b.Property("Published") + .HasColumnType("datetime2"); b.Property("ReleaseNotes") .HasColumnName("ReleaseNotes") + .HasColumnType("nvarchar(4000)") .HasMaxLength(4000); b.Property("RepositoryType") + .HasColumnType("nvarchar(100)") .HasMaxLength(100); b.Property("RepositoryUrl") + .HasColumnType("nvarchar(4000)") .HasMaxLength(4000); - b.Property("RequireLicenseAcceptance"); + b.Property("RequireLicenseAcceptance") + .HasColumnType("bit"); b.Property("RowVersion") .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate(); + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); - b.Property("SemVerLevel"); + b.Property("SemVerLevel") + .HasColumnType("int"); b.Property("Summary") + .HasColumnType("nvarchar(4000)") .HasMaxLength(4000); b.Property("Tags") + .HasColumnType("nvarchar(4000)") .HasMaxLength(4000); b.Property("Title") + .HasColumnType("nvarchar(256)") .HasMaxLength(256); b.HasKey("Key"); @@ -112,17 +138,22 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.Property("Key") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); b.Property("Id") + .HasColumnType("nvarchar(128)") .HasMaxLength(128); - b.Property("PackageKey"); + b.Property("PackageKey") + .HasColumnType("int"); b.Property("TargetFramework") + .HasColumnType("nvarchar(256)") .HasMaxLength(256); b.Property("VersionRange") + .HasColumnType("nvarchar(256)") .HasMaxLength(256); b.HasKey("Key"); @@ -138,14 +169,18 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.Property("Key") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); b.Property("Name") + .HasColumnType("nvarchar(512)") .HasMaxLength(512); - b.Property("PackageKey"); + b.Property("PackageKey") + .HasColumnType("int"); b.Property("Version") + .HasColumnType("nvarchar(64)") .HasMaxLength(64); b.HasKey("Key"); @@ -161,12 +196,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.Property("Key") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); b.Property("Moniker") + .HasColumnType("nvarchar(256)") .HasMaxLength(256); - b.Property("PackageKey"); + b.Property("PackageKey") + .HasColumnType("int"); b.HasKey("Key"); @@ -189,7 +227,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasOne("BaGet.Core.Package", "Package") .WithMany("PackageTypes") .HasForeignKey("PackageKey") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); modelBuilder.Entity("BaGet.Core.TargetFramework", b => @@ -197,7 +236,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasOne("BaGet.Core.Package", "Package") .WithMany("TargetFrameworks") .HasForeignKey("PackageKey") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); #pragma warning restore 612, 618 } diff --git a/src/BaGet.Database.Sqlite/Migrations/20191113053824_AddHasIconColumn.Designer.cs b/src/BaGet.Database.Sqlite/Migrations/20200210004344_AddHasEmbeddedIconColumn.Designer.cs similarity index 64% rename from src/BaGet.Database.Sqlite/Migrations/20191113053824_AddHasIconColumn.Designer.cs rename to src/BaGet.Database.Sqlite/Migrations/20200210004344_AddHasEmbeddedIconColumn.Designer.cs index c65618c4b..4dde2f2ea 100644 --- a/src/BaGet.Database.Sqlite/Migrations/20191113053824_AddHasIconColumn.Designer.cs +++ b/src/BaGet.Database.Sqlite/Migrations/20200210004344_AddHasEmbeddedIconColumn.Designer.cs @@ -9,33 +9,40 @@ namespace BaGet.Database.Sqlite.Migrations { [DbContext(typeof(SqliteContext))] - [Migration("20191113053824_AddHasIconColumn")] - partial class AddHasIconColumn + [Migration("20200210004344_AddHasEmbeddedIconColumn")] + partial class AddHasEmbeddedIconColumn { protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.2.4-servicing-10062"); + .HasAnnotation("ProductVersion", "3.1.1"); modelBuilder.Entity("BaGet.Core.Package", b => { b.Property("Key") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); b.Property("Authors") + .HasColumnType("TEXT") .HasMaxLength(4000); b.Property("Description") + .HasColumnType("TEXT") .HasMaxLength(4000); - b.Property("Downloads"); + b.Property("Downloads") + .HasColumnType("INTEGER"); - b.Property("HasIcon"); + b.Property("HasEmbeddedIcon") + .HasColumnType("INTEGER"); - b.Property("HasReadme"); + b.Property("HasReadme") + .HasColumnType("INTEGER"); b.Property("IconUrl") + .HasColumnType("TEXT") .HasMaxLength(4000); b.Property("Id") @@ -43,54 +50,76 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("TEXT COLLATE NOCASE") .HasMaxLength(128); - b.Property("IsPrerelease"); + b.Property("IsPrerelease") + .HasColumnType("INTEGER"); b.Property("Language") + .HasColumnType("TEXT") .HasMaxLength(20); b.Property("LicenseUrl") + .HasColumnType("TEXT") .HasMaxLength(4000); - b.Property("Listed"); + b.Property("Listed") + .HasColumnType("INTEGER"); b.Property("MinClientVersion") + .HasColumnType("TEXT") .HasMaxLength(44); b.Property("NormalizedVersionString") .IsRequired() .HasColumnName("Version") + .HasColumnType("TEXT COLLATE NOCASE") .HasMaxLength(64); b.Property("OriginalVersionString") .HasColumnName("OriginalVersion") + .HasColumnType("TEXT") .HasMaxLength(64); b.Property("ProjectUrl") + .HasColumnType("TEXT") .HasMaxLength(4000); - b.Property("Published"); + b.Property("Published") + .HasColumnType("TEXT"); + + b.Property("ReleaseNotes") + .HasColumnName("ReleaseNotes") + .HasColumnType("TEXT") + .HasMaxLength(4000); b.Property("RepositoryType") + .HasColumnType("TEXT") .HasMaxLength(100); b.Property("RepositoryUrl") + .HasColumnType("TEXT") .HasMaxLength(4000); - b.Property("RequireLicenseAcceptance"); + b.Property("RequireLicenseAcceptance") + .HasColumnType("INTEGER"); b.Property("RowVersion") .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate(); + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("BLOB"); - b.Property("SemVerLevel"); + b.Property("SemVerLevel") + .HasColumnType("INTEGER"); b.Property("Summary") + .HasColumnType("TEXT") .HasMaxLength(4000); b.Property("Tags") + .HasColumnType("TEXT") .HasMaxLength(4000); b.Property("Title") + .HasColumnType("TEXT") .HasMaxLength(256); b.HasKey("Key"); @@ -106,18 +135,22 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("BaGet.Core.PackageDependency", b => { b.Property("Key") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); b.Property("Id") .HasColumnType("TEXT COLLATE NOCASE") .HasMaxLength(128); - b.Property("PackageKey"); + b.Property("PackageKey") + .HasColumnType("INTEGER"); b.Property("TargetFramework") + .HasColumnType("TEXT") .HasMaxLength(256); b.Property("VersionRange") + .HasColumnType("TEXT") .HasMaxLength(256); b.HasKey("Key"); @@ -132,15 +165,18 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("BaGet.Core.PackageType", b => { b.Property("Key") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); b.Property("Name") .HasColumnType("TEXT COLLATE NOCASE") .HasMaxLength(512); - b.Property("PackageKey"); + b.Property("PackageKey") + .HasColumnType("INTEGER"); b.Property("Version") + .HasColumnType("TEXT") .HasMaxLength(64); b.HasKey("Key"); @@ -155,13 +191,15 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("BaGet.Core.TargetFramework", b => { b.Property("Key") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); b.Property("Moniker") .HasColumnType("TEXT COLLATE NOCASE") .HasMaxLength(256); - b.Property("PackageKey"); + b.Property("PackageKey") + .HasColumnType("INTEGER"); b.HasKey("Key"); @@ -184,7 +222,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasOne("BaGet.Core.Package", "Package") .WithMany("PackageTypes") .HasForeignKey("PackageKey") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); modelBuilder.Entity("BaGet.Core.TargetFramework", b => @@ -192,7 +231,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasOne("BaGet.Core.Package", "Package") .WithMany("TargetFrameworks") .HasForeignKey("PackageKey") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); #pragma warning restore 612, 618 } diff --git a/src/BaGet.Database.Sqlite/Migrations/20191113053824_AddHasIconColumn.cs b/src/BaGet.Database.Sqlite/Migrations/20200210004344_AddHasEmbeddedIconColumn.cs similarity index 78% rename from src/BaGet.Database.Sqlite/Migrations/20191113053824_AddHasIconColumn.cs rename to src/BaGet.Database.Sqlite/Migrations/20200210004344_AddHasEmbeddedIconColumn.cs index 41038f8bb..df4897b4e 100644 --- a/src/BaGet.Database.Sqlite/Migrations/20191113053824_AddHasIconColumn.cs +++ b/src/BaGet.Database.Sqlite/Migrations/20200210004344_AddHasEmbeddedIconColumn.cs @@ -2,12 +2,12 @@ namespace BaGet.Database.Sqlite.Migrations { - public partial class AddHasIconColumn : Migration + public partial class AddHasEmbeddedIconColumn : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( - name: "HasIcon", + name: "HasEmbeddedIcon", table: "Packages", nullable: false, defaultValue: false); @@ -16,7 +16,7 @@ protected override void Up(MigrationBuilder migrationBuilder) protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropColumn( - name: "HasIcon", + name: "HasEmbeddedIcon", table: "Packages"); } } diff --git a/src/BaGet.Database.Sqlite/Migrations/SqliteContextModelSnapshot.cs b/src/BaGet.Database.Sqlite/Migrations/SqliteContextModelSnapshot.cs index 2ceb5e4c2..1d99d5cd6 100644 --- a/src/BaGet.Database.Sqlite/Migrations/SqliteContextModelSnapshot.cs +++ b/src/BaGet.Database.Sqlite/Migrations/SqliteContextModelSnapshot.cs @@ -33,7 +33,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Downloads") .HasColumnType("INTEGER"); - b.Property("HasIcon") + b.Property("HasEmbeddedIcon") .HasColumnType("INTEGER"); b.Property("HasReadme") From 094a90abb1c6c9b86c852a4daac8bb8e0e673c45 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Sun, 9 Feb 2020 17:11:57 -0800 Subject: [PATCH 14/22] Remove empty line --- src/BaGet.Core.Server/Controllers/PackageContentController.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/BaGet.Core.Server/Controllers/PackageContentController.cs b/src/BaGet.Core.Server/Controllers/PackageContentController.cs index 0b78b29a8..acc82e85c 100644 --- a/src/BaGet.Core.Server/Controllers/PackageContentController.cs +++ b/src/BaGet.Core.Server/Controllers/PackageContentController.cs @@ -1,4 +1,3 @@ - using System; using System.Threading; using System.Threading.Tasks; From ea1bfb92af97f9640b224ec205645691a62bb202 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Sun, 9 Feb 2020 17:15:31 -0800 Subject: [PATCH 15/22] Updates --- src/BaGet.Core/Metadata/RegistrationBuilder.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/BaGet.Core/Metadata/RegistrationBuilder.cs b/src/BaGet.Core/Metadata/RegistrationBuilder.cs index d4564c42a..04a8ffc0b 100644 --- a/src/BaGet.Core/Metadata/RegistrationBuilder.cs +++ b/src/BaGet.Core/Metadata/RegistrationBuilder.cs @@ -71,7 +71,9 @@ private RegistrationIndexPageItem ToRegistrationIndexPageItem(Package package) = Description = package.Description, Downloads = package.Downloads, HasReadme = package.HasReadme, - IconUrl = !string.IsNullOrEmpty(package.IconUrlString) ? package.IconUrlString : _url.GetPackageIconDownloadUrl(package.Id, package.Version), + IconUrl = package.HasEmbeddedIcon + ? _url.GetPackageIconDownloadUrl(package.Id, package.Version) + : package.IconUrlString, Language = package.Language, LicenseUrl = package.LicenseUrlString, Listed = package.Listed, From d4bda9e6b0d49919d0a183c115e21a548ca4ee37 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Sun, 9 Feb 2020 17:18:13 -0800 Subject: [PATCH 16/22] Clean --- tests/BaGet.Core.Tests/Services/PackageStorageServiceTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/BaGet.Core.Tests/Services/PackageStorageServiceTests.cs b/tests/BaGet.Core.Tests/Services/PackageStorageServiceTests.cs index 49805ff82..551219010 100644 --- a/tests/BaGet.Core.Tests/Services/PackageStorageServiceTests.cs +++ b/tests/BaGet.Core.Tests/Services/PackageStorageServiceTests.cs @@ -351,7 +351,6 @@ public FactsBase() protected string PackagePath => Path.Combine("packages", "my.package", "1.2.3", "my.package.1.2.3.nupkg"); protected string NuspecPath => Path.Combine("packages", "my.package", "1.2.3", "my.package.nuspec"); protected string ReadmePath => Path.Combine("packages", "my.package", "1.2.3", "readme"); - protected string IconPath => Path.Combine("packages", "my.package", "1.2.3", "icon"); protected Stream StringStream(string input) From 0c887c54f724c5dae071a2dd6c9592862808a788 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Sun, 9 Feb 2020 18:28:43 -0800 Subject: [PATCH 17/22] Clean --- src/BaGet.Core/Indexing/PackageIndexingService.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/BaGet.Core/Indexing/PackageIndexingService.cs b/src/BaGet.Core/Indexing/PackageIndexingService.cs index f8cac6fb6..17e8e97cc 100644 --- a/src/BaGet.Core/Indexing/PackageIndexingService.cs +++ b/src/BaGet.Core/Indexing/PackageIndexingService.cs @@ -13,7 +13,6 @@ public class PackageIndexingService : IPackageIndexingService private readonly IPackageService _packages; private readonly IPackageStorageService _storage; private readonly ISearchIndexer _search; - private readonly IUrlGenerator _url; private readonly IOptionsSnapshot _options; private readonly ILogger _logger; From 1e366076c695a8edde45e4714c73b300b65862c8 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Sun, 9 Feb 2020 18:45:29 -0800 Subject: [PATCH 18/22] Use generic image content type --- src/BaGet.Core.Server/Controllers/PackageContentController.cs | 2 +- src/BaGet.Core/Storage/FileStorageService.cs | 2 +- src/BaGet.Core/Storage/PackageStorageService.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/BaGet.Core.Server/Controllers/PackageContentController.cs b/src/BaGet.Core.Server/Controllers/PackageContentController.cs index acc82e85c..5ce4f5c34 100644 --- a/src/BaGet.Core.Server/Controllers/PackageContentController.cs +++ b/src/BaGet.Core.Server/Controllers/PackageContentController.cs @@ -93,7 +93,7 @@ public async Task DownloadIconAsync(string id, string version, Ca return NotFound(); } - return File(iconStream, contentType: ""); + return File(iconStream, "image/xyz"); } } } diff --git a/src/BaGet.Core/Storage/FileStorageService.cs b/src/BaGet.Core/Storage/FileStorageService.cs index 26d6f6ec0..07fdc6afb 100644 --- a/src/BaGet.Core/Storage/FileStorageService.cs +++ b/src/BaGet.Core/Storage/FileStorageService.cs @@ -52,7 +52,7 @@ public async Task PutAsync( CancellationToken cancellationToken = default) { if (content == null) throw new ArgumentNullException(nameof(content)); - if (string.IsNullOrEmpty(contentType)) throw new ArgumentException("Content type is required", nameof(contentType)); + if (contentType == null) throw new ArgumentNullException("Content type is required", nameof(contentType)); cancellationToken.ThrowIfCancellationRequested(); diff --git a/src/BaGet.Core/Storage/PackageStorageService.cs b/src/BaGet.Core/Storage/PackageStorageService.cs index f096384bd..55731b004 100644 --- a/src/BaGet.Core/Storage/PackageStorageService.cs +++ b/src/BaGet.Core/Storage/PackageStorageService.cs @@ -15,7 +15,7 @@ public class PackageStorageService : IPackageStorageService private const string PackageContentType = "binary/octet-stream"; private const string NuspecContentType = "text/plain"; private const string ReadmeContentType = "text/markdown"; - private const string IconContentType = ""; + private const string IconContentType = "image/xyz"; private readonly IStorageService _storage; private readonly ILogger _logger; From 3b0cd548e308b25305433db7c77a72cd2ce1a8ac Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Sun, 9 Feb 2020 18:57:54 -0800 Subject: [PATCH 19/22] Fix null reference exception --- src/BaGet.Azure/Table/TableSearchService.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/BaGet.Azure/Table/TableSearchService.cs b/src/BaGet.Azure/Table/TableSearchService.cs index 8872ff527..d1f99cf40 100644 --- a/src/BaGet.Azure/Table/TableSearchService.cs +++ b/src/BaGet.Azure/Table/TableSearchService.cs @@ -234,6 +234,7 @@ private SearchResult ToSearchResult(IReadOnlyList packages) if (latestVersion == null || version > latestVersion) { latest = package; + latestVersion = version; } } From a09d7af0755a1c8426e58c0d90f557d32c44fc25 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Sun, 9 Feb 2020 19:00:22 -0800 Subject: [PATCH 20/22] Undo --- src/BaGet.Core/Storage/FileStorageService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BaGet.Core/Storage/FileStorageService.cs b/src/BaGet.Core/Storage/FileStorageService.cs index 07fdc6afb..fb7ed07d2 100644 --- a/src/BaGet.Core/Storage/FileStorageService.cs +++ b/src/BaGet.Core/Storage/FileStorageService.cs @@ -52,7 +52,7 @@ public async Task PutAsync( CancellationToken cancellationToken = default) { if (content == null) throw new ArgumentNullException(nameof(content)); - if (contentType == null) throw new ArgumentNullException("Content type is required", nameof(contentType)); + if (contentType == null) throw new ArgumentException("Content type is required", nameof(contentType)); cancellationToken.ThrowIfCancellationRequested(); From 1e477a4ebcc3e43e83ffd05cbf35a14cd601d2f2 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Sun, 9 Feb 2020 19:00:53 -0800 Subject: [PATCH 21/22] Undo --- src/BaGet.Core/Storage/FileStorageService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BaGet.Core/Storage/FileStorageService.cs b/src/BaGet.Core/Storage/FileStorageService.cs index fb7ed07d2..26d6f6ec0 100644 --- a/src/BaGet.Core/Storage/FileStorageService.cs +++ b/src/BaGet.Core/Storage/FileStorageService.cs @@ -52,7 +52,7 @@ public async Task PutAsync( CancellationToken cancellationToken = default) { if (content == null) throw new ArgumentNullException(nameof(content)); - if (contentType == null) throw new ArgumentException("Content type is required", nameof(contentType)); + if (string.IsNullOrEmpty(contentType)) throw new ArgumentException("Content type is required", nameof(contentType)); cancellationToken.ThrowIfCancellationRequested(); From c1bca08f7eaca2e4e21687c2f5eca19ed40c1b96 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Sun, 9 Feb 2020 19:10:19 -0800 Subject: [PATCH 22/22] Fix tests --- tests/BaGet.Core.Tests/Services/PackageStorageServiceTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/BaGet.Core.Tests/Services/PackageStorageServiceTests.cs b/tests/BaGet.Core.Tests/Services/PackageStorageServiceTests.cs index 551219010..da246691e 100644 --- a/tests/BaGet.Core.Tests/Services/PackageStorageServiceTests.cs +++ b/tests/BaGet.Core.Tests/Services/PackageStorageServiceTests.cs @@ -85,7 +85,7 @@ await _target.SavePackageContentAsync( Assert.True(_puts.ContainsKey(IconPath)); Assert.Equal("My icon", await ToStringAsync(_puts[IconPath].Content)); - Assert.Equal("", _puts[IconPath].ContentType); + Assert.Equal("image/xyz", _puts[IconPath].ContentType); } }