mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Catch wrong cloud responses when it responds with a new file name
It could happen if there are bugs in the cloud, e.g. if they strip special characters somewhere. We'd want to know it if they do. But we also don't want Cura to crash if the remote connection is not reliable, or if there's changes/bugs in the future. Fixes Sentry issue CURA-42F.
This commit is contained in:
parent
1df76d8cc5
commit
96192adce2
1 changed files with 10 additions and 5 deletions
|
@ -1,5 +1,6 @@
|
||||||
# Copyright (c) 2021 Ultimaker B.V.
|
# Copyright (c) 2022 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import threading
|
import threading
|
||||||
from json import JSONDecodeError
|
from json import JSONDecodeError
|
||||||
|
@ -135,6 +136,9 @@ class DFFileExportAndUploadManager:
|
||||||
else:
|
else:
|
||||||
Logger.log("e", "Wrong response type received. Aborting uploading file to the Digital Library")
|
Logger.log("e", "Wrong response type received. Aborting uploading file to the Digital Library")
|
||||||
return
|
return
|
||||||
|
if file_name not in self._file_upload_job_metadata:
|
||||||
|
Logger.error(f"API response for uploading doesn't match the file name we just uploaded: {file_name} was never uploaded.")
|
||||||
|
return
|
||||||
with self._message_lock:
|
with self._message_lock:
|
||||||
self.progress_message.show()
|
self.progress_message.show()
|
||||||
self._file_upload_job_metadata[file_name]["file_upload_response"] = file_upload_response
|
self._file_upload_job_metadata[file_name]["file_upload_response"] = file_upload_response
|
||||||
|
@ -335,10 +339,11 @@ class DFFileExportAndUploadManager:
|
||||||
self._handleNextUploadJob()
|
self._handleNextUploadJob()
|
||||||
|
|
||||||
def _handleNextUploadJob(self):
|
def _handleNextUploadJob(self):
|
||||||
match self._upload_jobs:
|
try:
|
||||||
case [job, *jobs]:
|
job = self._upload_jobs.pop(0)
|
||||||
job.start()
|
job.start()
|
||||||
self._upload_jobs = jobs
|
except IndexError:
|
||||||
|
pass # Empty list, do nothing.
|
||||||
|
|
||||||
def initializeFileUploadJobMetadata(self) -> Dict[str, Any]:
|
def initializeFileUploadJobMetadata(self) -> Dict[str, Any]:
|
||||||
metadata = {}
|
metadata = {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue