diff options
author | Julien Valroff <julien@kirya.net> | 2012-01-08 07:54:46 +0100 |
---|---|---|
committer | Julien Valroff <julien@kirya.net> | 2012-01-08 07:54:46 +0100 |
commit | 05e7b52a1f94a40996f2619ad9db8bbdb1518497 (patch) | |
tree | f63dbaaf571e59a139ddf3de2a3103965e8093aa /rapid/backupfile.py | |
parent | da2cce92a7eed706d04d6cbe778fd1bf32f18eeb (diff) |
Imported Upstream version 0.4.3upstream/0.4.3
Diffstat (limited to 'rapid/backupfile.py')
-rw-r--r-- | rapid/backupfile.py | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/rapid/backupfile.py b/rapid/backupfile.py index 40039bc..39efb53 100644 --- a/rapid/backupfile.py +++ b/rapid/backupfile.py @@ -85,7 +85,21 @@ class BackupFiles(multiprocessing.Process): def progress_callback(self, amount_downloaded, total): self.update_progress(amount_downloaded, total) - + def progress_callback_no_update(self, amount_downloaded, total): + """called when copying very small files""" + pass + + def backup_additional_file(self, dest_dir, full_file_name): + """Backs up small files like XMP or THM files""" + source = gio.File(full_file_name) + dest_name = os.path.join(dest_dir, os.path.split(full_file_name)[1]) + logger.debug("Backing up %s", dest_name) + dest=gio.File(dest_name) + try: + source.copy(dest, self.progress_callback_no_update, cancellable=None) + except gio.Error, inst: + logger.error("Failed to backup file %s", full_file_name) + def run(self): self.cancel_copy = gio.Cancellable() @@ -174,6 +188,14 @@ class BackupFiles(multiprocessing.Process): rpd_file.status = config.STATUS_DOWNLOAD_AND_BACKUP_FAILED else: rpd_file.status = config.STATUS_BACKUP_PROBLEM + else: + # backup any THM or XMP files + if rpd_file.download_thm_full_name: + self.backup_additional_file(dest_dir, + rpd_file.download_thm_full_name) + if rpd_file.download_xmp_full_name: + self.backup_additional_file(dest_dir, + rpd_file.download_xmp_full_name) self.total_downloaded += rpd_file.size bytes_not_downloaded = rpd_file.size - self.amount_downloaded |