fix windows FileNotFound error fr this time :trollface:

This commit is contained in:
leminlimez
2025-03-31 12:31:22 -04:00
parent ad2685f3e0
commit ee3d1396ec
5 changed files with 22 additions and 18 deletions

View File

@@ -0,0 +1,12 @@
import os
def fix_windows_path(dos_path: str, encoding=None):
if os.name == 'nt':
if (not isinstance(dos_path, str) and encoding is not None):
dos_path = dos_path.decode(encoding)
path = os.path.abspath(dos_path)
if path.startswith(u"\\\\"):
return u"\\\\?\\UNC\\" + path[2:]
return u"\\\\?\\" + path
else:
return dos_path

View File

@@ -12,6 +12,8 @@ from pymobiledevice3.exceptions import MuxException, PasswordRequiredError
from devicemanagement.constants import Device, Version
from devicemanagement.data_singleton import DataSingleton
from controllers.path_handler import fix_windows_path
from tweaks.tweaks import tweaks, FeatureFlagTweak, EligibilityTweak, AITweak, BasicPlistTweak, AdvancedPlistTweak, RdarFixTweak, NullifyFileTweak
from tweaks.custom_gestalt_tweaks import CustomGestaltTweaks
from tweaks.posterboard_tweak import PosterboardTweak
@@ -331,7 +333,7 @@ class DeviceManager:
elif isinstance(tweak, PosterboardTweak):
tmp_pb_dir = TemporaryDirectory()
tweak.apply_tweak(
files_to_restore=files_to_restore, output_dir=tmp_pb_dir.name,
files_to_restore=files_to_restore, output_dir=fix_windows_path(tmp_pb_dir.name),
version=self.get_current_device_version()
)
if tweak.enabled:
@@ -437,9 +439,9 @@ class DeviceManager:
if tmp_pb_dir != None:
try:
tmp_pb_dir.cleanup()
except Exception as e:
except Exception as e2:
# ignore clean up errors
print(str(e))
print(str(e2))
show_apply_error(e, update_label)
## RESETTING MOBILE GESTALT

View File

@@ -20,7 +20,7 @@ from tweaks.custom_gestalt_tweaks import CustomGestaltTweaks, ValueTypeStrings
from tweaks.daemons_tweak import Daemon
App_Version = "5.0.3"
App_Build = 1
App_Build = 0
class Page(Enum):
Home = 0

View File

@@ -1,4 +1,3 @@
pymobiledevice3
PySide6-Essentials
PyInstaller
rarfile
PyInstaller

View File

@@ -1,6 +1,5 @@
import os
import zipfile
import rarfile
import uuid
import re
from random import randint
@@ -9,6 +8,7 @@ from PySide6 import QtWidgets, QtCore, QtGui
from .tweak_classes import Tweak
from Sparserestore.restore import FileToRestore
from controllers.plist_handler import set_plist_value
from controllers.path_handler import fix_windows_path
from qt.ui_mainwindow import Ui_Nugget
class TendieFile:
@@ -183,16 +183,7 @@ class PosterboardTweak(Tweak):
for tendie in self.tendies:
zip_output = os.path.join(output_dir, str(uuid.uuid4()))
os.makedirs(zip_output)
if os == 'nt':
rar_archive = rarfile.RarFile(tendie.path)
try:
# Extract the contents to the target directory
rar_archive.extractall(path=zip_output)
finally:
# Close the RAR file to release resources
rar_archive.close()
else:
with zipfile.ZipFile(tendie.path, 'r') as zip_ref:
zip_ref.extractall(zip_output)
with zipfile.ZipFile(tendie.path, 'r') as zip_ref:
zip_ref.extractall(zip_output)
# add the files
self.recursive_add(files_to_restore, curr_path=output_dir)