| 336 | |
| 337 | |
| 338 | void CSharedFileList::FindSharedFiles(const ReloadYieldCb & yieldCb, bool & aborted) |
| 339 | { |
| 340 | /* Abort loading if we are shutting down. */ |
| 341 | if(theApp->IsOnShutDown()) { |
| 342 | return; |
| 343 | } |
| 344 | |
| 345 | // Clear statistics. |
| 346 | theStats::ClearSharedFilesInfo(); |
| 347 | |
| 348 | // Reload shareddir.dat |
| 349 | theApp->glob_prefs->ReloadSharedFolders(); |
| 350 | |
| 351 | { |
| 352 | wxMutexLocker lock(list_mut); |
| 353 | m_Files_map.clear(); |
| 354 | } |
| 355 | |
| 356 | // All part files are automatically shared. |
| 357 | for ( uint32 i = 0; i < theApp->downloadqueue->GetFileCount(); ++i ) { |
| 358 | CPartFile* file = theApp->downloadqueue->GetFileByIndex( i ); |
| 359 | |
| 360 | if ( file->GetStatus(true) == PS_READY ) { |
| 361 | AddLogLineNS(CFormat(_("Adding file %s to shares")) |
| 362 | % file->GetFullName().GetPrintable()); |
| 363 | AddFile(file); |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | // Create a list of all shared paths and weed out duplicates. |
| 368 | std::list<CPath> sharedPaths; |
| 369 | |
| 370 | // Global incoming dir and all category incoming directories are automatically shared. |
| 371 | sharedPaths.push_back(thePrefs::GetIncomingDir()); |
| 372 | for (unsigned int i = 1;i < theApp->glob_prefs->GetCatCount(); ++i) { |
| 373 | sharedPaths.push_back(theApp->glob_prefs->GetCatPath(i)); |
| 374 | } |
| 375 | |
| 376 | const thePrefs::PathList& shared = theApp->glob_prefs->shareddir_list; |
| 377 | sharedPaths.insert(sharedPaths.end(), shared.begin(), shared.end()); |
| 378 | |
| 379 | sharedPaths.sort(); |
| 380 | sharedPaths.unique(); |
| 381 | |
| 382 | filelist->PrepareIndex(); |
| 383 | // Gathering is done in the foreground and can be slowed down severely by parallel background hashing. |
| 384 | // So just store the hashing tasks for now. |
| 385 | TaskList hashTasks; |
| 386 | size_t scanned = 0; |
| 387 | for (std::list<CPath>::iterator it = sharedPaths.begin(); it != sharedPaths.end(); ++it) { |
| 388 | AddFilesFromDirectory(*it, hashTasks, yieldCb, scanned, aborted); |
| 389 | if (aborted) { |
| 390 | break; |
| 391 | } |
| 392 | } |
| 393 | filelist->ReleaseIndex(); |
| 394 | |
| 395 | // Now that the shared files are gathered feed the hashing tasks to the scheduler to start hashing. |
nothing calls this directly
no test coverage detected