mirror of
https://github.com/leminlimez/Nugget.git
synced 2025-04-08 04:23:05 +08:00
depricate old FileToRestore
This commit is contained in:
@@ -3,19 +3,9 @@ from pymobiledevice3.lockdown import LockdownClient
|
||||
import os
|
||||
|
||||
class FileToRestore:
|
||||
# TODO: Depricate this in favor of second init definition
|
||||
def __init__(self, contents: str, restore_path: str, restore_name: str, owner: int = 501, group: int = 501):
|
||||
self.contents = contents
|
||||
self.restore_path = restore_path
|
||||
self.restore_name = restore_name
|
||||
self.owner = owner
|
||||
self.group = group
|
||||
|
||||
def __init__(self, contents: str, restore_path: str, owner: int = 501, group: int = 501):
|
||||
self.contents = contents
|
||||
path, file = os.path.split(restore_path)
|
||||
self.restore_path = path + "/"
|
||||
self.restore_name = file # TODO: Remove this and handle splitting in the restore_files function
|
||||
self.restore_path = restore_path
|
||||
self.owner = owner
|
||||
self.group = group
|
||||
|
||||
@@ -52,7 +42,8 @@ def restore_files(files: list, reboot: bool = False, lockdown_client: LockdownCl
|
||||
elif file.restore_path.startswith("/private/var/"):
|
||||
base_path = "/private/var/backup"
|
||||
# don't append the directory if it has already been added (restore will fail)
|
||||
domain_path = f"SysContainerDomain-../../../../../../../..{base_path}{file.restore_path}"
|
||||
path, name = os.path.split(file.restore_path)
|
||||
domain_path = f"SysContainerDomain-../../../../../../../..{base_path}{path}"
|
||||
if last_domain != domain_path:
|
||||
files_list.append(backup.Directory(
|
||||
"",
|
||||
@@ -63,7 +54,7 @@ def restore_files(files: list, reboot: bool = False, lockdown_client: LockdownCl
|
||||
last_domain = domain_path
|
||||
files_list.append(backup.ConcreteFile(
|
||||
"",
|
||||
f"{domain_path}{file.restore_name}",
|
||||
f"{domain_path}{name}",
|
||||
owner=file.owner,
|
||||
group=file.group,
|
||||
contents=b"",
|
||||
|
||||
@@ -135,13 +135,11 @@ while running:
|
||||
files_to_restore = [
|
||||
FileToRestore(
|
||||
contents=plistlib.dumps(gestalt_plist),
|
||||
restore_path="/var/containers/Shared/SystemGroup/systemgroup.com.apple.mobilegestaltcache/Library/Caches/",
|
||||
restore_name="com.apple.MobileGestalt.plist"
|
||||
restore_path="/var/containers/Shared/SystemGroup/systemgroup.com.apple.mobilegestaltcache/Library/Caches/com.apple.MobileGestalt.plist",
|
||||
),
|
||||
FileToRestore(
|
||||
contents=plistlib.dumps(flag_plist),
|
||||
restore_path="/var/preferences/FeatureFlags/",
|
||||
restore_name="Global.plist"
|
||||
restore_path="/var/preferences/FeatureFlags/Global.plist",
|
||||
)
|
||||
]
|
||||
if eligibility_files != None:
|
||||
@@ -175,8 +173,7 @@ while running:
|
||||
try:
|
||||
restore_files(files=[FileToRestore(
|
||||
contents=b"",
|
||||
restore_path="/var/containers/Shared/SystemGroup/systemgroup.com.apple.mobilegestaltcache/Library/Caches/",
|
||||
restore_name="com.apple.MobileGestalt.plist"
|
||||
restore_path="/var/containers/Shared/SystemGroup/systemgroup.com.apple.mobilegestaltcache/Library/Caches/com.apple.MobileGestalt.plist",
|
||||
)], reboot=True, lockdown_client=device.ld)
|
||||
except Exception as e:
|
||||
print(traceback.format_exc())
|
||||
|
||||
@@ -143,15 +143,13 @@ class DeviceManager:
|
||||
files_to_restore = [
|
||||
FileToRestore(
|
||||
contents=plistlib.dumps(flag_plist),
|
||||
restore_path="/var/preferences/FeatureFlags/",
|
||||
restore_name="Global.plist"
|
||||
restore_path="/var/preferences/FeatureFlags/Global.plist",
|
||||
)
|
||||
]
|
||||
if gestalt_data != None:
|
||||
files_to_restore.append(FileToRestore(
|
||||
contents=gestalt_data,
|
||||
restore_path="/var/containers/Shared/SystemGroup/systemgroup.com.apple.mobilegestaltcache/Library/Caches/",
|
||||
restore_name="com.apple.MobileGestalt.plist"
|
||||
restore_path="/var/containers/Shared/SystemGroup/systemgroup.com.apple.mobilegestaltcache/Library/Caches/com.apple.MobileGestalt.plist",
|
||||
))
|
||||
if eligibility_files:
|
||||
files_to_restore += eligibility_files
|
||||
@@ -197,8 +195,7 @@ class DeviceManager:
|
||||
try:
|
||||
restore_files(files=[FileToRestore(
|
||||
contents=b"",
|
||||
restore_path="/var/containers/Shared/SystemGroup/systemgroup.com.apple.mobilegestaltcache/Library/Caches/",
|
||||
restore_name="com.apple.MobileGestalt.plist"
|
||||
restore_path="/var/containers/Shared/SystemGroup/systemgroup.com.apple.mobilegestaltcache/Library/Caches/com.apple.MobileGestalt.plist",
|
||||
)], reboot=True, lockdown_client=self.data_singleton.current_device.ld)
|
||||
QMessageBox.information(None, "Success!", "All done! Your device will now restart.")
|
||||
update_label("Success!")
|
||||
|
||||
@@ -62,8 +62,7 @@ class EligibilityTweak(Tweak):
|
||||
files_to_restore = [
|
||||
FileToRestore(
|
||||
contents=eligibility_data,
|
||||
restore_path="/var/db/os_eligibility/",
|
||||
restore_name="eligibility.plist"
|
||||
restore_path="/var/db/os_eligibility/eligibility.plist",
|
||||
)
|
||||
]
|
||||
|
||||
@@ -74,16 +73,14 @@ class EligibilityTweak(Tweak):
|
||||
files_to_restore.append(
|
||||
FileToRestore(
|
||||
contents=config_data,
|
||||
restore_path="/var/MobileAsset/AssetsV2/com_apple_MobileAsset_OSEligibility/purpose_auto/c55a421c053e10233e5bfc15c42fa6230e5639a9.asset/AssetData/",
|
||||
restore_name="Config.plist"
|
||||
restore_path="/var/MobileAsset/AssetsV2/com_apple_MobileAsset_OSEligibility/purpose_auto/c55a421c053e10233e5bfc15c42fa6230e5639a9.asset/AssetData/Config.plist",
|
||||
)
|
||||
)
|
||||
elif self.method == 1:
|
||||
files_to_restore.append(
|
||||
FileToRestore(
|
||||
contents=config_data,
|
||||
restore_path="/var/MobileAsset/AssetsV2/com_apple_MobileAsset_OSEligibility/purpose_auto/247556c634fc4cc4fd742f1b33af9abf194a986e.asset/AssetData/",
|
||||
restore_name="Config.plist"
|
||||
restore_path="/var/MobileAsset/AssetsV2/com_apple_MobileAsset_OSEligibility/purpose_auto/247556c634fc4cc4fd742f1b33af9abf194a986e.asset/AssetData/Config.plist",
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user