Comparison function needed by sort. Returns true if file1 precedes file2
| 990 | |
| 991 | // Comparison function needed by sort. Returns true if file1 precedes file2 |
| 992 | static bool ComparePartFiles(const CPartFile* file1, const CPartFile* file2) { |
| 993 | if (file1->GetDownPriority() != file2->GetDownPriority()) { |
| 994 | // To place high-priority files before low priority files we have to |
| 995 | // invert this test, since PR_LOW is lower than PR_HIGH, and since |
| 996 | // placing a PR_LOW file before a PR_HIGH file would mean that |
| 997 | // the PR_LOW file gets sources before the PR_HIGH file ... |
| 998 | return (file1->GetDownPriority() > file2->GetDownPriority()); |
| 999 | } else { |
| 1000 | int sourcesA = file1->GetSourceCount(); |
| 1001 | int sourcesB = file2->GetSourceCount(); |
| 1002 | |
| 1003 | int notSourcesA = file1->GetNotCurrentSourcesCount(); |
| 1004 | int notSourcesB = file2->GetNotCurrentSourcesCount(); |
| 1005 | |
| 1006 | int cmp = CmpAny( sourcesA - notSourcesA, sourcesB - notSourcesB ); |
| 1007 | |
| 1008 | if ( cmp == 0 ) { |
| 1009 | cmp = CmpAny( notSourcesA, notSourcesB ); |
| 1010 | } |
| 1011 | |
| 1012 | return cmp < 0; |
| 1013 | } |
| 1014 | } |
| 1015 | |
| 1016 | |
| 1017 | void CDownloadQueue::DoSortByPriority() |
nothing calls this directly
no test coverage detected