[Pkg-privacy-commits] [tails-installer] 10/13: Don't detect new releases when downloader or writer is already running

Intrigeri intrigeri at moszumanska.debian.org
Wed May 24 15:28:07 UTC 2017


This is an automated email from the git hooks/post-receive script.

intrigeri pushed a commit to tag 3.95.0
in repository tails-installer.

commit 6f9abab583d622dc26375f73c15a5b9575e75f16
Author: Martin Bříza <m at rtinbriza.cz>
Date:   Fri Apr 29 10:44:05 2016 +0200

    Don't detect new releases when downloader or writer is already running
---
 liveusb/components/DownloadDialog.qml |  3 +--
 liveusb/creator.py                    | 16 ++++++++++------
 liveusb/gui.py                        | 10 ++++++++--
 3 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/liveusb/components/DownloadDialog.qml b/liveusb/components/DownloadDialog.qml
index 62be2b6..14cd602 100644
--- a/liveusb/components/DownloadDialog.qml
+++ b/liveusb/components/DownloadDialog.qml
@@ -327,8 +327,7 @@ Dialog {
                                 }
                                 color: liveUSBData.currentImage.writer.finished ? "#628fcf" : "red"
                                 textColor: enabled ? "white" : palette.text
-                                transformOrigin: Item.Center
-                                enabled: (liveUSBData.currentImage.readyToWrite && !liveUSBData.currentImage.writer.running && liveUSBData.usbDrives.length > 0)
+                                enabled: liveUSBData.currentImage.readyToWrite && !liveUSBData.currentImage.writer.running && liveUSBData.usbDrives.length > 0
                                 text: liveUSBData.currentImage.writer.finished ? qsTranslate("", "Close") : qsTranslate("", "Write to disk")
                                 onClicked: {
                                     if (liveUSBData.currentImage.writer.finished) {
diff --git a/liveusb/creator.py b/liveusb/creator.py
index 3132c1a..b9fabac 100755
--- a/liveusb/creator.py
+++ b/liveusb/creator.py
@@ -622,21 +622,19 @@ class WindowsLiveUSBCreator(LiveUSBCreator):
         import re
 
         if update_function:
-            update_function(-1.0)
+            update_function(float("NaN"))
 
         for i in self.drive.mount:
             mountvol = subprocess.Popen(['mountvol', i, '/d'], shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
             mountvol.wait()
 
         diskpart = subprocess.Popen(['diskpart'], shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-        diskpart.communicate('select disk '+self.drive.device+'\r\nclean\r\nexit\r\n')
+        diskpart.communicate('select disk '+self.drive.device+'\nclean\nexit\n')
         diskpart.wait()
         if diskpart.returncode != 0:
             self.log('Diskpart exited with a nonzero status')
             return
 
-        if update_function:
-            update_function(0.0)
         dd = subprocess.Popen([(os.path.dirname(sys.argv[0]) if len(os.path.dirname(sys.argv[0])) else os.path.dirname(os.path.realpath(__file__))+'/..')+'/tools/dd.exe',
                                'bs=1M',
                                'if='+self.iso,
@@ -654,16 +652,22 @@ class WindowsLiveUSBCreator(LiveUSBCreator):
                 #buf = dd.stdout.read(256)
                 r = re.search('^([,0-9]+)', buf)
                 if r and len(r.groups()) > 0 and len(r.group(0)) > 0:
-                    update_function(float(r.group(0).replace(',', '')) / self.isosize)
+                    ratio = float(float(r.group(0).replace(',', '')) / self.isosize)
+                    if ratio >= 0.0 and ratio <= 1.0:
+                        update_function(ratio)
         else:
             dd.wait()
 
+        if update_function:
+            update_function(1.0)
+
+
     def restore_drive(self, d, callback):
 
         def restore_drive_work(callback, device):
             import threading
             diskpart = subprocess.Popen(['diskpart'], shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-            diskpart.communicate('select disk '+self.drive.device+'\r\nclean\r\ncreate part pri\r\nselect part 1\r\nformat fs=fat32 quick\r\nassign\r\nexit\r\n')
+            diskpart.communicate('select disk '+self.drive.device+'\nclean\ncreate part pri\nselect part 1\nformat fs=fat32 quick\nassign\nexit\n')
             diskpart.wait()
             callback(True)
 
diff --git a/liveusb/gui.py b/liveusb/gui.py
index 79f060b..b282252 100755
--- a/liveusb/gui.py
+++ b/liveusb/gui.py
@@ -476,7 +476,7 @@ class Release(QObject):
 
     @pyqtProperty(str, notify=statusChanged)
     def status(self):
-        if not self._download.running and not self.readyToWrite and not self._writer.running and len(self._error) == 0:
+        if not self.writer.finished and not self._download.running and not self.readyToWrite and not self._writer.running and len(self._error) == 0:
             return _('Starting')
         elif self._download.running:
             return _('Downloading')
@@ -687,6 +687,8 @@ class LiveUSBData(QObject):
     _currentIndex = 0
     _currentDrive = 0
 
+    releaseData = []
+
     def __init__(self, opts):
         QObject.__init__(self)
         self.live = LiveUSBCreator(opts=opts)
@@ -706,8 +708,11 @@ class LiveUSBData(QObject):
 
     @pyqtSlot()
     def fillReleases(self):
+        if self.releaseData and self.releaseData[self.currentIndex]:
+            if self.releaseData[self.currentIndex].download.running or self.releaseData[self.currentIndex].writer.running:
+                return
+
         self.releaseModel.beginResetModel()
-        self.releaseData = []
 
         for release in releases:
             self.releaseData.append(Release(self,
@@ -718,6 +723,7 @@ class LiveUSBData(QObject):
 
         self.releaseModel.endResetModel()
         self.releaseProxyModel.invalidate()
+        self.currentImageChanged.emit()
 
     def USBDeviceCallback(self):
         tmpDrives = []

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/tails-installer.git



More information about the Pkg-privacy-commits mailing list