Skip to content

Commit 21362eb

Browse files
committed
treewide: Make uploads asynchronously
1 parent 17f220f commit 21362eb

File tree

1 file changed

+9
-23
lines changed

1 file changed

+9
-23
lines changed

Packages/MIES/MIES_MiesUtilities_Uploads.ipf

+9-23
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ Function UploadCrashDumpsDaily()
3232
return NaN
3333
endif
3434

35-
if(UploadCrashDumps())
36-
printf "Crash dumps have been successfully uploaded.\r"
37-
endif
35+
UploadCrashDumps()
3836

3937
JSON_SetString(jsonID, "/diagnostics/last upload", GetIso8601TimeStamp())
4038
AbortOnRTE
@@ -142,7 +140,7 @@ static Function UploadPing()
142140

143141
jsonID = GenerateJSONTemplateForUpload()
144142
AddPayloadEntries(jsonID, {UPLOAD_BLOCK_USERPING}, {payload}, isBinary = 0)
145-
UploadJSONPayload(jsonID)
143+
UploadJSONPayloadAsync(jsonID)
146144

147145
return err
148146
End
@@ -175,8 +173,6 @@ End
175173
/// The uploaded files are moved out of the way afterwards.
176174
///
177175
/// See `tools/http-upload/upload-json-payload-v1.php` for the JSON format description.
178-
///
179-
/// @return 1 if crash dumps had been uploaded, 0 otherwise
180176
Function UploadCrashDumps()
181177

182178
string diagSymbPath, basePath, diagPath
@@ -192,12 +188,9 @@ Function UploadCrashDumps()
192188
numLogs = DimSize(logs, ROWS)
193189

194190
if(!numFiles && !numLogs)
195-
return 0
191+
return NaN
196192
endif
197193

198-
printf "Please wait while we upload %d crash dumps. This might take a while.\r", numFiles + numLogs
199-
ControlWindowToFront()
200-
201194
jsonID = GenerateJSONTemplateForUpload()
202195

203196
AddPayloadEntriesFromFiles(jsonID, files, isBinary = 1)
@@ -213,15 +206,16 @@ Function UploadCrashDumps()
213206
SaveTextFile(JSON_dump(jsonID, indent = 4), diagPath + ":" + UniqueFileOrFolder(basePath, "crash-dumps", suffix = ".json"))
214207
#endif // DEBUGGING_ENABLED
215208

216-
UploadJSONPayload(jsonID)
209+
UploadJSONPayloadAsync(jsonID)
217210

218211
#ifndef DEBUGGING_ENABLED
219212
MoveFolder/P=$basePath "Diagnostics" as UniqueFileOrFolder(basePath, "Diagnostics_old")
220213
#endif // DEBUGGING_ENABLED
221214

222215
DEBUGPRINT_ELAPSED(referenceTime)
223216

224-
return 1
217+
printf "Uploading %d crash dumps is in progress in the background.\r", numFiles + numLogs
218+
ControlWindowToFront()
225219
End
226220

227221
/// @brief Upload the MIES and ZeroMQ logfiles
@@ -234,7 +228,7 @@ Function UploadLogFiles([variable verbose, variable firstDate, variable lastDate
234228

235229
string logPartStr, fNamePart, file, ticket, timeStamp
236230
string path, location, basePath, out
237-
variable ret, jsonID, numFiles, i, j, doFilter, isBinary, lastIndex, jsonIndex, partCnt, sumSize, fSize
231+
variable jsonID, numFiles, i, j, doFilter, isBinary, lastIndex, jsonIndex, partCnt, sumSize, fSize
238232

239233
isBinary = 1
240234
verbose = ParamIsDefault(verbose) ? 1 : !!verbose
@@ -334,22 +328,14 @@ Function UploadLogFiles([variable verbose, variable firstDate, variable lastDate
334328
sprintf out, "Uploading %.0f MB (~%d Bytes)", sumSize / MEGABYTE, sumSize
335329
UploadLogFilesPrint(out, verbose)
336330
for(jsonID : jsonIDs)
337-
ret = UploadJSONPayload(jsonID)
338-
339-
if(ret)
340-
sprintf out, "Error uploading the logfiles.\r"
341-
UploadLogFilesPrint(out, verbose)
342-
Make/FREE/N=(DimSize(jsonIDs, ROWS)) junk = JSON_Release(jsonIDs[p], ignoreErr = 1)
343-
return NaN
344-
endif
331+
UploadJSONPayloadAsync(jsonID)
345332

346333
UploadLogFilesPrint(".", verbose)
347334
endfor
348335
UploadLogFilesPrint("\r", verbose)
349336
endif
350-
UploadLogFilesPrint("Done.\r", verbose)
351337

352-
sprintf out, "Successfully uploaded the MIES, ZeroMQ-XOP and ITCXOP2 logfiles. Please mention your ticket \"%s\" if you are contacting support.\r", ticket
338+
sprintf out, "Uploading the MIES, ZeroMQ-XOP and ITCXOP2 logfiles is in progress in the background. Please mention your ticket \"%s\" if you are contacting support.\r", ticket
353339
UploadLogFilesPrint(out, verbose)
354340
End
355341

0 commit comments

Comments
 (0)