瀏覽代碼

Check for cancellation between each batch of MediaAttachment inserts.

Andrew Mahone 5 年之前
父節點
當前提交
6defe80b62
共有 1 個文件被更改,包括 4 次插入2 次删除
  1. 4 2
      Emby.Server.Implementations/Data/SqliteItemRepository.cs

+ 4 - 2
Emby.Server.Implementations/Data/SqliteItemRepository.cs

@@ -6226,13 +6226,13 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
 
                     db.Execute("delete from mediaattachments where ItemId=@ItemId", itemIdBlob);
 
-                    InsertMediaAttachments(itemIdBlob, attachments, db);
+                    InsertMediaAttachments(itemIdBlob, attachments, db, cancellationToken);
 
                 }, TransactionMode);
             }
         }
 
-        private void InsertMediaAttachments(byte[] idBlob, List<MediaAttachment> attachments, IDatabaseConnection db)
+        private void InsertMediaAttachments(byte[] idBlob, List<MediaAttachment> attachments, IDatabaseConnection db, CancellationToken cancellationToken)
         {
             var startIndex = 0;
             var insertAtOnce = 10;
@@ -6263,6 +6263,8 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
                     insertText.Append(")");
                 }
 
+                cancellationToken.ThrowIfCancellationRequested();
+
                 using (var statement = PrepareStatement(db, insertText.ToString()))
                 {
                     statement.TryBind("@ItemId", idBlob);