diff options
author | Julien Valroff <julien@kirya.net> | 2011-04-16 16:39:17 +0200 |
---|---|---|
committer | Julien Valroff <julien@kirya.net> | 2011-04-16 16:39:17 +0200 |
commit | 5539b9c5aa11891c66104fe51ebb5e9b4ad31538 (patch) | |
tree | a08efd10faf1ac622a62e29d17da6d4f1f0aeac3 /rapid/copyfiles.py | |
parent | 07934178861343ee213674120db367b8faeef1be (diff) | |
parent | 75b28642dd41fb4a7925b42cb24274de90a4f52c (diff) |
Merge commit 'upstream/0.4.0_beta1' into experimental
Diffstat (limited to 'rapid/copyfiles.py')
-rw-r--r-- | rapid/copyfiles.py | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/rapid/copyfiles.py b/rapid/copyfiles.py index 78fe8a3..08daafe 100644 --- a/rapid/copyfiles.py +++ b/rapid/copyfiles.py @@ -30,6 +30,7 @@ import rpdmultiprocessing as rpdmp import rpdfile import problemnotification as pn import config +import thumbnail as tn from gettext import gettext as _ @@ -37,7 +38,7 @@ from gettext import gettext as _ class CopyFiles(multiprocessing.Process): def __init__(self, photo_download_folder, video_download_folder, files, - scan_pid, + generate_thumbnails, scan_pid, batch_size_MB, results_pipe, terminate_queue, run_event): multiprocessing.Process.__init__(self) @@ -47,6 +48,7 @@ class CopyFiles(multiprocessing.Process): self.photo_download_folder = photo_download_folder self.video_download_folder = video_download_folder self.files = files + self.generate_thumbnails = generate_thumbnails self.scan_pid = scan_pid self.no_files= len(self.files) self.run_event = run_event @@ -69,17 +71,17 @@ class CopyFiles(multiprocessing.Process): # it is - cancel the current copy self.cancel_copy.cancel() else: - if (amount_downloaded - self.bytes_downloaded > self.batch_size_bytes) or (amount_downloaded == total): - chunk_downloaded = amount_downloaded - self.bytes_downloaded + chunk_downloaded = amount_downloaded - self.bytes_downloaded + if (chunk_downloaded > self.batch_size_bytes) or (amount_downloaded == total): self.bytes_downloaded = amount_downloaded - self.results_pipe.send((rpdmp.CONN_PARTIAL, (rpdmp.MSG_BYTES, (self.scan_pid, self.total_downloaded + amount_downloaded)))) + if amount_downloaded == total: + # this function is called a couple of times when total is reached + chunk_downloaded = 0 + self.results_pipe.send((rpdmp.CONN_PARTIAL, (rpdmp.MSG_BYTES, (self.scan_pid, self.total_downloaded + amount_downloaded, chunk_downloaded)))) + if amount_downloaded == total: + self.bytes_downloaded = 0 def progress_callback(self, amount_downloaded, total): - - #~ if self.check_termination_request(): - #~ # FIXME: cancel copy - #~ pass - self.update_progress(amount_downloaded, total) @@ -102,6 +104,10 @@ class CopyFiles(multiprocessing.Process): self.video_temp_dir)))) if self.photo_temp_dir or self.video_temp_dir: + + if self.generate_thumbnails: + self.thumbnail_maker = tn.Thumbnail() + for i in range(len(self.files)): rpd_file = self.files[i] @@ -145,6 +151,15 @@ class CopyFiles(multiprocessing.Process): # succeeded or not. It's neccessary to keep the user informed. self.total_downloaded += rpd_file.size + if copy_succeeded and self.generate_thumbnails: + thumbnail, thumbnail_icon = self.thumbnail_maker.get_thumbnail( + temp_full_file_name, + rpd_file.file_type, + (160, 120), (100,100)) + self.results_pipe.send((rpdmp.CONN_PARTIAL, + (rpdmp.MSG_THUMB, (rpd_file.unique_id, + thumbnail_icon, thumbnail)))) + if rpd_file.metadata is not None: rpd_file.metadata = None |