add ntfsfix
This commit is contained in:
@@ -440,6 +440,9 @@ class MainWindow:
|
||||
elif fstype == 'xfs':
|
||||
fs_menu.add_command(label=f"修复文件系统 (xfs_repair) {device_path}",
|
||||
command=lambda dp=device_path: self._handle_xfs_repair(dp))
|
||||
elif fstype.lower() == 'ntfs':
|
||||
fs_menu.add_command(label=f"修复文件系统 (ntfsfix) {device_path}",
|
||||
command=lambda dp=device_path: self._handle_ntfsfix(dp))
|
||||
if fs_menu.index(tk.END) is not None:
|
||||
menu.add_cascade(label=f"文件系统工具 {device_path}", menu=fs_menu)
|
||||
|
||||
@@ -546,6 +549,9 @@ class MainWindow:
|
||||
elif fstype == 'xfs':
|
||||
fs_menu.add_command(label=f"修复文件系统 (xfs_repair) {array_path}",
|
||||
command=lambda dp=array_path: self._handle_xfs_repair(dp))
|
||||
elif fstype.lower() == 'ntfs':
|
||||
fs_menu.add_command(label=f"修复文件系统 (ntfsfix) {array_path}",
|
||||
command=lambda dp=array_path: self._handle_ntfsfix(dp))
|
||||
if fs_menu.index(tk.END) is not None:
|
||||
menu.add_cascade(label=f"文件系统工具 {array_path}", menu=fs_menu)
|
||||
|
||||
@@ -637,6 +643,9 @@ class MainWindow:
|
||||
elif fstype == 'xfs':
|
||||
fs_menu.add_command(label=f"修复文件系统 (xfs_repair) {lv_path}",
|
||||
command=lambda dp=lv_path: self._handle_xfs_repair(dp))
|
||||
elif fstype.lower() == 'ntfs':
|
||||
fs_menu.add_command(label=f"修复文件系统 (ntfsfix) {lv_path}",
|
||||
command=lambda dp=lv_path: self._handle_ntfsfix(dp))
|
||||
if fs_menu.index(tk.END) is not None:
|
||||
menu.add_cascade(label=f"文件系统工具 {lv_path}", menu=fs_menu)
|
||||
|
||||
@@ -918,6 +927,37 @@ class MainWindow:
|
||||
else:
|
||||
messagebox.showerror("错误", f"调整文件系统大小失败:\n{stderr[:500] if stderr else '未知错误'}")
|
||||
self.refresh_all_info()
|
||||
|
||||
def _handle_ntfsfix(self, device_path):
|
||||
"""修复 NTFS 文件系统"""
|
||||
# 检查设备是否已挂载
|
||||
mount_point = self.system_manager.get_mountpoint_for_device(device_path)
|
||||
if mount_point and mount_point != 'N/A':
|
||||
messagebox.showwarning("警告", f"设备 {device_path} 已挂载到 {mount_point}\n请先卸载后再执行文件系统修复。")
|
||||
return
|
||||
|
||||
if not messagebox.askyesno("确认",
|
||||
f"即将对 {device_path} (NTFS) 执行文件系统修复。\n"
|
||||
f"命令: sudo ntfsfix -d {device_path}\n\n"
|
||||
f"注意:此操作会清除 NTFS 卷的脏标志并尝试修复。\n"
|
||||
f"如果修复后仍无法挂载,请尝试使用 ntfs-3g 方式挂载。",
|
||||
default=messagebox.NO):
|
||||
return
|
||||
|
||||
logger.info(f"开始修复 NTFS 文件系统: {device_path}")
|
||||
success, stdout, stderr = self.lvm_ops._execute_shell_command(
|
||||
["ntfsfix", "-d", device_path],
|
||||
f"修复 NTFS 文件系统 {device_path} 失败"
|
||||
)
|
||||
|
||||
if success:
|
||||
messagebox.showinfo("成功", f"NTFS 文件系统修复完成:\n{stdout[:500] if stdout else '无输出'}\n\n"
|
||||
f"如果仍无法正常挂载,请尝试使用:\n"
|
||||
f"mount -t ntfs-3g {device_path} <挂载点>")
|
||||
else:
|
||||
messagebox.showerror("错误", f"NTFS 文件系统修复失败:\n{stderr[:500] if stderr else '未知错误'}\n\n"
|
||||
f"建议尝试使用 ntfs-3g 驱动挂载。")
|
||||
self.refresh_all_info()
|
||||
|
||||
def on_disk_formatting_finished(self, success, device_path, stdout, stderr):
|
||||
"""接收格式化完成回调并刷新界面"""
|
||||
|
||||
Reference in New Issue
Block a user