aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server.Implementations
diff options
context:
space:
mode:
authorPatrick Barron <barronpm@gmail.com>2020-06-13 16:38:17 -0400
committerPatrick Barron <barronpm@gmail.com>2020-06-13 16:38:17 -0400
commit32780154440d5e7d26d3cb4b32a43d1d8d2735f3 (patch)
tree8952ddb19a0fdfd94dc35dbcd3768e14506e1c77 /Jellyfin.Server.Implementations
parent1e1386bbc67d0f1c8904ed5c86ea482d3e39b620 (diff)
Actually fix profile images
Diffstat (limited to 'Jellyfin.Server.Implementations')
-rw-r--r--Jellyfin.Server.Implementations/Migrations/20200613202153_AddUsers.Designer.cs (renamed from Jellyfin.Server.Implementations/Migrations/20200613155524_AddUsers.Designer.cs)28
-rw-r--r--Jellyfin.Server.Implementations/Migrations/20200613202153_AddUsers.cs (renamed from Jellyfin.Server.Implementations/Migrations/20200613155524_AddUsers.cs)67
-rw-r--r--Jellyfin.Server.Implementations/Migrations/JellyfinDbModelSnapshot.cs25
-rw-r--r--Jellyfin.Server.Implementations/Users/UserManager.cs2
4 files changed, 62 insertions, 60 deletions
diff --git a/Jellyfin.Server.Implementations/Migrations/20200613155524_AddUsers.Designer.cs b/Jellyfin.Server.Implementations/Migrations/20200613202153_AddUsers.Designer.cs
index c43b035d9..6342ce9cf 100644
--- a/Jellyfin.Server.Implementations/Migrations/20200613155524_AddUsers.Designer.cs
+++ b/Jellyfin.Server.Implementations/Migrations/20200613202153_AddUsers.Designer.cs
@@ -1,5 +1,4 @@
#pragma warning disable CS1591
-#pragma warning disable SA1601
// <auto-generated />
using System;
@@ -12,7 +11,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Jellyfin.Server.Implementations.Migrations
{
[DbContext(typeof(JellyfinDb))]
- [Migration("20200613155524_AddUsers")]
+ [Migration("20200613202153_AddUsers")]
partial class AddUsers
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -107,8 +106,14 @@ namespace Jellyfin.Server.Implementations.Migrations
.HasColumnType("TEXT")
.HasMaxLength(512);
+ b.Property<Guid?>("UserId")
+ .HasColumnType("TEXT");
+
b.HasKey("Id");
+ b.HasIndex("UserId")
+ .IsUnique();
+
b.ToTable("ImageInfos");
});
@@ -239,9 +244,6 @@ namespace Jellyfin.Server.Implementations.Migrations
b.Property<bool>("PlayDefaultAudioTrack")
.HasColumnType("INTEGER");
- b.Property<int?>("ProfileImageId")
- .HasColumnType("INTEGER");
-
b.Property<bool>("RememberAudioSelections")
.HasColumnType("INTEGER");
@@ -272,8 +274,6 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasKey("Id");
- b.HasIndex("ProfileImageId");
-
b.ToTable("Users");
});
@@ -286,6 +286,13 @@ namespace Jellyfin.Server.Implementations.Migrations
.IsRequired();
});
+ modelBuilder.Entity("Jellyfin.Data.Entities.ImageInfo", b =>
+ {
+ b.HasOne("Jellyfin.Data.Entities.User", null)
+ .WithOne("ProfileImage")
+ .HasForeignKey("Jellyfin.Data.Entities.ImageInfo", "UserId");
+ });
+
modelBuilder.Entity("Jellyfin.Data.Entities.Permission", b =>
{
b.HasOne("Jellyfin.Data.Entities.User", null)
@@ -299,13 +306,6 @@ namespace Jellyfin.Server.Implementations.Migrations
.WithMany("Preferences")
.HasForeignKey("Preference_Preferences_Guid");
});
-
- modelBuilder.Entity("Jellyfin.Data.Entities.User", b =>
- {
- b.HasOne("Jellyfin.Data.Entities.ImageInfo", "ProfileImage")
- .WithMany()
- .HasForeignKey("ProfileImageId");
- });
#pragma warning restore 612, 618
}
}
diff --git a/Jellyfin.Server.Implementations/Migrations/20200613155524_AddUsers.cs b/Jellyfin.Server.Implementations/Migrations/20200613202153_AddUsers.cs
index 369458b6c..7e5a76850 100644
--- a/Jellyfin.Server.Implementations/Migrations/20200613155524_AddUsers.cs
+++ b/Jellyfin.Server.Implementations/Migrations/20200613202153_AddUsers.cs
@@ -11,21 +11,6 @@ namespace Jellyfin.Server.Implementations.Migrations
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
- name: "ImageInfos",
- schema: "jellyfin",
- columns: table => new
- {
- Id = table.Column<int>(nullable: false)
- .Annotation("Sqlite:Autoincrement", true),
- Path = table.Column<string>(maxLength: 512, nullable: false),
- LastModified = table.Column<DateTime>(nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_ImageInfos", x => x.Id);
- });
-
- migrationBuilder.CreateTable(
name: "Users",
schema: "jellyfin",
columns: table => new
@@ -57,20 +42,12 @@ namespace Jellyfin.Server.Implementations.Migrations
MaxParentalAgeRating = table.Column<int>(nullable: true),
RemoteClientBitrateLimit = table.Column<int>(nullable: true),
InternalId = table.Column<long>(nullable: false),
- ProfileImageId = table.Column<int>(nullable: true),
SyncPlayAccess = table.Column<int>(nullable: false),
RowVersion = table.Column<uint>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
- table.ForeignKey(
- name: "FK_Users_ImageInfos_ProfileImageId",
- column: x => x.ProfileImageId,
- principalSchema: "jellyfin",
- principalTable: "ImageInfos",
- principalColumn: "Id",
- onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
@@ -98,6 +75,29 @@ namespace Jellyfin.Server.Implementations.Migrations
});
migrationBuilder.CreateTable(
+ name: "ImageInfos",
+ schema: "jellyfin",
+ columns: table => new
+ {
+ Id = table.Column<int>(nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ UserId = table.Column<Guid>(nullable: true),
+ Path = table.Column<string>(maxLength: 512, nullable: false),
+ LastModified = table.Column<DateTime>(nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_ImageInfos", x => x.Id);
+ table.ForeignKey(
+ name: "FK_ImageInfos_Users_UserId",
+ column: x => x.UserId,
+ principalSchema: "jellyfin",
+ principalTable: "Users",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Restrict);
+ });
+
+ migrationBuilder.CreateTable(
name: "Permissions",
schema: "jellyfin",
columns: table => new
@@ -152,6 +152,13 @@ namespace Jellyfin.Server.Implementations.Migrations
column: "UserId");
migrationBuilder.CreateIndex(
+ name: "IX_ImageInfos_UserId",
+ schema: "jellyfin",
+ table: "ImageInfos",
+ column: "UserId",
+ unique: true);
+
+ migrationBuilder.CreateIndex(
name: "IX_Permissions_Permission_Permissions_Guid",
schema: "jellyfin",
table: "Permissions",
@@ -162,12 +169,6 @@ namespace Jellyfin.Server.Implementations.Migrations
schema: "jellyfin",
table: "Preferences",
column: "Preference_Preferences_Guid");
-
- migrationBuilder.CreateIndex(
- name: "IX_Users_ProfileImageId",
- schema: "jellyfin",
- table: "Users",
- column: "ProfileImageId");
}
protected override void Down(MigrationBuilder migrationBuilder)
@@ -177,19 +178,19 @@ namespace Jellyfin.Server.Implementations.Migrations
schema: "jellyfin");
migrationBuilder.DropTable(
- name: "Permissions",
+ name: "ImageInfos",
schema: "jellyfin");
migrationBuilder.DropTable(
- name: "Preferences",
+ name: "Permissions",
schema: "jellyfin");
migrationBuilder.DropTable(
- name: "Users",
+ name: "Preferences",
schema: "jellyfin");
migrationBuilder.DropTable(
- name: "ImageInfos",
+ name: "Users",
schema: "jellyfin");
}
}
diff --git a/Jellyfin.Server.Implementations/Migrations/JellyfinDbModelSnapshot.cs b/Jellyfin.Server.Implementations/Migrations/JellyfinDbModelSnapshot.cs
index 9548c38a3..51fad8224 100644
--- a/Jellyfin.Server.Implementations/Migrations/JellyfinDbModelSnapshot.cs
+++ b/Jellyfin.Server.Implementations/Migrations/JellyfinDbModelSnapshot.cs
@@ -102,8 +102,14 @@ namespace Jellyfin.Server.Implementations.Migrations
.HasColumnType("TEXT")
.HasMaxLength(512);
+ b.Property<Guid?>("UserId")
+ .HasColumnType("TEXT");
+
b.HasKey("Id");
+ b.HasIndex("UserId")
+ .IsUnique();
+
b.ToTable("ImageInfos");
});
@@ -234,9 +240,6 @@ namespace Jellyfin.Server.Implementations.Migrations
b.Property<bool>("PlayDefaultAudioTrack")
.HasColumnType("INTEGER");
- b.Property<int?>("ProfileImageId")
- .HasColumnType("INTEGER");
-
b.Property<bool>("RememberAudioSelections")
.HasColumnType("INTEGER");
@@ -267,8 +270,6 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasKey("Id");
- b.HasIndex("ProfileImageId");
-
b.ToTable("Users");
});
@@ -281,6 +282,13 @@ namespace Jellyfin.Server.Implementations.Migrations
.IsRequired();
});
+ modelBuilder.Entity("Jellyfin.Data.Entities.ImageInfo", b =>
+ {
+ b.HasOne("Jellyfin.Data.Entities.User", null)
+ .WithOne("ProfileImage")
+ .HasForeignKey("Jellyfin.Data.Entities.ImageInfo", "UserId");
+ });
+
modelBuilder.Entity("Jellyfin.Data.Entities.Permission", b =>
{
b.HasOne("Jellyfin.Data.Entities.User", null)
@@ -294,13 +302,6 @@ namespace Jellyfin.Server.Implementations.Migrations
.WithMany("Preferences")
.HasForeignKey("Preference_Preferences_Guid");
});
-
- modelBuilder.Entity("Jellyfin.Data.Entities.User", b =>
- {
- b.HasOne("Jellyfin.Data.Entities.ImageInfo", "ProfileImage")
- .WithMany()
- .HasForeignKey("ProfileImageId");
- });
#pragma warning restore 612, 618
}
}
diff --git a/Jellyfin.Server.Implementations/Users/UserManager.cs b/Jellyfin.Server.Implementations/Users/UserManager.cs
index bab6cf3fc..63b8e1d94 100644
--- a/Jellyfin.Server.Implementations/Users/UserManager.cs
+++ b/Jellyfin.Server.Implementations/Users/UserManager.cs
@@ -671,7 +671,7 @@ namespace Jellyfin.Server.Implementations.Users
public void ClearProfileImage(User user)
{
var dbContext = _dbProvider.CreateContext();
- dbContext.ImageInfos.Remove(user.ProfileImage);
+ dbContext.Remove(user.ProfileImage);
dbContext.SaveChanges();
}