* Handle the closing and extracting of a file after * downloading it has been done. */
| 519 | * downloading it has been done. |
| 520 | */ |
| 521 | void ClientNetworkContentSocketHandler::AfterDownload() |
| 522 | { |
| 523 | /* We read nothing; that's our marker for end-of-stream. |
| 524 | * Now gunzip the tar and make it known. */ |
| 525 | this->cur_file.reset(); |
| 526 | |
| 527 | if (GunzipFile(*this->cur_info)) { |
| 528 | FioRemove(GetFullFilename(*this->cur_info, true)); |
| 529 | |
| 530 | Subdirectory sd = GetContentInfoSubDir(this->cur_info->type); |
| 531 | if (sd == NO_DIRECTORY) NOT_REACHED(); |
| 532 | |
| 533 | TarScanner ts; |
| 534 | std::string fname = GetFullFilename(*this->cur_info, false); |
| 535 | ts.AddFile(sd, fname); |
| 536 | |
| 537 | if (this->cur_info->type == CONTENT_TYPE_BASE_MUSIC) { |
| 538 | /* Music can't be in a tar. So extract the tar! */ |
| 539 | ExtractTar(fname, BASESET_DIR); |
| 540 | FioRemove(fname); |
| 541 | } |
| 542 | |
| 543 | #ifdef __EMSCRIPTEN__ |
| 544 | EM_ASM(if (window["openttd_syncfs"]) openttd_syncfs()); |
| 545 | #endif |
| 546 | |
| 547 | this->OnDownloadComplete(this->cur_info->id); |
| 548 | } else { |
| 549 | ShowErrorMessage(GetEncodedString(STR_CONTENT_ERROR_COULD_NOT_EXTRACT), {}, WL_ERROR); |
| 550 | } |
| 551 | } |
| 552 | |
| 553 | bool ClientNetworkContentSocketHandler::IsCancelled() const |
| 554 | { |
no test coverage detected