| 2274 | |
| 2275 | |
| 2276 | void CPartFile::CompleteFileEnded(bool errorOccured, const CPath& newname) |
| 2277 | { |
| 2278 | if (errorOccured) { |
| 2279 | m_paused = true; |
| 2280 | SetStatus(PS_ERROR); |
| 2281 | AddLogLineC(CFormat( _("Unexpected error while completing %s. File paused") )% GetFileName() ); |
| 2282 | } else { |
| 2283 | m_fullname = newname; |
| 2284 | |
| 2285 | SetFilePath(m_fullname.GetPath()); |
| 2286 | SetFileName(m_fullname.GetFullName()); |
| 2287 | m_lastDateChanged = CPath::GetModificationTime(m_fullname); |
| 2288 | |
| 2289 | SetStatus(PS_COMPLETE); |
| 2290 | m_paused = false; |
| 2291 | ClearPriority(); |
| 2292 | |
| 2293 | |
| 2294 | // Remove from list of canceled files in case it was canceled once upon a time |
| 2295 | if (theApp->canceledfiles->Remove(GetFileHash())) { |
| 2296 | theApp->canceledfiles->Save(); |
| 2297 | } |
| 2298 | |
| 2299 | // Mark as known (checks if it's already known), |
| 2300 | // also updates search files |
| 2301 | theApp->knownfiles->SafeAddKFile(this); |
| 2302 | |
| 2303 | // remove the file from the suspended uploads list |
| 2304 | theApp->uploadqueue->ResumeUpload(GetFileHash()); |
| 2305 | theApp->downloadqueue->RemoveFile(this, true); |
| 2306 | theApp->sharedfiles->SafeAddKFile(this); |
| 2307 | UpdateDisplayedInfo(true); |
| 2308 | |
| 2309 | // republish that file to the ed2k-server to update the 'FT_COMPLETE_SOURCES' counter on the server. |
| 2310 | theApp->sharedfiles->RepublishFile(this); |
| 2311 | |
| 2312 | // Ensure that completed shows the correct value |
| 2313 | completedsize = GetFileSize(); |
| 2314 | |
| 2315 | // clear the blackbox to free up memory |
| 2316 | m_CorruptionBlackBox->Free(); |
| 2317 | |
| 2318 | AddLogLineC(CFormat( _("Finished downloading: %s") ) % GetFileName() ); |
| 2319 | #ifndef AMULE_DAEMON |
| 2320 | if (thePrefs::ShowNotifications()) { |
| 2321 | wxNotificationMessage *notification = new wxNotificationMessage (); |
| 2322 | notification->SetTitle("aMule"); |
| 2323 | notification->SetMessage(CFormat( _("Finished downloading:\n%s") ) % GetFileName() ); |
| 2324 | notification->SetFlags(wxICON_INFORMATION); |
| 2325 | notification->Show(7); |
| 2326 | delete notification; |
| 2327 | } |
| 2328 | #endif |
| 2329 | } |
| 2330 | |
| 2331 | theApp->downloadqueue->StartNextFile(this); |
| 2332 | } |
| 2333 |
no test coverage detected