aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Data/CleanDatabaseScheduledTask.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2017-05-06 01:18:54 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2017-05-06 01:18:54 -0400
commit59f2463efd39e7e69f62dba7c20c4f8cfc96fe94 (patch)
treeb500e24a2e72539faaaff1fb706b20c8cf635012 /Emby.Server.Implementations/Data/CleanDatabaseScheduledTask.cs
parent91cb7e06e9934d43740f8899a30a771625a08be3 (diff)
update nuget
Diffstat (limited to 'Emby.Server.Implementations/Data/CleanDatabaseScheduledTask.cs')
-rw-r--r--Emby.Server.Implementations/Data/CleanDatabaseScheduledTask.cs112
1 files changed, 1 insertions, 111 deletions
diff --git a/Emby.Server.Implementations/Data/CleanDatabaseScheduledTask.cs b/Emby.Server.Implementations/Data/CleanDatabaseScheduledTask.cs
index 0096f2284..e25955782 100644
--- a/Emby.Server.Implementations/Data/CleanDatabaseScheduledTask.cs
+++ b/Emby.Server.Implementations/Data/CleanDatabaseScheduledTask.cs
@@ -71,10 +71,9 @@ namespace Emby.Server.Implementations.Data
double newPercentCommplete = 45 + .55 * p;
progress.Report(newPercentCommplete);
});
- await CleanDeletedItems(cancellationToken, innerProgress).ConfigureAwait(false);
- progress.Report(100);
await _itemRepo.UpdateInheritedValues(cancellationToken).ConfigureAwait(false);
+ progress.Report(100);
}
private async Task CleanDeadItems(CancellationToken cancellationToken, IProgress<double> progress)
@@ -115,115 +114,6 @@ namespace Emby.Server.Implementations.Data
progress.Report(100);
}
- private async Task CleanDeletedItems(CancellationToken cancellationToken, IProgress<double> progress)
- {
- var result = _itemRepo.GetItemIdsWithPath(new InternalItemsQuery
- {
- LocationTypes = new[] { LocationType.FileSystem },
- //Limit = limit,
-
- // These have their own cleanup routines
- ExcludeItemTypes = new[]
- {
- typeof(Person).Name,
- typeof(Genre).Name,
- typeof(MusicGenre).Name,
- typeof(GameGenre).Name,
- typeof(Studio).Name,
- typeof(Year).Name,
- typeof(Channel).Name,
- typeof(AggregateFolder).Name,
- typeof(CollectionFolder).Name
- }
- });
-
- var numComplete = 0;
- var numItems = result.Count;
-
- var allLibraryPaths = _libraryManager
- .GetVirtualFolders()
- .SelectMany(i => i.Locations)
- .ToList();
-
- foreach (var item in result)
- {
- cancellationToken.ThrowIfCancellationRequested();
-
- var path = item.Item2;
-
- try
- {
- var isPathInLibrary = false;
-
- if (allLibraryPaths.Any(i => path.StartsWith(i, StringComparison.Ordinal)) ||
- allLibraryPaths.Contains(path, StringComparer.Ordinal) ||
- path.StartsWith(_appPaths.ProgramDataPath, StringComparison.Ordinal))
- {
- isPathInLibrary = true;
-
- if (_fileSystem.FileExists(path) || _fileSystem.DirectoryExists(path))
- {
- continue;
- }
- }
-
- var libraryItem = _libraryManager.GetItemById(item.Item1);
-
- if (libraryItem == null)
- {
- continue;
- }
-
- if (libraryItem.IsTopParent)
- {
- continue;
- }
-
- var hasDualAccess = libraryItem as IHasDualAccess;
- if (hasDualAccess != null && hasDualAccess.IsAccessedByName)
- {
- continue;
- }
-
- var libraryItemPath = libraryItem.Path;
- if (!string.Equals(libraryItemPath, path, StringComparison.OrdinalIgnoreCase))
- {
- _logger.Error("CleanDeletedItems aborting delete for item {0}-{1} because paths don't match. {2}---{3}", libraryItem.Id, libraryItem.Name, libraryItem.Path ?? string.Empty, path ?? string.Empty);
- continue;
- }
-
- if (Folder.IsPathOffline(path, allLibraryPaths))
- {
- continue;
- }
-
- if (isPathInLibrary)
- {
- _logger.Info("Deleting item from database {0} because path no longer exists. type: {1} path: {2}", libraryItem.Name, libraryItem.GetType().Name, libraryItemPath ?? string.Empty);
- }
- else
- {
- _logger.Info("Deleting item from database {0} because path is no longer in the server library. type: {1} path: {2}", libraryItem.Name, libraryItem.GetType().Name, libraryItemPath ?? string.Empty);
- }
-
- await libraryItem.OnFileDeleted().ConfigureAwait(false);
- }
- catch (OperationCanceledException)
- {
- throw;
- }
- catch (Exception ex)
- {
- _logger.ErrorException("Error in CleanDeletedItems. File {0}", ex, path);
- }
-
- numComplete++;
- double percent = numComplete;
- percent /= numItems;
- progress.Report(percent * 100);
- }
- }
-
/// <summary>
/// Creates the triggers that define when the task will run
/// </summary>