mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[fix] Catch IOError on tar creation (backup).
This commit is contained in:
parent
5027ec0468
commit
286ce86993
2 changed files with 20 additions and 19 deletions
|
@ -185,6 +185,7 @@
|
||||||
"backup_nothings_done" : "There is nothing to save",
|
"backup_nothings_done" : "There is nothing to save",
|
||||||
"backup_cleaning_failed" : "Unable to clean backup temporary directory",
|
"backup_cleaning_failed" : "Unable to clean backup temporary directory",
|
||||||
"backup_complete" : "Backup complete",
|
"backup_complete" : "Backup complete",
|
||||||
|
"backup_failed" : "Backup failed",
|
||||||
"backup_invalid_archive" : "Invalid backup archive",
|
"backup_invalid_archive" : "Invalid backup archive",
|
||||||
"restore_action_required" : "You must specify something to restore",
|
"restore_action_required" : "You must specify something to restore",
|
||||||
"restore_confirm_yunohost_installed" : "Do you really want to restore an already installed system? [{answers:s}]",
|
"restore_confirm_yunohost_installed" : "Do you really want to restore an already installed system? [{answers:s}]",
|
||||||
|
|
|
@ -265,29 +265,29 @@ def backup_create(name=None, description=None, output_directory=None,
|
||||||
if not no_compress:
|
if not no_compress:
|
||||||
logger.info(m18n.n('backup_creating_archive'))
|
logger.info(m18n.n('backup_creating_archive'))
|
||||||
archive_file = "%s/%s.tar.gz" % (output_directory, name)
|
archive_file = "%s/%s.tar.gz" % (output_directory, name)
|
||||||
|
# Create the archives directory
|
||||||
|
if not os.path.isdir(archives_path):
|
||||||
|
os.mkdir(archives_path, 0750)
|
||||||
|
|
||||||
|
# Open archive file for writing
|
||||||
try:
|
try:
|
||||||
tar = tarfile.open(archive_file, "w:gz")
|
tar = tarfile.open(archive_file, "w:gz")
|
||||||
except:
|
except:
|
||||||
tar = None
|
logger.debug("unable to open '%s' for writing",
|
||||||
|
archive_file, exc_info=1)
|
||||||
|
|
||||||
# Create the archives directory and retry
|
_clean_tmp_dir(2)
|
||||||
if not os.path.isdir(archives_path):
|
raise MoulinetteError(errno.EIO,
|
||||||
os.mkdir(archives_path, 0750)
|
m18n.n('backup_archive_open_failed'))
|
||||||
try:
|
|
||||||
tar = tarfile.open(archive_file, "w:gz")
|
# Write into archive
|
||||||
except:
|
try:
|
||||||
logger.debug("unable to open '%s' for writing",
|
tar.add(tmp_dir, arcname='')
|
||||||
archive_file, exc_info=1)
|
tar.close()
|
||||||
tar = None
|
except IOError as e:
|
||||||
else:
|
logger.error(m18n.n('backup_archive_writing_error'), exc_info=1)
|
||||||
logger.debug("unable to open '%s' for writing",
|
_clean_tmp_dir(3)
|
||||||
archive_file, exc_info=1)
|
raise MoulinetteError(errno.EIO, m18n.n('backup_failed'))
|
||||||
if tar is None:
|
|
||||||
_clean_tmp_dir(2)
|
|
||||||
raise MoulinetteError(errno.EIO,
|
|
||||||
m18n.n('backup_archive_open_failed'))
|
|
||||||
tar.add(tmp_dir, arcname='')
|
|
||||||
tar.close()
|
|
||||||
|
|
||||||
# Move info file
|
# Move info file
|
||||||
os.rename(tmp_dir + '/info.json',
|
os.rename(tmp_dir + '/info.json',
|
||||||
|
|
Loading…
Add table
Reference in a new issue