summaryrefslogtreecommitdiff
path: root/rapid/backupfile.py
diff options
context:
space:
mode:
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