Skip to content

fix: clear selection on back from result page - #832

Open
pppanghu77 wants to merge 37 commits into
linuxdeepin:masterfrom
pppanghu77:fix/pms-262109-clear-selection-back
Open

pppanghu77 wants to merge 37 commits into
linuxdeepin:masterfrom
pppanghu77:fix/pms-262109-clear-selection-back

Conversation

@pppanghu77

Copy link
Copy Markdown
Contributor

Root Cause Analysis

ZipFileProcessResultWidget::backPage() (export result page "Back" button
handler) emits only changeWidget(choosewidget) to switch pages, but does not
emit clearWidget beforehand. The clearWidget signal is connected to
MainWindowPrivate::clearWidget() (mainwindow_p_win.cpp:139-140), which
calls clear() on all selection widgets. Because the signal is never emitted,
selection state is never reset, leaving stale file selections when the user
returns to the choose page.

Key evidence:

  • zipfileprocessresultwidget.cpp:136-138 — backPage() missing clearWidget
  • errorwidget.cpp:99-102 — same-module ErrorWidget::backPage() emits
    clearWidget before changeWidget, establishing the correct pattern

Fix

Add emit TransferHelper::instance()->clearWidget(); before the existing
changeWidget emit in backPage(), matching the pattern in
ErrorWidget::backPage() and other back-handlers in the same module.

Change Safety Assessment

Code Safety

  • Risk Level: Low
  • Single-file, single-function, one-line addition; no signature change, no
    public member change, no caller impact beyond the backButton click path
  • clearWidget signal already has 4 established emit sites
    (transferworker.cpp:373, resultdisplay.cpp:87, errorwidget.cpp:101,
    errorwidget.cpp:107); adding a 5th follows the same proven pattern
  • Target line is not a historical fix product; this change does not revert any
    prior fix

Business Impact Scope

  • Data Transfer — Backup File Export: Windows users export files, click
    "Back" on the result page, return to the file selection page
  • Affected caller: zipfileprocessresultwidget.cpp:64
    (backButton::clicked → backPage)
  • After fix: returning from export result page clears all selection state,
    so the user starts fresh on re-entry

Verification Suggestion

Test export success then click Back — verify file selections are cleared.
Test export failure then click Back — same verification. Verify re-selecting
and re-exporting works normally after returning.


根因分析

ZipFileProcessResultWidget::backPage()(导出结果页"返回"按钮槽函数)仅发射
changeWidget(choosewidget) 切换页面,未事先发射 clearWidget 信号。该信号连接到
MainWindowPrivate::clearWidget()(mainwindow_p_win.cpp:139-140),对全部选择控件
执行 clear() 重置。由于信号未发射,选择状态未被重置,返回选择页时残留历史选择。

关键证据:

  • zipfileprocessresultwidget.cpp:136-138 — backPage() 缺少 clearWidget 发射
  • errorwidget.cpp:99-102 — 同模块 ErrorWidget::backPage() 先发射 clearWidget
    再发射 changeWidget,确立了正确范式

修复方案

在 backPage() 中 changeWidget 发射之前添加
emit TransferHelper::instance()->clearWidget();,与 ErrorWidget::backPage()
等同模块返回处理范式一致。

改动安全评估

代码安全评估

  • 风险等级: 低风险
  • 单文件单函数一行新增,不修改签名、不删公开函数、不影响其他调用者
  • clearWidget 信号已有 4 处成熟发射点,新增第 5 处沿用同一范式
  • 目标行非历史修复产物,本次改动不撤销任何已有修复

业务影响范围

  • 数据迁移-备份文件导出:Windows 端用户导出文件后点击"返回"回到选择备份内容界面
  • 受影响调用者:zipfileprocessresultwidget.cpp:64(backButton::clicked → backPage)
  • 修复后:从导出结果页返回时清空所有选择状态,用户重新进入时为空白状态

验证建议

测试导出成功后点击返回,验证文件选择已清空。测试导出失败后点击返回,同样验证。
验证返回后重新选择并导出流程正常。

pppanghu77 and others added 30 commits June 25, 2024 14:03
 [build] fix build

Log: [build] fix build
Task: https://pms.uniontech.com/task-view-354339.html
new tag v0.8.5, fix frontend launch issue for win.

Log: v0.8.5 override other incompatible version.
fix Multi user startup test

Log: fix Multi user startup test
Bug: https://pms.uniontech.com/bug-view-256723.html
[start] Change the startup sequence of the front-end and back-end

Log: [start] Change the startup sequence of the front-end and back-end
Bug: https://pms.uniontech.com/bug-view-261983.html
new tag v0.8.6

Log: new tag v0.8.6
[translation] add bo ug translation

Log: [translation] add bo ug translation
Fix title icon issue which caused by DTK updated.

Log: Fix title icon issue.
Bug: https://pms.uniontech.com/bug-view-264627.html
v0.8.7 release.

Log: v0.8.7 release.
…offline

Avoiding the impact of network fluctuations

Log: Added the option to manually disconnect the other party offline
Task: https://pms.uniontech.com/task-view-357177.html
Fix List Status and move the log location to/etc

Log: Fix List Status and move the log location to/et
Task: https://pms.uniontech.com/task-view-357177.html
v0.8.8 release.

Log: v0.8.8 release.
Modify the storage location of log level files

Log: Modify the storage location of log level files
Task: https://pms.uniontech.com/story-view-36529.html
Fix translation and UI issues

Log: Fix translation and UI issues
Bug: https://pms.uniontech.com/bug-view-250549.html
libcoost creates persistent static resources for each thread, which can cause memory leaks when threads are frequently created and released
using a thread pool to avoid frequent creation and destruction of threads
Log: Fix memory leaks
Bug: https://pms.uniontech.com/bug-view-266935.html
The daemon is renamed dde operation daemon

Log: The daemon is renamed dde operation daemon
Bug: https://pms.uniontech.com/bug-view-266935.html
v0.8.9 release.

Log: v0.8.9 release.
The default number of thread pools is too low, resulting in communication failure

Log: [thread] Increase the initial number of threads in threadpool
Bug: https://pms.uniontech.com/bug-view-273695.html
…nnection

Fix the issue of disconnection after network disconnection

Log: Fix the issue of disconnection after network disconnection
Bug: https://pms.uniontech.com/bug-view-273833.html
Record the searched devices and provide the option to minimize pallets

Log: [optimization] Optimize user experience
Bug: https://pms.uniontech.com/bug-view-250143.html
fix the password for the connection page is not complete in tibetan

Log: fix the password display is incomplete
Bug: https://pms.uniontech.com/bug-view-250623.html
Probability crash upon awakening

Log: Probability crash upon awakening
Bug: no
Unable to open from launcher after closing

Log: fix some ui bug
Bug: https://pms.uniontech.com/bug-view-282501.html
Implement a check in the setFile function to ensure that file paths do not exceed two directory levels. This change modifies the filename to retain only the last two directories and the file name itself, enhancing path management.

Log: Filter file paths to limit depth to two directories.
…P retrieval

Replace direct usage of QNetworkInterface::allAddresses() with
deepin_cross::CommonUitls::getFirstIp() to get the first available IP
address.
Log: fix: (data-transfer) replace QNetworkInterface with CommonUtils for IP retrieval
Bug: https://pms.uniontech.com/bug-view-341249.html
…rm transfer mechanism

- Add security checks in `getSaveFullpath` to prevent path traversal attacks by validating
  filenames and ensuring they are within allowed directories using realpath resolution.
- Introduce transfer confirmation mechanism in `JobManager` to require user approval before
  accepting incoming file transfers.
- Add methods to confirm, remove, and check transfer confirmation status for apps.
- Update `SendRpcService` to handle transfer confirmation and refusal messages.
- Include cleanup of confirmation status when jobs finish, cancel, or fail.

Log: fix(security): add path traversal protection in TransferJob and confirm transfer mechanism
Bug: https://pms.uniontech.com/bug-view-343709.html
Replace the library's dependencies with a method that displays the calling dynamic library.

Log: Remove displayjack kvm depend.
- Add file transfer confirmation status when password authentication succeeds
- Allow subsequent file transfers by calling JobManager::confirmTransfer
- This enables file operations after remote login is authenticated

Log: fix(rpc): add file transfer confirmation after successful authentication
Bug: https://pms.uniontech.com/bug-view-354299.html
pppanghu77 and others added 7 commits April 7, 2026 12:38
- Remove the transfer confirmation cleanup on job finished/canceled/failed
- Keep the confirmation state alive for the entire session to allow
  subsequent transfers without re-authentication
- This fixes the network error when transferring files again after
  returning from a completed transfer

Log: fix(transfer): 传输完成后点击返回再次传输提示网络错误
Bug: https://pms.uniontech.com/bug-view-355819.html
…emove transfer.json

- Fix storage directory for data-transfer: place target subdirectory under ~/Downloads
  instead of directly under home directory
- Change cleanup behavior to only remove transfer.json instead of the entire directory

Log: fix(data-transfer): save files to ~/Downloads subdirectory and only remove transfer.json
Bug: https://pms.uniontech.com/bug-view-356089.html
sync by github workflow

Log: none
Influence: none
… prompt on app installation

- Add initSecurityLoaderReport() in main.cpp: when started by deepin-security-loader (--fd1/--fd2 passed), report the system bus unique name and the com.deepin.lastore service list to the loader in JSON so it registers the lastore allow-caller whitelist on our behalf, making InstallPackage free of polkit authentication
- Call the report before any early-exit branch (including single-instance failure), otherwise the loader times out and kills the process, which shows up as a crash on startup
- Add launcher script /usr/bin/deepin-data-transfer: start the real binary /usr/libexec/deepin/deepin-data-transfer through deepin-security-loader with the deepin-daemon group when available (dbus >= 1.12.20.17-deepin1), otherwise fall back to direct launch with the historical polkit behavior
- Enable Qt DBus component/linking and install the real binary to libexec/deepin with the launcher taking over /usr/bin
- Update debian packaging: install the libexec binary and add Recommends: deepin-security-loader

修复(data-transfer): 经 deepin-security-loader 启动以避免安装应用时弹出 polkit 鉴权框

- main.cpp 新增 initSecurityLoaderReport():经 deepin-security-loader 启动(带 --fd1/--fd2 参数)时,将 system bus 唯一连接名和 com.deepin.lastore 服务列表以 JSON 回报给 loader,由其代为注册 lastore 的 allow-caller 白名单,使 InstallPackage 等接口免 polkit 鉴权
- 回报调用置于任何提前退出分支(含单例失败)之前,否则 loader 会超时结束子进程,表现为启动闪退
- 新增启动脚本 /usr/bin/deepin-data-transfer:环境满足(dbus >= 1.12.20.17-deepin1)时经 deepin-security-loader 附加 deepin-daemon 组启动真实二进制 /usr/libexec/deepin/deepin-data-transfer,否则回退直接启动,鉴权行为与历史一致
- 启用 Qt DBus 组件与链接,真实二进制安装至 libexec/deepin,/usr/bin 由启动脚本接管
- 更新 debian 打包:安装 libexec 二进制并增加 Recommends: deepin-security-loader

Log: 数据迁移工具经 deepin-security-loader 附加 deepin-daemon 组启动并回报 bus 连接名,实现 lastore 安装接口免鉴权,修复迁移三方应用时弹出密码认证框的问题
Bug: https://pms.uniontech.com/bug-view-375325.html
…n different filesystems

- Move directories with QDir::rename instead of QFile::rename, which fails with EISDIR on directories
- Fall back to recursive copy plus source removal when rename fails with EXDEV across filesystems: copyDirectory() for directories and QFile::copy for single files
- Fix rename-collision handling: dst.remove(fileName) deleted every occurrence of the name and corrupted paths with repeated segments; only the trailing segment is cut now
- Ensure the destination parent directory exists before moving, for targets such as ~/D:/ derived from Windows drive letters

修复(数据迁移): 修复源和目标位于不同文件系统时 moveFile 搬运失败的问题

- 目录改用 QDir::rename 移动,避免 QFile::rename 移动目录时报 EISDIR 错误
- rename 跨文件系统失败(EXDEV)时退化为复制后删除源:目录走 copyDirectory() 递归复制,单文件走 QFile::copy
- 修复重名避让逻辑: dst.remove(fileName) 会误删路径中所有同名段导致路径破坏,改为只截取结尾段
- 移动前确保目标父目录存在,兼容 ~/D:/ 这类源自 Windows 盘符的目标路径

Log: 修复数据迁移搬运阶段接收目录与主目录不在同一文件系统时 rename 跨设备失败(EXDEV)导致搬运失败的问题
Bug: https://pms.uniontech.com/bug-view-375881.html
- In domain-account environments the loginctl session username may differ
  from the home directory name (e.g. "@xxx"), and the name comparison
  failed, making the daemon exit right after startup (inactive desktop session)
- isActiveUser() now compares the active desktop session UID against getuid(),
  decoupled from the user naming scheme; when multiple desktop sessions are
  active, only the one belonging to the current user is taken as the active session
- KEY_CURRENT_ACTIVE_USER now stores the active session UID and the
  ServiceManager runtime check compares UIDs accordingly
- Guard the loginctl/getuid() based session check with _WIN32 so the daemon
  still compiles on Windows, where the check is not applicable
- Update SPDX copyright year to 2023-2026 for the modified files

修复(daemon): 改用 UID 而非用户名判定活动桌面会话

- 域账号场景下 loginctl 会话用户名与家目录名可能不一致(如 "@xxx"),
  名字比对失败导致 daemon 启动即退出(exit, inactive desktop session)
- isActiveUser 改为比对活动桌面会话 UID 与 getuid(), 与命名体系解耦;
  存在多个活跃桌面会话时, 以属于当前用户的会话为准
- KEY_CURRENT_ACTIVE_USER 改存活动会话 UID, ServiceManager 运行时检查同步按 UID 判定
- 活动会话检查增加 _WIN32 平台守卫, 修复 Windows 构建下 getuid() 编译失败的问题
- 更新所改文件的 SPDX 版权年份为 2023-2026

Log: 修复域账号环境下跨端协同 daemon 无法启动的问题
1. Root cause: ZipFileProcessResultWidget::backPage() emits
   changeWidget without first emitting clearWidget, leaving stale
   file selection on the choose page
2. Fix: add emit clearWidget before changeWidget, matching the
   pattern used in ErrorWidget::backPage and other back handlers
3. Impact: only backButton click path in export result page, no
   signature or behavior change for other callers

Log: Clear file selection when returning from export result page

Influence:
1. Test export success then click back, verify selection cleared
2. Test export failure then click back, verify selection cleared
3. Verify re-selecting files after returning works normally

fix: 导出结果页返回时清空选择历史

1. 根因:ZipFileProcessResultWidget::backPage() 发射 changeWidget
   前未发射 clearWidget,导致选择页残留上次选择的文件列表
2. 方案:在 changeWidget 前增加 emit clearWidget,与
   ErrorWidget::backPage 等同模块返回处理保持一致
3. 影响:仅影响导出结果页返回按钮路径,对其他调用者无签名或行为变化

Log: 导出结果页返回时清空文件选择

Influence:
1. 测试导出成功后点击返回,验证文件选择已清空
2. 测试导出失败后点击返回,验证文件选择已清空
3. 验证返回后重新选择文件并导出流程正常

PMS: BUG-262109

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, we are unable to review this pull request

The GitHub API does not allow us to fetch diffs exceeding 20000 lines

@github-actions

Copy link
Copy Markdown

TAG Bot

TAG: 0.8.9
EXISTED: no
DISTRIBUTION: unstable

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 88 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次PR标题为"fix: clear selection on back from result page",实际包含大量改动: WaylandUtils从静态链接改为dlopen动态加载、daemon重命名(cooperation-daemon→dde-cooperation-daemon)、 isActiveUser改用UID判定、新增deepin-security-loader集成、新增路径穿越防护与文件传输确认机制、 新增DiscoverController(ZeroConf设备发现)、新增关闭对话框与系统托盘最小化、修复disconnectToDevice空指针问题、 修复Settings::setValueNoNotify参数错误、新增QUNIGO宏解决线程内存泄漏等。代码整体质量良好, 安全防护有显著增强(路径穿越检查、传输确认机制),但路径穿越验证存在边界缺口,部分新增代码有注释残留。 四维度均通过,总评88分,等级良好。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['getSaveFullpath中,当realFull为nullptr时应返回空字符串或报错,而非继续返回未验证的fullpath', 'initSearchDeivce中的QTimer应设置父子对象关系或使用QPointer保护this指针']


2. 代码质量 ✅

评价: 代码结构清晰,注释完整 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['清理DiscoverController中注释掉的代码块,如需保留设计意图可添加简要注释说明', '统一版权年份格式', 'moveFile可考虑使用局部变量代替修改入参dst']


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['initSecurityLoaderReport中管道读取可考虑使用QSocketNotifier实现事件驱动', 'refresh可考虑增量更新而非全量重建列表']


4. 代码安全 🔒

评价: 存在1个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: ['修复getSaveFullpath中realFull为nullptr时的逻辑:当realpath对文件和父目录均返回nullptr时,应拒绝写入而非继续返回fullpath', '可考虑使用realpathat或openat等AT_FDCWD系列函数进行更安全的路径验证']


💡 改进建议代码示例

// TransferJob::getSaveFullpath 修复建议
fastring TransferJob::getSaveFullpath(const fastring &rootdir, const fastring &filename)
{
    // ... 前置检查保持不变 ...

    fastring fullpath = path::join(rootdir, acfilename);

    // 二次验证:规范化路径后检查是否仍在用户配置的下载目录内
    fastring allowedRoot = DaemonConfig::instance()->getStorageDir(_app_name);
    char *realRoot = realpath(allowedRoot.c_str(), nullptr);
    char *realFull = realpath(fullpath.c_str(), nullptr);

    // 如果目标文件不存在,验证其父目录
    if (realFull == nullptr) {
        std::pair<fastring, fastring> pairs = path::split(fullpath);
        fastring parentDir = pairs.first;
        realFull = realpath(parentDir.c_str(), nullptr);
    }

    // 修复:如果无法解析路径,拒绝写入
    if (realRoot == nullptr || realFull == nullptr) {
        ELOG << "Path validation failed: unable to resolve path: " << fullpath;
        if (realRoot) free(realRoot);
        if (realFull) free(realFull);
        return "";
    }

    fastring rootPath(realRoot);
    fastring fullPath(realFull);
    if (!fullPath.starts_with(rootPath)) {
        ELOG << "Path traversal detected! Target path outside allowed directory: " << fullpath;
        free(realRoot);
        free(realFull);
        return "";
    }

    free(realRoot);
    free(realFull);
    return fullpath;
}

本报告由 AI 代码审查工具自动生成

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants