| 563 | |
| 564 | |
| 565 | bool CSharedFileList::AddFile(CKnownFile* pFile) |
| 566 | { |
| 567 | wxASSERT(pFile->GetHashCount() == pFile->GetED2KPartHashCount()); |
| 568 | |
| 569 | wxMutexLocker lock(list_mut); |
| 570 | |
| 571 | CKnownFileMap::value_type entry(pFile->GetFileHash(), pFile); |
| 572 | if (m_Files_map.insert(entry).second) { |
| 573 | /* Keywords to publish on Kad */ |
| 574 | m_keywords->AddKeywords(pFile); |
| 575 | theStats::AddSharedFile(pFile->GetFileSize()); |
| 576 | // Mirror into the path index so the watcher's per-event |
| 577 | // dispatch can resolve DELETE / MODIFY events to the |
| 578 | // CKnownFile* in O(1). Empty key (e.g. a CPartFile whose |
| 579 | // SetFilePath has not run yet) is harmless: it lives in |
| 580 | // m_pathIndex under "" until SafeAddKFile attaches the real |
| 581 | // path via the post-completion path. Stale entries left |
| 582 | // over from a previous shared-list membership are |
| 583 | // overwritten here. |
| 584 | const wxString key = |
| 585 | pFile->GetFilePath().JoinPaths(pFile->GetFileName()).GetRaw(); |
| 586 | m_pathIndex[key] = pFile; |
| 587 | return true; |
| 588 | } |
| 589 | return false; |
| 590 | } |
| 591 | |
| 592 | |
| 593 | void CSharedFileList::SafeAddKFile(CKnownFile* toadd, bool bOnlyAdd) |
no test coverage detected