fix2222
This commit is contained in:
@@ -36,11 +36,12 @@ class MainWindow(QMainWindow):
|
||||
|
||||
# 初始化管理器和操作类
|
||||
self.system_manager = SystemInfoManager()
|
||||
self.lvm_ops = LvmOperations() # <--- 先初始化 LvmOperations
|
||||
# <--- 将 lvm_ops 实例传递给 DiskOperations
|
||||
self.disk_ops = DiskOperations(self.system_manager, self.lvm_ops)
|
||||
self.raid_ops = RaidOperations()
|
||||
# self.lvm_ops = LvmOperations() # 这一行是重复的,可以删除
|
||||
# Correct order for dependency injection:
|
||||
self.lvm_ops = LvmOperations() # Initialize LVM first
|
||||
self.disk_ops = DiskOperations(self.system_manager, self.lvm_ops) # DiskOperations needs system_manager and lvm_ops
|
||||
self.lvm_ops.disk_ops = self.disk_ops # Inject disk_ops into lvm_ops
|
||||
self.raid_ops = RaidOperations(self.system_manager, self.disk_ops) # RaidOperations needs system_manager and disk_ops
|
||||
|
||||
|
||||
# 连接刷新按钮的信号到槽函数
|
||||
if hasattr(self.ui, 'refreshButton'):
|
||||
@@ -188,6 +189,11 @@ class MainWindow(QMainWindow):
|
||||
"""
|
||||
处理擦除物理盘分区表的操作。
|
||||
"""
|
||||
# NEW: 尝试解决磁盘占用问题
|
||||
if not self.disk_ops._resolve_device_occupation(device_path, action_description=f"擦除 {device_path} 上的分区表"):
|
||||
logger.info(f"用户取消或未能解决磁盘 {device_path} 的占用问题,取消擦除分区表。")
|
||||
return
|
||||
|
||||
reply = QMessageBox.question(
|
||||
self,
|
||||
"确认擦除分区表",
|
||||
@@ -455,7 +461,7 @@ class MainWindow(QMainWindow):
|
||||
|
||||
array_uuid = array_data.get('uuid')
|
||||
if not array_uuid or array_uuid == 'N/A':
|
||||
QMessageBox.critical(self, "错误", f"无法激活 RAID 阵列 {array_path}:缺少 UUID 信息。")
|
||||
QMessageBox.critical(None, "错误", f"无法激活 RAID 阵列 {array_path}:缺少 UUID 信息。")
|
||||
logger.error(f"激活 RAID 阵列 {array_path} 失败:缺少 UUID。")
|
||||
return
|
||||
|
||||
@@ -494,7 +500,7 @@ class MainWindow(QMainWindow):
|
||||
|
||||
def _handle_delete_active_raid_array(self, array_path, member_devices, uuid): # <--- 修改方法名并添加 uuid 参数
|
||||
"""
|
||||
处理删除活动 RAID 阵列的操作。
|
||||
处理删除一个活动的 RAID 阵列的操作。
|
||||
"""
|
||||
if self.raid_ops.delete_active_raid_array(array_path, member_devices, uuid): # <--- 调用修改后的方法
|
||||
self.refresh_all_info()
|
||||
@@ -850,4 +856,3 @@ if __name__ == "__main__":
|
||||
widget = MainWindow()
|
||||
widget.show()
|
||||
sys.exit(app.exec())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user