mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-17 03:09:40 +08:00
Adjust code to review comments.
- Use delete-on-close instead. - Prevent infinite loops. part of CURA-12156
This commit is contained in:
parent
1fb89e0e7d
commit
14bf34d96a
@ -114,7 +114,7 @@ class Backup:
|
||||
data["installed"] = keep_in
|
||||
data["to_install"].update(reinstall)
|
||||
if data is not None:
|
||||
tmpfile = tempfile.NamedTemporaryFile(delete=False)
|
||||
tmpfile = tempfile.NamedTemporaryFile(delete_on_close=False)
|
||||
with open(tmpfile.name, "w") as outfile:
|
||||
json.dump(data, outfile)
|
||||
add_to_archive(tmpfile.name, file_path)
|
||||
|
@ -99,10 +99,10 @@ class CreateBackupJob(Job):
|
||||
self._requestUploadSlot(backup_meta_data, len(self._backup_zip))
|
||||
|
||||
# Note: One 'process events' call wasn't enough with the changed situation somehow.
|
||||
active_done_check = False
|
||||
while not active_done_check:
|
||||
for _ in range(5000):
|
||||
CuraApplication.getInstance().processEvents()
|
||||
active_done_check = self._job_done.wait(0.02)
|
||||
if self._job_done.wait(0.02):
|
||||
break
|
||||
|
||||
if self.backup_upload_error_message == "":
|
||||
self._upload_message.setText(catalog.i18nc("@info:backup_status", "Your backup has finished uploading."))
|
||||
|
@ -56,10 +56,10 @@ class RestoreBackupJob(Job):
|
||||
)
|
||||
|
||||
# Note: Just to be sure, use the same structure here as in CreateBackupJob.
|
||||
active_done_check = False
|
||||
while not active_done_check:
|
||||
for _ in range(5000):
|
||||
CuraApplication.getInstance().processEvents()
|
||||
active_done_check = self._job_done.wait(0.02)
|
||||
if self._job_done.wait(0.02):
|
||||
break
|
||||
|
||||
def _onRestoreRequestCompleted(self, reply: QNetworkReply, error: Optional["QNetworkReply.NetworkError"] = None) -> None:
|
||||
if not HttpRequestManager.replyIndicatesSuccess(reply, error):
|
||||
@ -71,7 +71,7 @@ class RestoreBackupJob(Job):
|
||||
|
||||
# We store the file in a temporary path fist to ensure integrity.
|
||||
try:
|
||||
self._temporary_backup_file = NamedTemporaryFile(delete = False)
|
||||
self._temporary_backup_file = NamedTemporaryFile(delete_on_close = False)
|
||||
with open(self._temporary_backup_file.name, "wb") as write_backup:
|
||||
app = CuraApplication.getInstance()
|
||||
bytes_read = reply.read(self.DISK_WRITE_BUFFER_SIZE)
|
||||
|
Loading…
x
Reference in New Issue
Block a user