Repository navigation
fix: skip backup recovery for explicitly opened files #736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -327,7 +327,7 @@ void StartManager::autoBackupFile() | |
| qCDebug(appLog) << "Exit autoBackupFile"; | ||
| } | ||
|
|
||
| int StartManager::recoverFile(Window *window) | ||
| int StartManager::recoverFile(Window *window, const QStringList &explicitFiles) | ||
| { | ||
| qCDebug(appLog) << "Enter recoverFile"; | ||
|
|
||
|
|
@@ -420,6 +420,15 @@ int StartManager::recoverFile(Window *window) | |
| } | ||
| } | ||
|
|
||
| // 跳过显式请求打开的文件的备份记录,避免会话恢复与显式打开之间路径去重失败 | ||
| if (!explicitFiles.isEmpty() && !localPath.isEmpty()) { | ||
| QString resolvedLocal = Utils::getFilePath(localPath); | ||
| if (explicitFiles.contains(resolvedLocal)) { | ||
| qCDebug(appLog) << "Skipping backup for explicitly opened file:" << localPath; | ||
| continue; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium · Restored tabs lose window separation When all saved records in the first window match explicitly opened files and a later saved window has records to restore, Update the saved window index and create the corresponding window before skipping an explicitly opened record. Also at Prompt for AI agentsIn `src/startmanager.cpp` at line 428:
**Restored tabs lose window separation**
When all saved records in the first window match explicitly opened files and a later saved window has records to restore, `recoverFile` skips the first window's records before updating `windowIndex`, so the first later-window record initializes the index without creating a window and its tabs are added to the supplied window alongside the explicitly opened files.
Update the saved window index and create the corresponding window before skipping an explicitly opened record.
Also at `src/startmanager.cpp:429`. |
||
| } | ||
| } | ||
|
|
||
| // 确定实际打开路径和显示名称 | ||
| QString openPath; | ||
| QString displayName; | ||
|
|
@@ -639,7 +648,11 @@ void StartManager::openFilesInTab(QStringList files) | |
| // 以 window 为 context:窗口在延时期间被销毁则不触发,避免悬空调用 | ||
| QTimer::singleShot(50, window, [ = ] { | ||
| qCDebug(appLog) << "Delayed file opening for:" << resolvedFile; | ||
| recoverFile(window); | ||
| QStringList resolvedFiles; | ||
| for (const QString &f : files) { | ||
| resolvedFiles << Utils::getFilePath(f); | ||
| } | ||
| recoverFile(window, resolvedFiles); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium · Recovery opens duplicate tabs When a second Pass recovery the combined list of files opened by requests received before the delayed recovery runs. Prompt for AI agentsIn `src/startmanager.cpp` at line 655:
**Recovery opens duplicate tabs**
When a second `openFilesInTab` request arrives during the first request's 50 ms delay and includes a file with a saved backup, `openFilesInTab` opens the second request's file immediately, but the first request's delayed recovery passes only its own file list to `recoverFile`, which restores the second file's backup as another tab.
Pass recovery the combined list of files opened by requests received before the delayed recovery runs. |
||
| window->addTab(resolvedFile); | ||
| }); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,9 +57,10 @@ class StartManager : public QObject | |
| /** | ||
| * @brief recoverFile 备份恢复 | ||
| * @param window 从哪个窗口进行恢复 | ||
| * @param explicitFiles 显式请求打开的文件路径列表,恢复时跳过这些文件的备份记录 | ||
| * @return 恢复完成的文件数量 | ||
| */ | ||
| int recoverFile(Window *window); | ||
| int recoverFile(Window *window, const QStringList &explicitFiles = QStringList()); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Critical · Test target no longer compiles When the test target is compiled, Preserve the one-parameter overload and add a separate overload that accepts the explicit-file list. Also at Prompt for AI agentsIn `src/startmanager.h` at line 63:
**Test target no longer compiles**
When the test target is compiled, `recoverFile` has a two-parameter member-function type despite its default argument, so the existing one-parameter `static_cast` stubs in `test_startmanager` fail and the test target does not build.
Preserve the one-parameter overload and add a separate overload that accepts the explicit-file list.
Also at `src/startmanager.cpp:330`, `src/startmanager.h:64`. |
||
|
|
||
| /** | ||
| * @brief analyzeBookmakeInfo 解析书签信息 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 Critical · Unsaved recovery edits disappear
When an explicitly opened file has a modified recovery backup,
recoverFileskips the backup, soopenFilesInTabopens the on-disk contents instead or, if the file is unreadable, leaves no tab with the valid backup. A laterautoBackupFilecan overwrite the saved session record with the opened file's current contents.Preserve and restore the modified backup for explicitly opened files, including when opening the on-disk file fails.
Also at
src/startmanager.cpp:429.Prompt for AI agents