fix(database): synchronize cleanup of bookmarks and tab groups in orphan states - #387
Conversation
…han states Cleanup could leave dangling references because bookmarks and tab groups were removed independently while ownership records were still being reconciled; the residue was re-persisted by later sync runs. 孤立状态下的书签与标签组独立清理时归属记录仍在协调,残留项会被 后续同步再次落盘。 Log: 修复孤立状态下书签与标签组清理不同步导致残留引用的问题 Influence: 数据库书签与标签组清理逻辑,孤立状态下不再残留悬挂引用。
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe orphan cleanup path now atomically removes both bookmark and tab-group records for deleted documents, preventing residual tab-group data while leaving normal document read/write behavior unchanged. Sequence diagram for atomic orphan bookmark and tab-group cleanupsequenceDiagram
participant Database
participant Transaction
participant Bookmark
participant TabGroup
Database->>Transaction: cleanupOrphanStates()
loop orphan document path
Transaction->>Bookmark: DELETE FROM bookmark WHERE filePath = :filePath
Transaction->>TabGroup: DELETE FROM tabgroup WHERE filePath = :filePath
end
Database->>Transaction: commit()
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 语法正确,逻辑清晰。新增的 tabgroup 清理代码完全遵循已有的 bookmark 清理模式(prepare → bindValue → exec),在同一事务中执行,保证数据一致性。 2. 代码质量 ✅评价: 优秀 ✅ 通过 潜在问题:
建议: 建议对 deleteQuery.exec() 的返回值进行检查,或在删除失败时记录警告日志,与 operation 表删除的错误处理保持一致。例如:if (!deleteQuery.exec()) { qCWarning(appLog) << "Failed to clean tabgroup:" << deleteQuery.lastError(); } 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 性能良好,资源使用合理。新增的 DELETE 语句在同一事务中执行,使用参数化查询,无明显性能开销。 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 存在0个安全漏洞。代码使用参数化查询(prepare + bindValue)防止 SQL 注入,无硬编码凭证,无敏感信息泄露。 💡 改进建议代码示例// 建议对 tabgroup 删除操作添加错误检查,与 operation 删除保持一致
deleteQuery.prepare("DELETE FROM tabgroup WHERE filePath = :filePath");
deleteQuery.bindValue(":filePath", path);
if (!deleteQuery.exec()) {
qCWarning(appLog) << "Failed to clean tabgroup for orphan state:" << path
<< deleteQuery.lastError();
}
// 同理,建议 bookmark 删除也补充错误检查
deleteQuery.prepare("DELETE FROM bookmark WHERE filePath = :filePath");
deleteQuery.bindValue(":filePath", path);
if (!deleteQuery.exec()) {
qCWarning(appLog) << "Failed to clean bookmark for orphan state:" << path
<< deleteQuery.lastError();
}本报告由 AI 代码审查工具自动生成 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos, lzwind The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/merge |
修改说明
Database::cleanupOrphanStates()清理孤儿文档状态时,此前仅同步删除了bookmark表中的对应记录,tabgroup表会遗留孤儿数据(文档已删除但标签页组记录残留)。本 PR 在同一事务中同步清理
tabgroup记录,保证书签与标签页组清理的一致性。影响范围
仅
reader/app/Database.cpp,孤儿状态清理路径;不影响正常文档的书签/标签页组读写。Summary by Sourcery
Bug Fixes: