aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Barron <barronpm@gmail.com>2020-05-15 14:08:46 -0400
committerPatrick Barron <barronpm@gmail.com>2020-05-15 14:09:15 -0400
commita7c2e524a9571f4b6747908db94d0241d73ae5f3 (patch)
tree5f4db59e3db7e87bb497f41f7bb3c4d663452d04
parenta5dee3680880d525a6c507deb7dd284b08b7ebdd (diff)
Apply more review suggestions
-rw-r--r--Jellyfin.Server/Migrations/Routines/MigrateActivityLogDb.cs20
1 files changed, 14 insertions, 6 deletions
diff --git a/Jellyfin.Server/Migrations/Routines/MigrateActivityLogDb.cs b/Jellyfin.Server/Migrations/Routines/MigrateActivityLogDb.cs
index 6f4fc4f28..079b5b5dc 100644
--- a/Jellyfin.Server/Migrations/Routines/MigrateActivityLogDb.cs
+++ b/Jellyfin.Server/Migrations/Routines/MigrateActivityLogDb.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
+using System.Linq;
using Emby.Server.Implementations.Data;
using Jellyfin.Data.Entities;
using Jellyfin.Server.Implementations;
@@ -75,7 +76,7 @@ namespace Jellyfin.Server.Migrations.Routines
dbContext.Database.ExecuteSqlRaw("UPDATE sqlite_sequence SET seq = 0 WHERE name = 'ActivityLog';");
dbContext.SaveChanges();
- foreach (var entry in queryResult)
+ var newEntries = queryResult.Select(entry =>
{
if (!logLevelDictionary.TryGetValue(entry[8].ToString(), out var severity))
{
@@ -93,28 +94,35 @@ namespace Jellyfin.Server.Migrations.Routines
if (entry[2].SQLiteType != SQLiteType.Null)
{
- newEntry.Overview = entry[2].ToString();
+ newEntry.Overview = entry[2].ToString();
}
if (entry[3].SQLiteType != SQLiteType.Null)
{
- newEntry.ShortOverview = entry[3].ToString();
+ newEntry.ShortOverview = entry[3].ToString();
}
if (entry[5].SQLiteType != SQLiteType.Null)
{
- newEntry.ItemId = entry[5].ToString();
+ newEntry.ItemId = entry[5].ToString();
}
- dbContext.ActivityLogs.Add(newEntry);
- }
+ return newEntry;
+ });
+ dbContext.ActivityLogs.AddRange(newEntries);
dbContext.SaveChanges();
}
try
{
File.Move(Path.Combine(dataPath, DbFilename), Path.Combine(dataPath, DbFilename + ".old"));
+
+ var journalPath = Path.Combine(dataPath, DbFilename + "-journal");
+ if (File.Exists(journalPath))
+ {
+ File.Move(journalPath, Path.Combine(dataPath, DbFilename + ".old-journal"));
+ }
}
catch (IOException e)
{