aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Data/SqliteItemRepository.cs
diff options
context:
space:
mode:
authorBond_009 <bond.009@outlook.com>2019-12-26 23:09:00 +0100
committerdkanada <dkanada@users.noreply.github.com>2020-01-08 01:23:57 +0900
commita253fa616da3fd982ca2190b69d25853893665f1 (patch)
tree26ebc329f7ab82bb366c1e8703c9527ccd1f5e6f /Emby.Server.Implementations/Data/SqliteItemRepository.cs
parentaca31457c06ea13042accd60e27ab61208a51577 (diff)
Fix build and address comments
Diffstat (limited to 'Emby.Server.Implementations/Data/SqliteItemRepository.cs')
-rw-r--r--Emby.Server.Implementations/Data/SqliteItemRepository.cs34
1 files changed, 18 insertions, 16 deletions
diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
index 2206816a5..91ca8477d 100644
--- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
@@ -55,8 +55,8 @@ namespace Emby.Server.Implementations.Data
queryPrefixText.Append("insert into mediaattachments (");
foreach (var column in _mediaAttachmentSaveColumns)
{
- queryPrefixText.Append(column);
- queryPrefixText.Append(',');
+ queryPrefixText.Append(column)
+ .Append(',');
}
queryPrefixText.Length -= 1;
@@ -449,6 +449,7 @@ namespace Emby.Server.Implementations.Data
"Filename",
"MIMEType"
};
+
private static readonly string _mediaAttachmentInsertPrefix;
private static string GetSaveItemCommandText()
@@ -6208,7 +6209,10 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
return list;
}
- public void SaveMediaAttachments(Guid id, List<MediaAttachment> attachments, CancellationToken cancellationToken)
+ public void SaveMediaAttachments(
+ Guid id,
+ List<MediaAttachment> attachments,
+ CancellationToken cancellationToken)
{
CheckDisposed();
if (id == Guid.Empty)
@@ -6237,24 +6241,22 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
}
}
- private void InsertMediaAttachments(byte[] idBlob, List<MediaAttachment> attachments, IDatabaseConnection db, CancellationToken cancellationToken)
+ private void InsertMediaAttachments(
+ byte[] idBlob,
+ List<MediaAttachment> attachments,
+ IDatabaseConnection db,
+ CancellationToken cancellationToken)
{
- var startIndex = 0;
- var insertAtOnce = 10;
+ const int InsertAtOnce = 10;
- while (startIndex < attachments.Count)
+ for (var startIndex = 0; startIndex < attachments.Count; startIndex += InsertAtOnce)
{
var insertText = new StringBuilder(_mediaAttachmentInsertPrefix);
- var endIndex = Math.Min(attachments.Count, startIndex + insertAtOnce);
+ var endIndex = Math.Min(attachments.Count, startIndex + InsertAtOnce);
for (var i = startIndex; i < endIndex; i++)
{
- if (i != startIndex)
- {
- insertText.Append(',');
- }
-
var index = i.ToString(CultureInfo.InvariantCulture);
insertText.Append("(@ItemId, ");
@@ -6265,9 +6267,11 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
insertText.Length -= 1;
- insertText.Append(")");
+ insertText.Append("),");
}
+ insertText.Length--;
+
cancellationToken.ThrowIfCancellationRequested();
using (var statement = PrepareStatement(db, insertText.ToString()))
@@ -6291,8 +6295,6 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
statement.Reset();
statement.MoveNext();
}
-
- startIndex += insertAtOnce;
}
}