private void PieceFinishedAlert(piece_finished_alert a) { Interlocked.MemoryBarrier(); using (Core.TorrentHandle th = a.handle) using (Core.Sha1Hash hash = th.info_hash()) { if (TorrentList.ToList().Any(x => x.Hash == hash.ToString())) { Models.TorrentItem ti = TorrentList.First(z => z.Hash == hash.ToString()); if (!ReferenceEquals(null, ti.Pieces.Parts) && ti.Pieces.Parts.Any(q => q.Id == a.piece_index)) { ti.Pieces.Parts[a.piece_index].Downloaded = true; log.Debug("{0} for {1}", a.piece_index, ti.Name); foreach (Models.FileEntry item in ti.FileList) { foreach (Models.Part part in item.Pieces.Where(k => k.Id == a.piece_index)) { part.Downloaded = true; } } if (ti.SequentialDownload) { if (ti.Pieces.Parts.Any(w => w.Downloaded == false)) { Models.Part mp = ti.Pieces.Parts.First(w => w.Downloaded == false); mp.Priority = 7; th.piece_priority(mp.Id, 7); } } } } } }
private void OnPieceFinishedAlert(piece_finished_alert a) { string hash = a.handle.info_hash().ToString(); if (_streamingList.ContainsKey(hash) && _streamingList[hash].OnStreaming) { _streamingList[hash].ContinueOne(); } }