MCPcopy Create free account
hub / github.com/amule-project/amule / FindSharedFiles

Method FindSharedFiles

src/SharedFileList.cpp:338–412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

336
337
338void 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.

Callers

nothing calls this directly

Calls 15

CFormatClass · 0.85
IsOnShutDownMethod · 0.80
ReloadSharedFoldersMethod · 0.80
GetPrintableMethod · 0.80
GetFullNameMethod · 0.80
GetCatCountMethod · 0.80
insertMethod · 0.80
PrepareIndexMethod · 0.80
ReleaseIndexMethod · 0.80
clearMethod · 0.45
GetFileCountMethod · 0.45
GetFileByIndexMethod · 0.45

Tested by

no test coverage detected