|
|
|
@ -36,18 +36,23 @@ def create_backup_directory_name(backup_info, time_format="%Y-%m-%d_%H-%M-%S"): |
|
|
|
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 |
|
|
|
apk_hash = backup_info["app_apk_md5"] |
|
|
|
apk_file = filter( |
|
|
|
lambda apk_file: apk_hash in apk_file.name, backup_root.glob("*.apk*") |
|
|
|
) |
|
|
|
try: |
|
|
|
apk_hash = backup_info["app_apk_md5"] |
|
|
|
apk_file = filter( |
|
|
|
lambda apk_file: apk_hash in apk_file.name, backup_root.glob("*.apk*") |
|
|
|
) |
|
|
|
except KeyError: |
|
|
|
apk_file = None |
|
|
|
related_files = list(backup_root.glob(backup_filepath.stem + "*")) |
|
|
|
if len(related_files) > 2: |
|
|
|
raise Exception |
|
|
|
tar_file = None |
|
|
|
for filename in related_files: |
|
|
|
if ".tar" in filename.name: |
|
|
|
tar_file = filename |
|
|
|
|
|
|
|
property_file = backup_filepath |
|
|
|
return property_file, apk_file, tar_file |
|
|
|
return {"property_file": property_file, "apk_file": apk_file, "tar_file": tar_file} |
|
|
|
|
|
|
|
|
|
|
|
class Backup: |
|
|
|
@ -57,5 +62,6 @@ class Backup: |
|
|
|
self.related_files = find_backup_data(self.backup_filepath, self.backup_info) |
|
|
|
|
|
|
|
def hardlink_to(self, dest): |
|
|
|
for filepath in self.related_files: |
|
|
|
filepath.link_to(dest) |
|
|
|
for filepath in self.related_files.values(): |
|
|
|
if filepath: |
|
|
|
filepath.link_to(dest) |