Просмотр исходного кода

Provess some code review comments

CURA-6983
Nino van Hooff 5 лет назад
Родитель
Сommit
15dc866cbe

+ 4 - 2
plugins/Toolbox/src/CloudSync/DownloadPresenter.py

@@ -19,6 +19,8 @@ from plugins.Toolbox.src.CloudSync.SubscribedPackagesModel import SubscribedPack
 # use download() exactly once: should not be used for multiple sets of downloads since this class contains state
 class DownloadPresenter:
 
+    DISK_WRITE_BUFFER_SIZE = 256 * 1024  # 256 KB
+
     def __init__(self, app: CuraApplication):
         # Emits (Dict[str, str], List[str]) # (success_items, error_items)
         # Dict{success_package_id, temp_file_path}
@@ -93,10 +95,10 @@ class DownloadPresenter:
 
         try:
             with tempfile.NamedTemporaryFile(mode ="wb+", suffix =".curapackage", delete = False) as temp_file:
-                bytes_read = reply.read(256 * 1024)
+                bytes_read = reply.read(self.DISK_WRITE_BUFFER_SIZE)
                 while bytes_read:
                     temp_file.write(bytes_read)
-                    bytes_read = reply.read(256 * 1024)
+                    bytes_read = reply.read(self.DISK_WRITE_BUFFER_SIZE)
                     self._app.processEvents()
                 self._progress[package_id]["file_written"] = temp_file.name
         except IOError as e:

+ 7 - 7
plugins/Toolbox/src/CloudSync/SyncOrchestrator.py

@@ -24,10 +24,10 @@ from plugins.Toolbox.src.CloudSync.SubscribedPackagesModel import SubscribedPack
 # - The SyncOrchestrator uses PackageManager to remove local packages the users wants to see removed
 # - The DownloadPresenter shows a download progress dialog. It emits A tuple of succeeded and failed downloads
 # - The LicensePresenter extracts licenses from the downloaded packages and presents a license for each package to
-#   be installed. It emits the `licenseAnswers` {'packageId' : bool} for accept or declines
+#   be installed. It emits the `licenseAnswers` signal for accept or declines
 # - The CloudPackageManager removes the declined packages from the account
-# - The SyncOrchestrator uses PackageManager to install the downloaded packages.
-# - Bliss / profit / done
+# - The SyncOrchestrator uses PackageManager to install the downloaded packages and delete temp files.
+# - The RestartApplicationPresenter notifies the user that a restart is required for changes to take effect
 class SyncOrchestrator(Extension):
 
     def __init__(self, app: CuraApplication):
@@ -45,7 +45,7 @@ class SyncOrchestrator(Extension):
         self._discrepancies_presenter = DiscrepanciesPresenter(app)  # type: DiscrepanciesPresenter
         self._discrepancies_presenter.packageMutations.connect(self._onPackageMutations)
 
-        self._download_Presenter = DownloadPresenter(app)  # type: DownloadPresenter
+        self._download_presenter = DownloadPresenter(app)  # type: DownloadPresenter
 
         self._license_presenter = LicensePresenter(app)  # type: LicensePresenter
         self._license_presenter.licenseAnswers.connect(self._onLicenseAnswers)
@@ -57,9 +57,9 @@ class SyncOrchestrator(Extension):
         self._discrepancies_presenter.present(plugin_path, model)
 
     def _onPackageMutations(self, mutations: SubscribedPackagesModel):
-        self._download_Presenter = self._download_Presenter.resetCopy()
-        self._download_Presenter.done.connect(self._onDownloadFinished)
-        self._download_Presenter.download(mutations)
+        self._download_presenter = self._download_presenter.resetCopy()
+        self._download_presenter.done.connect(self._onDownloadFinished)
+        self._download_presenter.download(mutations)
 
     ## Called when a set of packages have finished downloading
     # \param success_items: Dict[package_id, file_path]