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

Method FindKnownFile

src/KnownFileList.cpp:337–378  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

335
336
337CKnownFile* CKnownFileList::FindKnownFile(
338 const CPath& filename,
339 time_t in_date,
340 uint64 in_size)
341{
342 wxMutexLocker sLock(list_mut);
343 const uint32 now = (uint32) time(NULL);
344
345 if (m_knownSizeMap) {
346 const auto key = std::make_pair((uint32) in_size, (uint32) in_date);
347 std::pair<KnownFileSizeMap::const_iterator, KnownFileSizeMap::const_iterator> p;
348 p = m_knownSizeMap->equal_range(key);
349 for (KnownFileSizeMap::const_iterator it = p.first; it != p.second; ++it) {
350 CKnownFile *cur_file = it->second;
351 if (KnownFileMatches(cur_file, filename, in_date, in_size)) {
352 cur_file->SetLastSeen(now);
353 return cur_file;
354 }
355 }
356 } else {
357 for (CKnownFileMap::const_iterator it = m_knownFileMap.begin();
358 it != m_knownFileMap.end(); ++it) {
359 CKnownFile *cur_file = it->second;
360 if (KnownFileMatches(cur_file, filename, in_date, in_size)) {
361 cur_file->SetLastSeen(now);
362 return cur_file;
363 }
364 }
365 }
366
367 // Pin any duplicate-list match against this session's prune so a
368 // real on-disk file's record isn't dropped just because its hash
369 // is also held by a more-recent live entry (the dual-content-copy
370 // case: same hash in two shared paths -- one becomes m_Files_map,
371 // the other only ever appears here).
372 CKnownFile * dup = IsOnDuplicates(filename, in_date, in_size);
373 if (dup) {
374 dup->SetLastSeen(now);
375 m_pinnedDuplicates.insert(dup);
376 }
377 return dup;
378}
379
380
381CKnownFile *CKnownFileList::IsOnDuplicates(

Callers 1

AddPathToSharesMethod · 0.80

Calls 4

insertMethod · 0.80
SetLastSeenMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected