fix(backup): [dependent on #240] resolve cross-platform path issues and restore crash#287
Closed
luosc wants to merge 1 commit intoChevey339:masterfrom
Closed
fix(backup): [dependent on #240] resolve cross-platform path issues and restore crash#287luosc wants to merge 1 commit intoChevey339:masterfrom
luosc wants to merge 1 commit intoChevey339:masterfrom
Conversation
Chevey339#243) - Fix 'PathNotFoundException' by adding robust path resolution logic: - Export: Convert absolute paths to portable relative paths (e.g. 'upload/img.jpg') using aggressive directory matching to handle iOS/macOS symlinks. - Import: Expand relative paths to current device's absolute path. - Import: Heal legacy absolute paths (from old backups) using 'SandboxPathResolver' with a generic fallback for generic subfolders. - Fix 'Widget unmounted' crash in 'DesktopBackupPane' during long restore operations by checking '!mounted'. - Add 'SandboxPathResolver' initialization to restore flow.
Contributor
Author
|
Contributor
支持,现有备份在不同设备间会丢失一些照片之类的插入文件。 |
Contributor
Author
|
“往后退一步,只改还原(Restore)逻辑,不改备份(Export)逻辑”的想法,从系统设计的角度来看,这种做法的核心优势在于**“数据无损性(Non-Destructive)和备份安全性”**。 为什么只改“还原逻辑”更好?
实施(Action Plan)
总结:退回一步,只在**读取(导入)时做兼容,而不在写入(导出)**时做变异,是目前保证用户数据绝对安全、且又能完美解决 #243 跨平台恢复痛点的最优解! |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses cross-platform image path compatibility issues when restoring backups on different devices (e.g., Windows User A to Windows User B, or PC to Mobile). It ensures that file paths are portable and correctly resolved regardless of the environment.
Additionally, it fixes a crash in the Desktop backup pane that occurred during long restore operations.
Fixes #243
Depends on #240 (Granular backup/restore)
Key Changes
Cross-Platform Path Resolution (
data_sync.dart):upload/img.jpg) before saving to the backup. It uses aggressive directory matching to correctly handle iOS/macOS symlinks.SandboxPathResolverwith a fallback mechanism to locate files in standard subfolders.Stability Improvements (
backup_pane.dart):Widget unmountedcrash inDesktopBackupPaneby adding!mountedchecks during asynchronous restore operations.Initialization:
SandboxPathResolverinitialization to the restore flow to ensure path helpers are ready before processing files.描述
本 PR 解决了在不同设备间(例如 Windows 用户 A 到 Windows 用户 B,或电脑到手机)恢复备份时,图片路径不兼容的问题。它确保文件路径具有可移植性,并在不同环境下都能被正确解析。
此外,修复了桌面端在长时间恢复操作过程中可能发生的崩溃问题。
修复 #243
依赖 #240 (颗粒化备份/恢复)
主要变更
跨平台路径解析 (
data_sync.dart):upload/img.jpg)。采用了更激进的目录匹配策略,以正确处理 iOS/macOS 的符号链接。SandboxPathResolver修复包含绝对路径的旧备份,并通过回退机制在标准子目录中查找文件。稳定性改进 (
backup_pane.dart):DesktopBackupPane的异步恢复操作中添加了!mounted检查,修复了Widget unmounted导致的崩溃。初始化:
SandboxPathResolver的初始化,确保在处理文件前路径助手已准备就绪。