(bot, task, build, sdkVariant, abiVariant, onDone)
| 1050 | } |
| 1051 | |
| 1052 | function uploadToTelegram (bot, task, build, sdkVariant, abiVariant, onDone) { |
| 1053 | const files = build.files[sdkVariant][abiVariant]; |
| 1054 | if (!files) { |
| 1055 | console.log('Build files not found to upload'); |
| 1056 | onDone(1); |
| 1057 | return; |
| 1058 | } |
| 1059 | |
| 1060 | const failWithError = (message, e) => { |
| 1061 | if (!task.endTime) { |
| 1062 | console.error(message, e); |
| 1063 | onDone(1); |
| 1064 | } |
| 1065 | }; |
| 1066 | |
| 1067 | const maxUploadAttemptCount = 5; |
| 1068 | |
| 1069 | const onMappingUploaded = (mappingMessage) => { |
| 1070 | onDone(0); |
| 1071 | }; |
| 1072 | |
| 1073 | const onSymbolsUploaded = (symbolsMessage) => { |
| 1074 | if (!files.mappingFile) { // Mapping file doesn't exist for builds made with --dontobfuscate option |
| 1075 | onDone(0); |
| 1076 | return; |
| 1077 | } |
| 1078 | attemptAction(maxUploadAttemptCount, (accept, reject) => { |
| 1079 | bot.sendDocument(build.serviceChatId, fs.createReadStream(files.mappingFile.path), { |
| 1080 | reply_to_message_id: symbolsMessage.message_id |
| 1081 | }, { |
| 1082 | contentType: 'text/plain' |
| 1083 | }).then(accept).catch(reject); |
| 1084 | }, (e, attemptNo) => { |
| 1085 | console.log('[RETRY]', 'Trying again to upload mapping file to Telegram, attemptNo:', attemptNo, e); |
| 1086 | }).then(onMappingUploaded).catch((e) => { |
| 1087 | failWithError('Cannot upload mapping file', e); |
| 1088 | }) |
| 1089 | }; |
| 1090 | |
| 1091 | const onApkUploaded = (apkMessage) => { |
| 1092 | files.apkFile.remote_id = apkMessage.document.file_id; |
| 1093 | modifyNativeDebugSymbolsArchive(files.nativeDebugSymbolsFile.path).then((nativeDebugSymbolsPath) => { |
| 1094 | attemptAction(maxUploadAttemptCount, (accept, reject) => { |
| 1095 | const nativeDebugSymbolsStream = fs.createReadStream(nativeDebugSymbolsPath); |
| 1096 | bot.sendDocument(build.serviceChatId, nativeDebugSymbolsStream, { |
| 1097 | reply_to_message_id: apkMessage.message_id |
| 1098 | }, { |
| 1099 | contentType: 'application/zip' |
| 1100 | }).then(accept).catch(reject); |
| 1101 | }, (e, attemptNo) => { |
| 1102 | console.log('[RETRY]', 'Trying again to upload native-debug-symbols.zip to Telegram, attemptNo:', attemptNo, e); |
| 1103 | }).then(onSymbolsUploaded).catch((e) => { |
| 1104 | failWithError('Cannot upload native-debug-symbols.zip', e); |
| 1105 | }); |
| 1106 | }); |
| 1107 | }; |
| 1108 | |
| 1109 | attemptAction(maxUploadAttemptCount, (accept, reject) => { |
no test coverage detected