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

Method Entry

src/ThreadTasks.cpp:83–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81
82
83void CHashingTask::Entry()
84{
85 CFileAutoClose file;
86
87 CPath fullPath = m_path.JoinPaths(m_filename);
88 if (!file.Open(fullPath, CFile::read)) {
89 AddDebugLogLineC(logHasher,
90 CFormat("Warning, failed to open file, skipping: %s") % fullPath);
91 return;
92 }
93
94 uint64 fileLength = 0;
95 try {
96 fileLength = file.GetLength();
97 } catch (const CIOFailureException&) {
98 AddDebugLogLineC(logHasher,
99 CFormat("Warning, failed to retrieve file-length, skipping: %s") % fullPath);
100 return;
101 }
102
103 if (fileLength > MAX_FILE_SIZE) {
104 AddDebugLogLineC(logHasher,
105 CFormat("Warning, file is larger than supported size, skipping: %s") % fullPath);
106 return;
107 } else if (fileLength == 0) {
108 if (m_owner) {
109 // It makes no sense to try to hash empty partfiles ...
110 wxFAIL;
111 } else {
112 // Zero-size partfiles should be hashed, but not zero-sized shared-files.
113 AddDebugLogLineC(logHasher,
114 CFormat("Warning, 0-size file, skipping: %s") % fullPath);
115 }
116
117 return;
118 }
119
120 // For thread-safety, results are passed via a temporary file object.
121 CScopedPtr<CKnownFile> knownfile;
122 knownfile->m_filePath = m_path;
123 knownfile->SetFileName(m_filename);
124 knownfile->SetFileSize(fileLength);
125 knownfile->m_lastDateChanged = CPath::GetModificationTime(fullPath);
126 knownfile->m_AvailPartFrequency.insert(
127 knownfile->m_AvailPartFrequency.begin(),
128 knownfile->GetPartCount(), 0);
129
130 if ((m_toHash & EH_MD4) && (m_toHash & EH_AICH)) {
131 knownfile->GetAICHHashset()->FreeHashSet();
132 AddDebugLogLineN( logHasher, CFormat(
133 "Starting to create MD4 and AICH hash for file: %s") %
134 m_filename );
135 } else if ((m_toHash & EH_MD4)) {
136 AddDebugLogLineN( logHasher, CFormat(
137 "Starting to create MD4 hash for file: %s") % m_filename );
138 } else if ((m_toHash & EH_AICH)) {
139 knownfile->GetAICHHashset()->FreeHashSet();
140 AddDebugLogLineN( logHasher, CFormat(

Callers

nothing calls this directly

Calls 15

CFormatClass · 0.85
GetConfigDirFunction · 0.85
CEOFExceptionClass · 0.85
CanFSHandleSpecialCharsFunction · 0.85
JoinPathsMethod · 0.80
insertMethod · 0.80
GetPartCountMethod · 0.80
FreeHashSetMethod · 0.80
GetAICHHashsetMethod · 0.80
whatMethod · 0.80
ReCalculateHashMethod · 0.80

Tested by

no test coverage detected