aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2017-10-22 02:23:24 -0400
committerGitHub <noreply@github.com>2017-10-22 02:23:24 -0400
commitef00237c729cbcc5cdba14560ef57e3e88da762b (patch)
treedc9c476050c4cd0877b838daae3329e45baf7f1f /Emby.Server.Implementations
parentac63ebfb316904da9d36328340a6ef72a932eba0 (diff)
parent61a2c23b0f7d469135b501d543fc6a146ed94f14 (diff)
Merge pull request #2968 from MediaBrowser/dev
Dev
Diffstat (limited to 'Emby.Server.Implementations')
-rw-r--r--Emby.Server.Implementations/Activity/ActivityRepository.cs2
-rw-r--r--Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs2
-rw-r--r--Emby.Server.Implementations/Data/SqliteItemRepository.cs53
-rw-r--r--Emby.Server.Implementations/Data/SqliteUserDataRepository.cs2
-rw-r--r--Emby.Server.Implementations/Data/SqliteUserRepository.cs3
-rw-r--r--Emby.Server.Implementations/Devices/SqliteDeviceRepository.cs2
-rw-r--r--Emby.Server.Implementations/Dto/DtoService.cs14
-rw-r--r--Emby.Server.Implementations/Library/LibraryManager.cs7
-rw-r--r--Emby.Server.Implementations/Notifications/NotificationManager.cs1
-rw-r--r--Emby.Server.Implementations/Security/AuthenticationRepository.cs2
-rw-r--r--Emby.Server.Implementations/Social/SharingRepository.cs2
11 files changed, 71 insertions, 19 deletions
diff --git a/Emby.Server.Implementations/Activity/ActivityRepository.cs b/Emby.Server.Implementations/Activity/ActivityRepository.cs
index 1ae8e5e66..6293cc69f 100644
--- a/Emby.Server.Implementations/Activity/ActivityRepository.cs
+++ b/Emby.Server.Implementations/Activity/ActivityRepository.cs
@@ -49,7 +49,7 @@ namespace Emby.Server.Implementations.Activity
RunDefaultInitialization(connection);
string[] queries = {
- "create table if not exists ActivityLogEntries (Id GUID PRIMARY KEY, Name TEXT, Overview TEXT, ShortOverview TEXT, Type TEXT, ItemId TEXT, UserId TEXT, DateCreated DATETIME, LogSeverity TEXT)",
+ "create table if not exists ActivityLogEntries (Id GUID PRIMARY KEY NOT NULL, Name TEXT NOT NULL, Overview TEXT, ShortOverview TEXT, Type TEXT NOT NULL, ItemId TEXT, UserId TEXT, DateCreated DATETIME NOT NULL, LogSeverity TEXT NOT NULL)",
"create index if not exists idx_ActivityLogEntries on ActivityLogEntries(Id)"
};
diff --git a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs
index 1901ce848..e6afcd410 100644
--- a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs
@@ -75,7 +75,7 @@ namespace Emby.Server.Implementations.Data
string[] queries = {
- "create table if not exists userdisplaypreferences (id GUID, userId GUID, client text, data BLOB)",
+ "create table if not exists userdisplaypreferences (id GUID NOT NULL, userId GUID NOT NULL, client text NOT NULL, data BLOB NOT NULL)",
"create unique index if not exists userdisplaypreferencesindex on userdisplaypreferences (id, userId, client)"
};
diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
index a6c7150da..01416a307 100644
--- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
@@ -146,11 +146,11 @@ namespace Emby.Server.Implementations.Data
"create table if not exists TypedBaseItems (guid GUID primary key NOT NULL, type TEXT NOT NULL, data BLOB NULL, ParentId GUID NULL, Path TEXT NULL)",
- "create table if not exists AncestorIds (ItemId GUID, AncestorId GUID, AncestorIdText TEXT, PRIMARY KEY (ItemId, AncestorId))",
+ "create table if not exists AncestorIds (ItemId GUID NOT NULL, AncestorId GUID NOT NULL, AncestorIdText TEXT NOT NULL, PRIMARY KEY (ItemId, AncestorId))",
"create index if not exists idx_AncestorIds1 on AncestorIds(AncestorId)",
"create index if not exists idx_AncestorIds5 on AncestorIds(AncestorIdText,ItemId)",
- "create table if not exists ItemValues (ItemId GUID, Type INT, Value TEXT, CleanValue TEXT)",
+ "create table if not exists ItemValues (ItemId GUID NOT NULL, Type INT NOT NULL, Value TEXT NOT NULL, CleanValue TEXT NOT NULL)",
"create table if not exists People (ItemId GUID, Name TEXT NOT NULL, Role TEXT, PersonType TEXT, SortOrder int, ListOrder int)",
@@ -158,7 +158,7 @@ namespace Emby.Server.Implementations.Data
"create index if not exists idxPeopleItemId1 on People(ItemId,ListOrder)",
"create index if not exists idxPeopleName on People(Name)",
- "create table if not exists "+ChaptersTableName+" (ItemId GUID, ChapterIndex INT, StartPositionTicks BIGINT, Name TEXT, ImagePath TEXT, PRIMARY KEY (ItemId, ChapterIndex))",
+ "create table if not exists "+ChaptersTableName+" (ItemId GUID, ChapterIndex INT NOT NULL, StartPositionTicks BIGINT NOT NULL, Name TEXT, ImagePath TEXT, PRIMARY KEY (ItemId, ChapterIndex))",
createMediaStreamsTableCommand,
@@ -616,6 +616,33 @@ namespace Emby.Server.Implementations.Data
SaveItems(new List<BaseItem> { item }, cancellationToken);
}
+ public void SaveImages(BaseItem item)
+ {
+ if (item == null)
+ {
+ throw new ArgumentNullException("item");
+ }
+
+ CheckDisposed();
+
+ using (WriteLock.Write())
+ {
+ using (var connection = CreateConnection())
+ {
+ connection.RunInTransaction(db =>
+ {
+ using (var saveImagesStatement = PrepareStatement(db, "Update TypedBaseItems set Images=@Images where guid=@Id"))
+ {
+ saveImagesStatement.TryBind("@Id", item.Id.ToGuidBlob());
+ saveImagesStatement.TryBind("@Images", SerializeImages(item));
+
+ saveImagesStatement.MoveNext();
+ }
+ }, TransactionMode);
+ }
+ }
+ }
+
/// <summary>
/// Saves the items.
/// </summary>
@@ -1170,7 +1197,11 @@ namespace Emby.Server.Implementations.Data
delimeter +
image.DateModified.Ticks.ToString(CultureInfo.InvariantCulture) +
delimeter +
- image.Type;
+ image.Type +
+ delimeter +
+ image.Width.ToString(CultureInfo.InvariantCulture) +
+ delimeter +
+ image.Height.ToString(CultureInfo.InvariantCulture);
}
public ItemImageInfo ItemImageInfoFromValueString(string value)
@@ -1198,6 +1229,20 @@ namespace Emby.Server.Implementations.Data
image.Type = type;
}
+ if (parts.Length >= 5)
+ {
+ int width;
+ int height;
+ if (int.TryParse(parts[3], NumberStyles.Integer, CultureInfo.InvariantCulture, out width))
+ {
+ if (int.TryParse(parts[4], NumberStyles.Integer, CultureInfo.InvariantCulture, out height))
+ {
+ image.Width = width;
+ image.Height = height;
+ }
+ }
+ }
+
return image;
}
diff --git a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs
index ef1d7ba44..ad5c60ede 100644
--- a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs
@@ -52,7 +52,7 @@ namespace Emby.Server.Implementations.Data
{
string[] queries = {
- "create table if not exists userdata (key nvarchar, userId GUID, rating float null, played bit, playCount int, isFavorite bit, playbackPositionTicks bigint, lastPlayedDate datetime null)",
+ "create table if not exists userdata (key nvarchar not null, userId GUID not null, rating float null, played bit not null, playCount int not null, isFavorite bit not null, playbackPositionTicks bigint not null, lastPlayedDate datetime null)",
"create table if not exists DataSettings (IsUserDataImported bit)",
diff --git a/Emby.Server.Implementations/Data/SqliteUserRepository.cs b/Emby.Server.Implementations/Data/SqliteUserRepository.cs
index b65996e40..e89de11c6 100644
--- a/Emby.Server.Implementations/Data/SqliteUserRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteUserRepository.cs
@@ -53,9 +53,8 @@ namespace Emby.Server.Implementations.Data
string[] queries = {
- "create table if not exists users (guid GUID primary key, data BLOB)",
+ "create table if not exists users (guid GUID primary key NOT NULL, data BLOB NOT NULL)",
"create index if not exists idx_users on users(guid)",
- "create table if not exists schema_version (table_name primary key, version)",
"pragma shrink_memory"
};
diff --git a/Emby.Server.Implementations/Devices/SqliteDeviceRepository.cs b/Emby.Server.Implementations/Devices/SqliteDeviceRepository.cs
index a15eb3558..b11a5d65b 100644
--- a/Emby.Server.Implementations/Devices/SqliteDeviceRepository.cs
+++ b/Emby.Server.Implementations/Devices/SqliteDeviceRepository.cs
@@ -60,7 +60,7 @@ namespace Emby.Server.Implementations.Devices
RunDefaultInitialization(connection);
string[] queries = {
- "create table if not exists Devices (Id TEXT PRIMARY KEY, Name TEXT, ReportedName TEXT, CustomName TEXT, CameraUploadPath TEXT, LastUserName TEXT, AppName TEXT, AppVersion TEXT, LastUserId TEXT, DateLastModified DATETIME, Capabilities TEXT)",
+ "create table if not exists Devices (Id TEXT PRIMARY KEY, Name TEXT NOT NULL, ReportedName TEXT NOT NULL, CustomName TEXT, CameraUploadPath TEXT, LastUserName TEXT NOT NULL, AppName TEXT NOT NULL, AppVersion TEXT NOT NULL, LastUserId TEXT NOT NULL, DateLastModified DATETIME NOT NULL, Capabilities TEXT NOT NULL)",
"create index if not exists idx_id on Devices(Id)"
};
diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs
index ef66c201c..a0176e406 100644
--- a/Emby.Server.Implementations/Dto/DtoService.cs
+++ b/Emby.Server.Implementations/Dto/DtoService.cs
@@ -1608,12 +1608,12 @@ namespace Emby.Server.Implementations.Dto
/// <param name="dto">The dto.</param>
/// <param name="item">The item.</param>
/// <returns>Task.</returns>
- public void AttachPrimaryImageAspectRatio(IItemDto dto, IHasMetadata item)
+ public void AttachPrimaryImageAspectRatio(IItemDto dto, BaseItem item)
{
dto.PrimaryImageAspectRatio = GetPrimaryImageAspectRatio(item);
}
- public double? GetPrimaryImageAspectRatio(IHasMetadata item)
+ public double? GetPrimaryImageAspectRatio(BaseItem item)
{
var imageInfo = item.GetImageInfo(ImageType.Primary, 0);
@@ -1646,12 +1646,14 @@ namespace Emby.Server.Implementations.Dto
return null;
}
- return null;
- _logger.Info("Getting image size for item type {0}", item.GetType().Name);
-
try
{
- size = _imageProcessor.GetImageSize(imageInfo);
+ size = _imageProcessor.GetImageSize(item, imageInfo);
+
+ if (size.Width <= 0 || size.Height <= 0)
+ {
+ return null;
+ }
}
catch
{
diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs
index a7b85ad42..cac1cb3b4 100644
--- a/Emby.Server.Implementations/Library/LibraryManager.cs
+++ b/Emby.Server.Implementations/Library/LibraryManager.cs
@@ -1826,6 +1826,13 @@ namespace Emby.Server.Implementations.Library
}
}
+ public void UpdateImages(BaseItem item)
+ {
+ ItemRepository.SaveImages(item);
+
+ RegisterItem(item);
+ }
+
/// <summary>
/// Updates the item.
/// </summary>
diff --git a/Emby.Server.Implementations/Notifications/NotificationManager.cs b/Emby.Server.Implementations/Notifications/NotificationManager.cs
index 5b4c43dd5..e11f2790e 100644
--- a/Emby.Server.Implementations/Notifications/NotificationManager.cs
+++ b/Emby.Server.Implementations/Notifications/NotificationManager.cs
@@ -76,7 +76,6 @@ namespace Emby.Server.Implementations.Notifications
var tasks = users.Select(i => SendNotification(request, service, title, description, i, cancellationToken));
return Task.WhenAll(tasks);
-
}
private IEnumerable<string> GetUserIds(NotificationRequest request, NotificationOption options)
diff --git a/Emby.Server.Implementations/Security/AuthenticationRepository.cs b/Emby.Server.Implementations/Security/AuthenticationRepository.cs
index f5b847ccf..b1877d776 100644
--- a/Emby.Server.Implementations/Security/AuthenticationRepository.cs
+++ b/Emby.Server.Implementations/Security/AuthenticationRepository.cs
@@ -34,7 +34,7 @@ namespace Emby.Server.Implementations.Security
string[] queries = {
- "create table if not exists AccessTokens (Id GUID PRIMARY KEY, AccessToken TEXT NOT NULL, DeviceId TEXT, AppName TEXT, AppVersion TEXT, DeviceName TEXT, UserId TEXT, IsActive BIT, DateCreated DATETIME NOT NULL, DateRevoked DATETIME)",
+ "create table if not exists AccessTokens (Id GUID PRIMARY KEY NOT NULL, AccessToken TEXT NOT NULL, DeviceId TEXT NOT NULL, AppName TEXT NOT NULL, AppVersion TEXT NOT NULL, DeviceName TEXT NOT NULL, UserId TEXT, IsActive BIT NOT NULL, DateCreated DATETIME NOT NULL, DateRevoked DATETIME)",
"create index if not exists idx_AccessTokens on AccessTokens(Id)"
};
diff --git a/Emby.Server.Implementations/Social/SharingRepository.cs b/Emby.Server.Implementations/Social/SharingRepository.cs
index f0b8cbd30..3c9e1024f 100644
--- a/Emby.Server.Implementations/Social/SharingRepository.cs
+++ b/Emby.Server.Implementations/Social/SharingRepository.cs
@@ -50,7 +50,7 @@ namespace Emby.Server.Implementations.Social
string[] queries = {
- "create table if not exists Shares (Id GUID, ItemId TEXT, UserId TEXT, ExpirationDate DateTime, PRIMARY KEY (Id))",
+ "create table if not exists Shares (Id GUID NOT NULL, ItemId TEXT NOT NULL, UserId TEXT NOT NULL, ExpirationDate DateTime NOT NULL, PRIMARY KEY (Id))",
"create index if not exists idx_Shares on Shares(Id)",
"pragma shrink_memory"