Skip to content
Snippets Groups Projects
Verified Commit a1fd31ab authored by Davide Gardenal's avatar Davide Gardenal
Browse files

upgrade_oniro: add error handling for restore


Add error handling for restore in case the backup is not found.

Signed-off-by: Davide Gardenal's avatarDavide Gardenal <davide.gardenal@huawei.com>
parent fa17698b
No related branches found
No related tags found
No related merge requests found
...@@ -185,11 +185,16 @@ def restore_oniro(): ...@@ -185,11 +185,16 @@ def restore_oniro():
if backup_archive_arg == "latest": if backup_archive_arg == "latest":
backup_archive_name = find_latest_backup() backup_archive_name = find_latest_backup()
if backup_archive_name is None:
if os.path.exists(backup_archive_arg): print("No backup found, aborting...")
return
elif os.path.exists(backup_archive_arg):
# TODO add a check to be sure that the selected path is actually a Oniro backup # TODO add a check to be sure that the selected path is actually a Oniro backup
backup_archive_name = backup_archive_arg backup_archive_name = backup_archive_arg
else:
print(f"'{backup_archive_arg}' has not been found, aborting...")
return
print(f"Restoring {backup_archive_name}") print(f"Restoring {backup_archive_name}")
with tarfile.open(backup_archive_name) as backup_archive: with tarfile.open(backup_archive_name) as backup_archive:
# Extract the metadata file and delete all the old folders # Extract the metadata file and delete all the old folders
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment