add ntfsfix
This commit is contained in:
@@ -190,26 +190,48 @@ class DiskOperations:
|
||||
logger.info(f"尝试挂载设备 {device_path} 到 {mount_point}。")
|
||||
success, _, stderr = self._execute_shell_command(
|
||||
["mount", device_path, mount_point],
|
||||
f"挂载设备 {device_path} 失败"
|
||||
f"挂载设备 {device_path} 失败",
|
||||
show_dialog=False
|
||||
)
|
||||
if success:
|
||||
messagebox.showinfo("成功", f"设备 {device_path} 已成功挂载到 {mount_point}。")
|
||||
if add_to_fstab:
|
||||
device_details = self.system_manager.get_device_details_by_path(device_path)
|
||||
if device_details:
|
||||
fstype = device_details.get('fstype')
|
||||
uuid = device_details.get('uuid')
|
||||
if fstype and uuid:
|
||||
self._add_to_fstab(device_path, mount_point, fstype, uuid)
|
||||
else:
|
||||
logger.error(f"无法获取设备 {device_path} 的文件系统类型或 UUID 以添加到 fstab。")
|
||||
messagebox.showwarning("警告", f"设备 {device_path} 已挂载,但无法获取文件系统类型或 UUID 以添加到 fstab。")
|
||||
|
||||
# 如果普通挂载失败,检查是否是 NTFS 并尝试使用 ntfs-3g
|
||||
if not success:
|
||||
device_details = self.system_manager.get_device_details_by_path(device_path)
|
||||
fstype = device_details.get('fstype', '').lower() if device_details else ''
|
||||
|
||||
if fstype == 'ntfs' or 'ntfs' in stderr.lower():
|
||||
logger.info(f"尝试使用 ntfs-3g 挂载设备 {device_path}。")
|
||||
success, _, stderr = self._execute_shell_command(
|
||||
["mount", "-t", "ntfs-3g", device_path, mount_point],
|
||||
f"使用 ntfs-3g 挂载设备 {device_path} 失败"
|
||||
)
|
||||
if success:
|
||||
messagebox.showinfo("成功", f"设备 {device_path} 已通过 ntfs-3g 成功挂载到 {mount_point}。")
|
||||
else:
|
||||
logger.error(f"无法获取设备 {device_path} 的详细信息以添加到 fstab。")
|
||||
messagebox.showwarning("警告", f"设备 {device_path} 已挂载,但无法获取详细信息以添加到 fstab。")
|
||||
return True
|
||||
messagebox.showerror("错误", f"挂载设备 {device_path} 失败。\n\n"
|
||||
f"普通挂载和 ntfs-3g 挂载均失败。\n"
|
||||
f"如果是 NTFS 文件系统损坏,请先使用文件系统工具中的 "修复文件系统 (ntfsfix)" 修复。")
|
||||
return False
|
||||
else:
|
||||
messagebox.showerror("错误", f"挂载设备 {device_path} 失败: {stderr}")
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
messagebox.showinfo("成功", f"设备 {device_path} 已成功挂载到 {mount_point}。")
|
||||
|
||||
if success and add_to_fstab:
|
||||
device_details = self.system_manager.get_device_details_by_path(device_path)
|
||||
if device_details:
|
||||
fstype = device_details.get('fstype')
|
||||
uuid = device_details.get('uuid')
|
||||
if fstype and uuid:
|
||||
self._add_to_fstab(device_path, mount_point, fstype, uuid)
|
||||
else:
|
||||
logger.error(f"无法获取设备 {device_path} 的文件系统类型或 UUID 以添加到 fstab。")
|
||||
messagebox.showwarning("警告", f"设备 {device_path} 已挂载,但无法获取文件系统类型或 UUID 以添加到 fstab。")
|
||||
else:
|
||||
logger.error(f"无法获取设备 {device_path} 的详细信息以添加到 fstab。")
|
||||
messagebox.showwarning("警告", f"设备 {device_path} 已挂载,但无法获取详细信息以添加到 fstab。")
|
||||
return success
|
||||
|
||||
def unmount_partition(self, device_path, show_dialog_on_error=True):
|
||||
"""卸载指定设备"""
|
||||
|
||||
Reference in New Issue
Block a user