summaryrefslogtreecommitdiff
path: root/rapid/backupfile.py
diff options
context:
space:
mode:
authorJulien Valroff <julien@kirya.net>2012-01-08 07:54:47 +0100
committerJulien Valroff <julien@kirya.net>2012-01-08 07:54:47 +0100
commitc7b6cc09dc694f8f321c5c7365c1e6ca445291a0 (patch)
treed18525fdc87178ae9e6c497734ed40ea62e41e63 /rapid/backupfile.py
parent1e866ec41146b8c85b874eb09b605538823985a4 (diff)
parent05e7b52a1f94a40996f2619ad9db8bbdb1518497 (diff)
Merge commit 'upstream/0.4.3'
Diffstat (limited to 'rapid/backupfile.py')
-rw-r--r--rapid/backupfile.py24
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