mirror of
https://github.com/leminlimez/Nugget.git
synced 2025-04-08 04:23:05 +08:00
new method of checking unsafe containers
This commit is contained in:
@@ -19,7 +19,7 @@ from tweaks.custom_gestalt_tweaks import CustomGestaltTweaks, ValueTypeStrings
|
|||||||
from tweaks.daemons_tweak import Daemon
|
from tweaks.daemons_tweak import Daemon
|
||||||
|
|
||||||
App_Version = "5.0"
|
App_Version = "5.0"
|
||||||
App_Build = 9
|
App_Build = 10
|
||||||
|
|
||||||
class Page(Enum):
|
class Page(Enum):
|
||||||
Home = 0
|
Home = 0
|
||||||
@@ -887,7 +887,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
titleBtn = QtWidgets.QToolButton(widget)
|
titleBtn = QtWidgets.QToolButton(widget)
|
||||||
titleBtn.setIcon(QtGui.QIcon(tendie.get_icon()))
|
titleBtn.setIcon(QtGui.QIcon(tendie.get_icon()))
|
||||||
titleBtn.setIconSize(QtCore.QSize(20, 20))
|
titleBtn.setIconSize(QtCore.QSize(20, 20))
|
||||||
titleBtn.setText(f" {tendie.path}")
|
titleBtn.setText(f" {tendie.name}")
|
||||||
titleBtn.setStyleSheet("QToolButton {\n background-color: transparent;\n icon-size: 20px;\n}")
|
titleBtn.setStyleSheet("QToolButton {\n background-color: transparent;\n icon-size: 20px;\n}")
|
||||||
titleBtn.setToolButtonStyle(QtCore.Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
|
titleBtn.setToolButtonStyle(QtCore.Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
|
||||||
titleBtn.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
|
titleBtn.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
|
||||||
|
|||||||
@@ -12,22 +12,31 @@ from qt.ui_mainwindow import Ui_Nugget
|
|||||||
|
|
||||||
class TendieFile:
|
class TendieFile:
|
||||||
path: str
|
path: str
|
||||||
|
name: str
|
||||||
descriptor_cnt: int
|
descriptor_cnt: int
|
||||||
|
is_container: bool
|
||||||
|
unsafe_container: bool
|
||||||
loaded: bool
|
loaded: bool
|
||||||
|
|
||||||
def __init__(self, path: str):
|
def __init__(self, path: str):
|
||||||
self.path = path
|
self.path = path
|
||||||
|
self.name = os.path.basename(path)
|
||||||
self.descriptor_cnt = 0
|
self.descriptor_cnt = 0
|
||||||
|
self.is_container = False
|
||||||
|
self.unsafe_container = False
|
||||||
self.loaded = False
|
self.loaded = False
|
||||||
|
|
||||||
# read the contents
|
# read the contents
|
||||||
with zipfile.ZipFile(path, mode="r") as archive:
|
with zipfile.ZipFile(path, mode="r") as archive:
|
||||||
for option in archive.namelist():
|
for option in archive.namelist():
|
||||||
if "__macosx/" in option.lower():
|
if "__macosx/" in option.lower():
|
||||||
continue
|
continue
|
||||||
elif "container" in option.lower():
|
if "container" in option.lower():
|
||||||
self.descriptor_cnt = -1
|
self.is_container = True
|
||||||
return
|
# check for the unsafe file that requires prb reset
|
||||||
elif "descriptor/" in option.lower():
|
if "PBFPosterExtensionDataStoreSQLiteDatabase.sqlite3" in option:
|
||||||
|
self.unsafe_container = True
|
||||||
|
if "descriptor/" in option.lower():
|
||||||
item = option.lower().split("descriptor/")[1]
|
item = option.lower().split("descriptor/")[1]
|
||||||
if item.count('/') == 1 and item.endswith('/'):
|
if item.count('/') == 1 and item.endswith('/'):
|
||||||
self.descriptor_cnt += 1
|
self.descriptor_cnt += 1
|
||||||
@@ -37,7 +46,7 @@ class TendieFile:
|
|||||||
self.descriptor_cnt += 1
|
self.descriptor_cnt += 1
|
||||||
|
|
||||||
def get_icon(self):
|
def get_icon(self):
|
||||||
if self.descriptor_cnt == -1:
|
if self.is_container:
|
||||||
# container
|
# container
|
||||||
return ":/icon/shippingbox.svg"
|
return ":/icon/shippingbox.svg"
|
||||||
elif self.descriptor_cnt == 1:
|
elif self.descriptor_cnt == 1:
|
||||||
@@ -60,7 +69,7 @@ class PosterboardTweak(Tweak):
|
|||||||
if new_tendie.descriptor_cnt + self.get_descriptor_count() <= 10:
|
if new_tendie.descriptor_cnt + self.get_descriptor_count() <= 10:
|
||||||
self.tendies.append(new_tendie)
|
self.tendies.append(new_tendie)
|
||||||
# alert if prb reset is needed
|
# alert if prb reset is needed
|
||||||
if new_tendie.descriptor_cnt == -1:
|
if new_tendie.unsafe_container:
|
||||||
detailsBox = QtWidgets.QMessageBox()
|
detailsBox = QtWidgets.QMessageBox()
|
||||||
detailsBox.setIcon(QtWidgets.QMessageBox.Critical)
|
detailsBox.setIcon(QtWidgets.QMessageBox.Critical)
|
||||||
detailsBox.setWindowTitle("Warning")
|
detailsBox.setWindowTitle("Warning")
|
||||||
@@ -72,10 +81,7 @@ class PosterboardTweak(Tweak):
|
|||||||
def get_descriptor_count(self):
|
def get_descriptor_count(self):
|
||||||
cnt = 0
|
cnt = 0
|
||||||
for tendie in self.tendies:
|
for tendie in self.tendies:
|
||||||
if tendie.descriptor_cnt == -1:
|
cnt += tendie.descriptor_cnt
|
||||||
cnt += 1
|
|
||||||
else:
|
|
||||||
cnt += tendie.descriptor_cnt
|
|
||||||
return cnt
|
return cnt
|
||||||
|
|
||||||
def update_plist_id(self, file_path: str, file_name: str, randomizedID: int):
|
def update_plist_id(self, file_path: str, file_name: str, randomizedID: int):
|
||||||
|
|||||||
Reference in New Issue
Block a user