| 347 | |
| 348 | |
| 349 | void CDownloadQueue::AddDownload(CPartFile* file, bool paused, uint8 category) |
| 350 | { |
| 351 | wxCHECK_RET(!IsFileExisting(file->GetFileHash()), "Adding duplicate part-file"); |
| 352 | |
| 353 | if (file->GetStatus(true) == PS_ALLOCATING) { |
| 354 | file->PauseFile(); |
| 355 | } else if (paused && GetFileCount()) { |
| 356 | file->StopFile(); |
| 357 | } |
| 358 | |
| 359 | { |
| 360 | wxMutexLocker lock(m_mutex); |
| 361 | m_filelist.push_back( file ); |
| 362 | DoSortByPriority(); |
| 363 | } |
| 364 | |
| 365 | NotifyObservers( EventType( EventType::INSERTED, file ) ); |
| 366 | if (category < theApp->glob_prefs->GetCatCount()) { |
| 367 | file->SetCategory(category); |
| 368 | } else { |
| 369 | AddDebugLogLineN( logDownloadQueue, "Tried to add download into invalid category." ); |
| 370 | } |
| 371 | Notify_DownloadCtrlAddFile( file ); |
| 372 | theApp->searchlist->UpdateSearchFileByHash(file->GetFileHash()); // Update file in the search dialog if it's still open |
| 373 | AddLogLineC(CFormat(_("Downloading %s")) % file->GetFileName() ); |
| 374 | } |
| 375 | |
| 376 | |
| 377 | bool CDownloadQueue::IsFileExisting( const CMD4Hash& fileid ) const |
no test coverage detected