Merge pull request #655 from kay0u/patch-4

[enh] Ensure the tar file is closed during the backup
This commit is contained in:
Alexandre Aubin 2019-02-21 14:28:07 +01:00 committed by GitHub
commit 7e37833347
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View file

@ -75,7 +75,7 @@
"backup_archive_name_unknown": "Unknown local backup archive named '{name:s}'",
"backup_archive_open_failed": "Unable to open the backup archive",
"backup_archive_system_part_not_available": "System part '{part:s}' not available in this backup",
"backup_archive_writing_error": "Unable to add files to backup into the compressed archive",
"backup_archive_writing_error": "Unable to add files '{source:s}' (named in the archive: '{dest:s}') to backup into the compressed archive '{archive:s}'",
"backup_ask_for_copying_if_needed": "Some files couldn't be prepared to be backuped using the method that avoid to temporarily waste space on the system. To perform the backup, {size:s}MB should be used temporarily. Do you agree?",
"backup_borg_not_implemented": "Borg backup method is not yet implemented",
"backup_cant_mount_uncompress_archive": "Unable to mount in readonly mode the uncompress archive directory",

View file

@ -1802,10 +1802,11 @@ class TarBackupMethod(BackupMethod):
# Add the "source" into the archive and transform the path into
# "dest"
tar.add(path['source'], arcname=path['dest'])
tar.close()
except IOError:
logger.error(m18n.n('backup_archive_writing_error'), exc_info=1)
logger.error(m18n.n('backup_archive_writing_error', source=path['source'], archive=self._archive_file, dest=path['dest']), exc_info=1)
raise YunohostError('backup_creation_failed')
finally:
tar.close()
# Move info file
shutil.copy(os.path.join(self.work_dir, 'info.json'),