|
|
@ -33,9 +33,9 @@ def create_backup_directory_name(backup_info, time_format="%Y-%m-%d_%H-%M-%S"): |
|
|
return backup_directory_name |
|
|
return backup_directory_name |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def find_backup_data(backup_filepath: Path, backup_info): |
|
|
|
|
|
# find the path of the *.apk, *.properties, and *.tar(.gz) corresponding to backup_filepath |
|
|
|
|
|
backup_root = backup_filepath.parent |
|
|
|
|
|
|
|
|
def find_backup_data(property_file: Path, backup_info): |
|
|
|
|
|
# find the path of the *.apk, *.properties, and *.tar(.gz) corresponding to property_file |
|
|
|
|
|
backup_root = property_file.parent |
|
|
try: |
|
|
try: |
|
|
apk_hash = backup_info["app_apk_md5"] |
|
|
apk_hash = backup_info["app_apk_md5"] |
|
|
apk_file = filter( |
|
|
apk_file = filter( |
|
|
@ -43,7 +43,7 @@ def find_backup_data(backup_filepath: Path, backup_info): |
|
|
) |
|
|
) |
|
|
except KeyError: |
|
|
except KeyError: |
|
|
apk_file = None |
|
|
apk_file = None |
|
|
related_files = list(backup_root.glob(backup_filepath.stem + "*")) |
|
|
|
|
|
|
|
|
related_files = list(backup_root.glob(property_file.stem + "*")) |
|
|
if len(related_files) > 2: |
|
|
if len(related_files) > 2: |
|
|
raise Exception |
|
|
raise Exception |
|
|
tar_file = None |
|
|
tar_file = None |
|
|
@ -51,7 +51,7 @@ def find_backup_data(backup_filepath: Path, backup_info): |
|
|
if ".tar" in filename.name: |
|
|
if ".tar" in filename.name: |
|
|
tar_file = filename |
|
|
tar_file = filename |
|
|
|
|
|
|
|
|
property_file = backup_filepath |
|
|
|
|
|
|
|
|
property_file = property_file |
|
|
return {"property_file": property_file, "apk_file": apk_file, "tar_file": tar_file} |
|
|
return {"property_file": property_file, "apk_file": apk_file, "tar_file": tar_file} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -59,7 +59,7 @@ class Backup: |
|
|
def __init__(self, property_file: Path): |
|
|
def __init__(self, property_file: Path): |
|
|
self.property_file = property_file |
|
|
self.property_file = property_file |
|
|
self.backup_info = read_backup_properties(property_file) |
|
|
self.backup_info = read_backup_properties(property_file) |
|
|
self.related_files = find_backup_data(self.backup_filepath, self.backup_info) |
|
|
|
|
|
|
|
|
self.related_files = find_backup_data(self.property_file, self.backup_info) |
|
|
|
|
|
|
|
|
def hardlink_to(self, dest): |
|
|
def hardlink_to(self, dest): |
|
|
for filepath in self.related_files.values(): |
|
|
for filepath in self.related_files.values(): |
|
|
|