mirror of https://github.com/ErsatzTV/ErsatzTV.git
Browse Source
* don't run pragma command on mysql * add not required pathhash * make media file path hash required * update changelogpull/2206/head
26 changed files with 18358 additions and 19 deletions
@ -0,0 +1,19 @@ |
|||||||
|
using System.Globalization; |
||||||
|
using System.Security.Cryptography; |
||||||
|
using System.Text; |
||||||
|
|
||||||
|
namespace ErsatzTV.Core; |
||||||
|
|
||||||
|
public static class PathUtils |
||||||
|
{ |
||||||
|
public static string GetPathHash(string path) |
||||||
|
{ |
||||||
|
byte[] bytes = SHA256.HashData(Encoding.UTF8.GetBytes(path)); |
||||||
|
var builder = new StringBuilder(); |
||||||
|
foreach (byte b in bytes) |
||||||
|
{ |
||||||
|
builder.Append(b.ToString("x2", CultureInfo.InvariantCulture)); |
||||||
|
} |
||||||
|
return builder.ToString(); |
||||||
|
} |
||||||
|
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,56 @@ |
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||||
|
|
||||||
|
#nullable disable |
||||||
|
|
||||||
|
namespace ErsatzTV.Infrastructure.MySql.Migrations |
||||||
|
{ |
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Update_MediaFilePathHash : Migration |
||||||
|
{ |
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||||
|
{ |
||||||
|
migrationBuilder.UpdateData( |
||||||
|
table: "MediaFile", |
||||||
|
keyColumn: "PathHash", |
||||||
|
keyValue: null, |
||||||
|
column: "PathHash", |
||||||
|
value: ""); |
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<string>( |
||||||
|
name: "PathHash", |
||||||
|
table: "MediaFile", |
||||||
|
type: "varchar(255)", |
||||||
|
nullable: false, |
||||||
|
oldClrType: typeof(string), |
||||||
|
oldType: "longtext", |
||||||
|
oldNullable: true) |
||||||
|
.Annotation("MySql:CharSet", "utf8mb4") |
||||||
|
.OldAnnotation("MySql:CharSet", "utf8mb4"); |
||||||
|
|
||||||
|
migrationBuilder.CreateIndex( |
||||||
|
name: "IX_MediaFile_PathHash", |
||||||
|
table: "MediaFile", |
||||||
|
column: "PathHash", |
||||||
|
unique: true); |
||||||
|
} |
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||||
|
{ |
||||||
|
migrationBuilder.DropIndex( |
||||||
|
name: "IX_MediaFile_PathHash", |
||||||
|
table: "MediaFile"); |
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<string>( |
||||||
|
name: "PathHash", |
||||||
|
table: "MediaFile", |
||||||
|
type: "longtext", |
||||||
|
nullable: true, |
||||||
|
oldClrType: typeof(string), |
||||||
|
oldType: "varchar(255)") |
||||||
|
.Annotation("MySql:CharSet", "utf8mb4") |
||||||
|
.OldAnnotation("MySql:CharSet", "utf8mb4"); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,38 @@ |
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||||
|
|
||||||
|
#nullable disable |
||||||
|
|
||||||
|
namespace ErsatzTV.Infrastructure.Sqlite.Migrations |
||||||
|
{ |
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Add_MediaFilePathHash : Migration |
||||||
|
{ |
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||||
|
{ |
||||||
|
migrationBuilder.DropIndex( |
||||||
|
name: "IX_MediaFile_Path", |
||||||
|
table: "MediaFile"); |
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>( |
||||||
|
name: "PathHash", |
||||||
|
table: "MediaFile", |
||||||
|
type: "TEXT", |
||||||
|
nullable: true); |
||||||
|
} |
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||||
|
{ |
||||||
|
migrationBuilder.DropColumn( |
||||||
|
name: "PathHash", |
||||||
|
table: "MediaFile"); |
||||||
|
|
||||||
|
migrationBuilder.CreateIndex( |
||||||
|
name: "IX_MediaFile_Path", |
||||||
|
table: "MediaFile", |
||||||
|
column: "Path", |
||||||
|
unique: true); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,46 @@ |
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||||
|
|
||||||
|
#nullable disable |
||||||
|
|
||||||
|
namespace ErsatzTV.Infrastructure.Sqlite.Migrations |
||||||
|
{ |
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Update_MediaFilePathHash : Migration |
||||||
|
{ |
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||||
|
{ |
||||||
|
migrationBuilder.AlterColumn<string>( |
||||||
|
name: "PathHash", |
||||||
|
table: "MediaFile", |
||||||
|
type: "TEXT", |
||||||
|
nullable: false, |
||||||
|
defaultValue: "", |
||||||
|
oldClrType: typeof(string), |
||||||
|
oldType: "TEXT", |
||||||
|
oldNullable: true); |
||||||
|
|
||||||
|
migrationBuilder.CreateIndex( |
||||||
|
name: "IX_MediaFile_PathHash", |
||||||
|
table: "MediaFile", |
||||||
|
column: "PathHash", |
||||||
|
unique: true); |
||||||
|
} |
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||||
|
{ |
||||||
|
migrationBuilder.DropIndex( |
||||||
|
name: "IX_MediaFile_PathHash", |
||||||
|
table: "MediaFile"); |
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<string>( |
||||||
|
name: "PathHash", |
||||||
|
table: "MediaFile", |
||||||
|
type: "TEXT", |
||||||
|
nullable: true, |
||||||
|
oldClrType: typeof(string), |
||||||
|
oldType: "TEXT"); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue