diff --git a/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs b/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs
index f4eb4ef8a..1bbe42426 100644
--- a/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs
+++ b/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs
@@ -65,17 +65,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
innerProgress.RegisterAction(p =>
{
double newPercentCommplete = .4 * p;
- if (EnableUnavailableMessage)
- {
- var html = "
Emby";
- var text = _localization.GetLocalizedString("DbUpgradeMessage");
- html += string.Format(text, newPercentCommplete.ToString("N2", CultureInfo.InvariantCulture));
-
- html += "";
- html += "";
-
- _httpServer.GlobalResponse = html;
- }
+ OnProgress(newPercentCommplete);
progress.Report(newPercentCommplete);
});
@@ -83,12 +73,22 @@ namespace MediaBrowser.Server.Implementations.Persistence
await UpdateToLatestSchema(cancellationToken, innerProgress).ConfigureAwait(false);
innerProgress = new ActionableProgress();
- innerProgress.RegisterAction(p => progress.Report(40 + (.05 * p)));
+ innerProgress.RegisterAction(p =>
+ {
+ double newPercentCommplete = 40 + (.05 * p);
+ OnProgress(newPercentCommplete);
+ progress.Report(newPercentCommplete);
+ });
await CleanDeadItems(cancellationToken, innerProgress).ConfigureAwait(false);
progress.Report(45);
innerProgress = new ActionableProgress();
- innerProgress.RegisterAction(p => progress.Report(45 + (.55 * p)));
+ innerProgress.RegisterAction(p =>
+ {
+ double newPercentCommplete = 45 + (.55 * p);
+ OnProgress(newPercentCommplete);
+ progress.Report(newPercentCommplete);
+ });
await CleanDeletedItems(cancellationToken, innerProgress).ConfigureAwait(false);
progress.Report(100);
@@ -101,6 +101,21 @@ namespace MediaBrowser.Server.Implementations.Persistence
}
}
+ private void OnProgress(double newPercentCommplete)
+ {
+ if (EnableUnavailableMessage)
+ {
+ var html = "Emby";
+ var text = _localization.GetLocalizedString("DbUpgradeMessage");
+ html += string.Format(text, newPercentCommplete.ToString("N2", CultureInfo.InvariantCulture));
+
+ html += "";
+ html += "";
+
+ _httpServer.GlobalResponse = html;
+ }
+ }
+
private async Task UpdateToLatestSchema(CancellationToken cancellationToken, IProgress progress)
{
var itemIds = _libraryManager.GetItemIds(new InternalItemsQuery
@@ -117,27 +132,25 @@ namespace MediaBrowser.Server.Implementations.Persistence
{
cancellationToken.ThrowIfCancellationRequested();
- if (itemId == Guid.Empty)
+ if (itemId != Guid.Empty)
{
// Somehow some invalid data got into the db. It probably predates the boundary checking
- continue;
- }
+ var item = _libraryManager.GetItemById(itemId);
- var item = _libraryManager.GetItemById(itemId);
-
- if (item != null)
- {
- try
+ if (item != null)
{
- await _itemRepo.SaveItem(item, cancellationToken).ConfigureAwait(false);
- }
- catch (OperationCanceledException)
- {
- throw;
- }
- catch (Exception ex)
- {
- _logger.ErrorException("Error saving item", ex);
+ try
+ {
+ await _itemRepo.SaveItem(item, cancellationToken).ConfigureAwait(false);
+ }
+ catch (OperationCanceledException)
+ {
+ throw;
+ }
+ catch (Exception ex)
+ {
+ _logger.ErrorException("Error saving item", ex);
+ }
}
}