[Pkg-privacy-commits] [tails-installer] 04/08: When download is cancelled, delete the partially downloaded file
Intrigeri
intrigeri at moszumanska.debian.org
Wed May 24 15:27:36 UTC 2017
This is an automated email from the git hooks/post-receive script.
intrigeri pushed a commit to tag 3.93.1
in repository tails-installer.
commit 064f4adc7a80bddb9ec6c78228f40be4db7488cd
Author: Martin Briza <mbriza at redhat.com>
Date: Thu Apr 21 12:02:23 2016 +0200
When download is cancelled, delete the partially downloaded file
---
liveusb/grabber.py | 8 ++++++++
liveusb/gui.py | 4 ++++
2 files changed, 12 insertions(+)
diff --git a/liveusb/grabber.py b/liveusb/grabber.py
index 275fc4b..469c251 100644
--- a/liveusb/grabber.py
+++ b/liveusb/grabber.py
@@ -47,6 +47,14 @@ def chown_file(path):
else:
pass
+def cancel_download(url, target_folder=find_downloads()):
+ file_name = os.path.basename(url)
+ full_path = os.path.join(target_folder, file_name)
+ partial_path = full_path + ".part"
+
+ if os.path.exists(partial_path):
+ os.remove(partial_path)
+
def download(url, target_folder=find_downloads(), update_maximum = None, update_current = None):
CHUNK_SIZE = 1024 * 1024
current_size = 0
diff --git a/liveusb/gui.py b/liveusb/gui.py
index 2a8b204..2796bdd 100755
--- a/liveusb/gui.py
+++ b/liveusb/gui.py
@@ -83,6 +83,10 @@ class ReleaseDownloadThread(QThread):
except LiveUSBError as e:
self.downloadError.emit(e.args[0])
+ def terminate(self):
+ QThread.terminate(self)
+ grabber.cancel_download(self.progress.release.url)
+
class ReleaseDownload(QObject):
""" Wrapper for the iso download process.
It exports properties to track the percentage and the file with the result.
--
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