update clean db task
This commit is contained in:
parent
bb26e05e1e
commit
998f7c0fb8
|
@ -65,6 +65,44 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
innerProgress.RegisterAction(p =>
|
||||
{
|
||||
double newPercentCommplete = .4 * p;
|
||||
OnProgress(newPercentCommplete);
|
||||
|
||||
progress.Report(newPercentCommplete);
|
||||
});
|
||||
|
||||
await UpdateToLatestSchema(cancellationToken, innerProgress).ConfigureAwait(false);
|
||||
|
||||
innerProgress = new ActionableProgress<double>();
|
||||
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<double>();
|
||||
innerProgress.RegisterAction(p =>
|
||||
{
|
||||
double newPercentCommplete = 45 + (.55 * p);
|
||||
OnProgress(newPercentCommplete);
|
||||
progress.Report(newPercentCommplete);
|
||||
});
|
||||
await CleanDeletedItems(cancellationToken, innerProgress).ConfigureAwait(false);
|
||||
progress.Report(100);
|
||||
|
||||
await _itemRepo.UpdateInheritedValues(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (EnableUnavailableMessage)
|
||||
{
|
||||
EnableUnavailableMessage = false;
|
||||
_httpServer.GlobalResponse = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnProgress(double newPercentCommplete)
|
||||
{
|
||||
if (EnableUnavailableMessage)
|
||||
{
|
||||
var html = "<!doctype html><html><head><title>Emby</title></head><body>";
|
||||
|
@ -76,29 +114,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
|
||||
_httpServer.GlobalResponse = html;
|
||||
}
|
||||
|
||||
progress.Report(newPercentCommplete);
|
||||
});
|
||||
|
||||
await UpdateToLatestSchema(cancellationToken, innerProgress).ConfigureAwait(false);
|
||||
|
||||
innerProgress = new ActionableProgress<double>();
|
||||
innerProgress.RegisterAction(p => progress.Report(40 + (.05 * p)));
|
||||
await CleanDeadItems(cancellationToken, innerProgress).ConfigureAwait(false);
|
||||
progress.Report(45);
|
||||
|
||||
innerProgress = new ActionableProgress<double>();
|
||||
innerProgress.RegisterAction(p => progress.Report(45 + (.55 * p)));
|
||||
await CleanDeletedItems(cancellationToken, innerProgress).ConfigureAwait(false);
|
||||
progress.Report(100);
|
||||
|
||||
await _itemRepo.UpdateInheritedValues(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (EnableUnavailableMessage)
|
||||
{
|
||||
EnableUnavailableMessage = false;
|
||||
_httpServer.GlobalResponse = null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task UpdateToLatestSchema(CancellationToken cancellationToken, IProgress<double> progress)
|
||||
|
@ -117,12 +132,9 @@ 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);
|
||||
|
||||
if (item != null)
|
||||
|
@ -140,6 +152,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
_logger.ErrorException("Error saving item", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
numComplete++;
|
||||
double percent = numComplete;
|
||||
|
|
Loading…
Reference in New Issue
Block a user