aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Data
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/Data')
-rw-r--r--Emby.Server.Implementations/Data/CleanDatabaseScheduledTask.cs112
-rw-r--r--Emby.Server.Implementations/Data/SqliteItemRepository.cs125
2 files changed, 33 insertions, 204 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>
diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
index 51f91acf3..61dce9bba 100644
--- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
@@ -201,7 +201,6 @@ namespace Emby.Server.Implementations.Data
AddColumn(db, "TypedBaseItems", "SortName", "Text", existingColumnNames);
AddColumn(db, "TypedBaseItems", "RunTimeTicks", "BIGINT", existingColumnNames);
- AddColumn(db, "TypedBaseItems", "OfficialRatingDescription", "Text", existingColumnNames);
AddColumn(db, "TypedBaseItems", "HomePageUrl", "Text", existingColumnNames);
AddColumn(db, "TypedBaseItems", "VoteCount", "INT", existingColumnNames);
AddColumn(db, "TypedBaseItems", "DisplayMediaType", "Text", existingColumnNames);
@@ -209,7 +208,6 @@ namespace Emby.Server.Implementations.Data
AddColumn(db, "TypedBaseItems", "DateModified", "DATETIME", existingColumnNames);
AddColumn(db, "TypedBaseItems", "ForcedSortName", "Text", existingColumnNames);
- AddColumn(db, "TypedBaseItems", "LocationType", "Text", existingColumnNames);
AddColumn(db, "TypedBaseItems", "IsSeries", "BIT", existingColumnNames);
AddColumn(db, "TypedBaseItems", "IsLive", "BIT", existingColumnNames);
@@ -240,7 +238,6 @@ namespace Emby.Server.Implementations.Data
AddColumn(db, "TypedBaseItems", "SourceType", "Text", existingColumnNames);
AddColumn(db, "TypedBaseItems", "TrailerTypes", "Text", existingColumnNames);
AddColumn(db, "TypedBaseItems", "CriticRating", "Float", existingColumnNames);
- AddColumn(db, "TypedBaseItems", "CriticRatingSummary", "Text", existingColumnNames);
AddColumn(db, "TypedBaseItems", "InheritedTags", "Text", existingColumnNames);
AddColumn(db, "TypedBaseItems", "CleanName", "Text", existingColumnNames);
AddColumn(db, "TypedBaseItems", "PresentationUniqueKey", "Text", existingColumnNames);
@@ -255,7 +252,6 @@ namespace Emby.Server.Implementations.Data
AddColumn(db, "TypedBaseItems", "SeasonName", "Text", existingColumnNames);
AddColumn(db, "TypedBaseItems", "SeasonId", "GUID", existingColumnNames);
AddColumn(db, "TypedBaseItems", "SeriesId", "GUID", existingColumnNames);
- AddColumn(db, "TypedBaseItems", "SeriesSortName", "Text", existingColumnNames);
AddColumn(db, "TypedBaseItems", "ExternalSeriesId", "Text", existingColumnNames);
AddColumn(db, "TypedBaseItems", "Tagline", "Text", existingColumnNames);
AddColumn(db, "TypedBaseItems", "Keywords", "Text", existingColumnNames);
@@ -429,7 +425,6 @@ namespace Emby.Server.Implementations.Data
"ParentIndexNumber",
"ProductionYear",
"OfficialRating",
- "OfficialRatingDescription",
"HomePageUrl",
"DisplayMediaType",
"ForcedSortName",
@@ -454,13 +449,11 @@ namespace Emby.Server.Implementations.Data
"DateLastMediaAdded",
"Album",
"CriticRating",
- "CriticRatingSummary",
"IsVirtualItem",
"SeriesName",
"SeasonName",
"SeasonId",
"SeriesId",
- "SeriesSortName",
"PresentationUniqueKey",
"InheritedParentalRatingValue",
"InheritedTags",
@@ -552,14 +545,12 @@ namespace Emby.Server.Implementations.Data
"InheritedParentalRatingValue",
"SortName",
"RunTimeTicks",
- "OfficialRatingDescription",
"HomePageUrl",
"VoteCount",
"DisplayMediaType",
"DateCreated",
"DateModified",
"ForcedSortName",
- "LocationType",
"PreferredMetadataLanguage",
"PreferredMetadataCountryCode",
"IsHD",
@@ -579,7 +570,6 @@ namespace Emby.Server.Implementations.Data
"SourceType",
"TrailerTypes",
"CriticRating",
- "CriticRatingSummary",
"InheritedTags",
"CleanName",
"PresentationUniqueKey",
@@ -594,7 +584,6 @@ namespace Emby.Server.Implementations.Data
"SeasonName",
"SeasonId",
"SeriesId",
- "SeriesSortName",
"ExternalSeriesId",
"Tagline",
"Keywords",
@@ -833,7 +822,6 @@ namespace Emby.Server.Implementations.Data
saveItemStatement.TryBind("@SortName", item.SortName);
saveItemStatement.TryBind("@RunTimeTicks", item.RunTimeTicks);
- saveItemStatement.TryBind("@OfficialRatingDescription", item.OfficialRatingDescription);
saveItemStatement.TryBind("@HomePageUrl", item.HomePageUrl);
saveItemStatement.TryBind("@VoteCount", item.VoteCount);
saveItemStatement.TryBind("@DisplayMediaType", item.DisplayMediaType);
@@ -841,7 +829,6 @@ namespace Emby.Server.Implementations.Data
saveItemStatement.TryBind("@DateModified", item.DateModified);
saveItemStatement.TryBind("@ForcedSortName", item.ForcedSortName);
- saveItemStatement.TryBind("@LocationType", item.LocationType.ToString());
saveItemStatement.TryBind("@PreferredMetadataLanguage", item.PreferredMetadataLanguage);
saveItemStatement.TryBind("@PreferredMetadataCountryCode", item.PreferredMetadataCountryCode);
@@ -942,7 +929,6 @@ namespace Emby.Server.Implementations.Data
}
saveItemStatement.TryBind("@CriticRating", item.CriticRating);
- saveItemStatement.TryBind("@CriticRatingSummary", item.CriticRatingSummary);
var inheritedTags = item.InheritedTags;
if (inheritedTags.Count > 0)
@@ -1024,13 +1010,11 @@ namespace Emby.Server.Implementations.Data
if (hasSeries != null)
{
saveItemStatement.TryBind("@SeriesId", hasSeries.SeriesId);
- saveItemStatement.TryBind("@SeriesSortName", hasSeries.SeriesSortName);
saveItemStatement.TryBind("@SeriesPresentationUniqueKey", hasSeries.SeriesPresentationUniqueKey);
}
else
{
saveItemStatement.TryBindNull("@SeriesId");
- saveItemStatement.TryBindNull("@SeriesSortName");
saveItemStatement.TryBindNull("@SeriesPresentationUniqueKey");
}
@@ -1290,22 +1274,10 @@ namespace Emby.Server.Implementations.Data
{
return false;
}
- if (type == typeof(Year))
- {
- return false;
- }
- if (type == typeof(Book))
- {
- return false;
- }
if (type == typeof(Person))
{
return false;
}
- if (type == typeof(RecordingGroup))
- {
- return false;
- }
if (type == typeof(Channel))
{
return false;
@@ -1339,31 +1311,42 @@ namespace Emby.Server.Implementations.Data
return false;
}
}
- if (_config.Configuration.SkipDeserializationForPrograms)
+
+ if (type == typeof(Year))
+ {
+ return false;
+ }
+ if (type == typeof(Book))
{
- if (type == typeof(LiveTvProgram))
- {
- return false;
- }
+ return false;
+ }
+ if (type == typeof(RecordingGroup))
+ {
+ return false;
}
+ if (type == typeof(LiveTvProgram))
+ {
+ return false;
+ }
+ if (type == typeof(LiveTvAudioRecording))
+ {
+ return false;
+ }
+ if (type == typeof(AudioPodcast))
+ {
+ return false;
+ }
+ if (type == typeof(AudioBook))
+ {
+ return false;
+ }
+
if (_config.Configuration.SkipDeserializationForAudio)
{
if (type == typeof(Audio))
{
return false;
}
- if (type == typeof(LiveTvAudioRecording))
- {
- return false;
- }
- if (type == typeof(AudioPodcast))
- {
- return false;
- }
- if (type == typeof(AudioBook))
- {
- return false;
- }
if (type == typeof(MusicAlbum))
{
return false;
@@ -1609,15 +1592,6 @@ namespace Emby.Server.Implementations.Data
}
index++;
- if (query.HasField(ItemFields.OfficialRatingDescription))
- {
- if (!reader.IsDBNull(index))
- {
- item.OfficialRatingDescription = reader.GetString(index);
- }
- index++;
- }
-
if (query.HasField(ItemFields.HomePageUrl))
{
if (!reader.IsDBNull(index))
@@ -1803,15 +1777,6 @@ namespace Emby.Server.Implementations.Data
}
index++;
- if (query.HasField(ItemFields.CriticRatingSummary))
- {
- if (!reader.IsDBNull(index))
- {
- item.CriticRatingSummary = reader.GetString(index);
- }
- index++;
- }
-
if (!reader.IsDBNull(index))
{
item.IsVirtualItem = reader.GetBoolean(index);
@@ -1856,15 +1821,6 @@ namespace Emby.Server.Implementations.Data
}
index++;
- if (hasSeries != null)
- {
- if (!reader.IsDBNull(index))
- {
- hasSeries.SeriesSortName = reader.GetString(index);
- }
- }
- index++;
-
if (!reader.IsDBNull(index))
{
item.PresentationUniqueKey = reader.GetString(index);
@@ -2893,6 +2849,10 @@ namespace Emby.Server.Implementations.Data
{
return new Tuple<string, bool>("(Select MAX(LastPlayedDate) from TypedBaseItems B" + GetJoinUserDataText(query) + " where Played=1 and B.SeriesPresentationUniqueKey=A.PresentationUniqueKey)", false);
}
+ if (string.Equals(name, ItemSortBy.SeriesSortName, StringComparison.OrdinalIgnoreCase))
+ {
+ return new Tuple<string, bool>("(Select SortName from TypedBaseItems where B.Guid=A.SeriesId)", false);
+ }
return new Tuple<string, bool>(name, false);
}
@@ -4100,27 +4060,6 @@ namespace Emby.Server.Implementations.Data
whereClauses.Add("ProductionYear in (" + val + ")");
}
- if (query.LocationTypes.Length == 1)
- {
- if (query.LocationTypes[0] == LocationType.Virtual && _config.Configuration.SchemaVersion >= 90)
- {
- query.IsVirtualItem = true;
- }
- else
- {
- whereClauses.Add("LocationType=@LocationType");
- if (statement != null)
- {
- statement.TryBind("@LocationType", query.LocationTypes[0].ToString());
- }
- }
- }
- else if (query.LocationTypes.Length > 1)
- {
- var val = string.Join(",", query.LocationTypes.Select(i => "'" + i + "'").ToArray());
-
- whereClauses.Add("LocationType in (" + val + ")");
- }
if (query.IsVirtualItem.HasValue)
{
whereClauses.Add("IsVirtualItem=@IsVirtualItem");