Repository navigation
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: LiHua000 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 |
Reviewer's GuideLibzipPlugin::updateArchiveData() now applies delete, rename, and add operations directly to DataManager’s in-memory archive state instead of clearing it and rereading from disk, enabling immediate UI refresh while preserving the existing dispatch interface and tar behavior. Sequence diagram for in-memory ZIP archive updatessequenceDiagram
participant Operation as ArchiveOperation
participant Plugin as LibzipPlugin
participant Data as DataManager
participant UI as ArchiveUI
Operation->>Plugin: updateArchiveData(options)
Plugin->>Data: archiveData()
alt Delete
Plugin->>Data: remove entries and update qSize
else Rename
Plugin->>Data: replace paths in mapFileEntry and listRootEntry
else Add
Plugin->>Data: insert entry and update qSize
end
Plugin-->>Operation: PFT_Nomral
Operation-->>UI: refresh from in-memory archive state
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="3rdparty/libzipplugin/libzipplugin.cpp" line_range="631-633" />
<code_context>
+ if (stArchiveData.listRootEntry.at(i).strFullPath == entry.strFullPath) { // 在第一次层数据中找到entry移除
+ stArchiveData.listRootEntry.removeAt(i);
+ strAlias = entry.strAlias + QDir::separator();
+ entry.strFullPath = strAlias;
+ entry.strFileName = strAlias;
+ stArchiveData.listRootEntry.append(entry);
+ break;
+ }
</code_context>
<issue_to_address>
**issue (bug_risk):** Root-level directory rename stores `strFileName` as the full aliased path including the trailing separator instead of the directory basename, so the root listing displays a path-like name rather than the renamed folder name.
**Triggers:** When renaming a directory at the archive root.
**Suggested fix:** Assign `QFileInfo(strAlias).fileName()` (or the directory basename without the trailing separator) to `entry.strFileName`.
</issue_to_address>| entry.strFullPath = strAlias; | ||
| entry.strFileName = strAlias; | ||
| stArchiveData.listRootEntry.append(entry); |
There was a problem hiding this comment.
issue (bug_risk): Root-level directory rename stores strFileName as the full aliased path including the trailing separator instead of the directory basename, so the root listing displays a path-like name rather than the renamed folder name.
Triggers: When renaming a directory at the archive root.
Suggested fix: Assign QFileInfo(strAlias).fileName() (or the directory basename without the trailing separator) to entry.strFileName.
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: [] 2. 代码质量 ✅评价: 良好 ✅ 通过 潜在问题: 建议: ['建议将重复的root entry更新逻辑提取为辅助函数,如:void updateRootEntry(ArchiveData &data, const FileEntry &oldEntry, const FileEntry &newEntry, bool isRename)', '建议将Delete/Rename/Add三个操作分支分别提取为独立函数,提升可读性和可维护性'] 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: ['建议使用 foreach (const FileEntry &entry, options.listEntry) 避免不必要的对象拷贝', '建议将目录前缀计算(strPath和strAlias前半段)移到while循环外部,只计算一次'] 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: ['代码采用内存级数据操作替代旧的磁盘读取方式,消除了zip_open()失败时错误处理被注释掉的安全隐患,安全性有所提升'] 💡 改进建议代码示例// 暂无代码示例本报告由 AI 代码审查工具自动生成 |
1. Root cause: LibzipPlugin::updateArchiveData() ignored the options parameter, cleared all memory data, and re-read from disk via zip_open() with commented-out error handling on failure 2. Fix: rewrite updateArchiveData() to use the options parameter for in-memory updates (Delete/Rename/Add), mirroring LibarchivePlugin::updateArchiveData(), eliminating disk re-read fragility and restoring proper error handling 3. Impact: zip format archives now refresh UI immediately after rename/delete/add operations without reopening, consistent with tar format behavior; no signature change, single caller via virtual dispatch unaffected Influence: 1. Test zip archive file rename, verify UI shows new name immediately 2. Test zip archive file/folder delete, verify UI updates instantly 3. Test zip archive file add, verify new entry appears without reopen 4. Test multi-level path folder rename/delete in zip archives 5. Verify tar format operations remain unaffected fix: 修复zip格式压缩包重命名后需重新打开才显示的问题 1. 根因:LibzipPlugin::updateArchiveData() 忽略 options 参数,清空 全部内存数据后通过 zip_open() 从磁盘重读,且 zip_open 失败时 错误处理被注释掉,导致内存数据为空或过时,UI 无法正确刷新 2. 方案:参照 LibarchivePlugin::updateArchiveData() 实现,改用 options 参数做内存级更新(Delete/Rename/Add),消除磁盘重读 脆弱性,恢复错误处理 3. 影响:zip 格式压缩包重命名/删除/追加后 UI 即时刷新,与 tar 格式行为一致;函数签名不变,单一调用方通过虚函数分派不受影响 Influence: 1. 测试zip压缩包内文件重命名,验证UI即时显示新名称 2. 测试zip压缩包内文件/文件夹删除,验证UI即时更新 3. 测试zip压缩包内文件追加,验证新条目无需重开即可显示 4. 测试多层路径文件夹的重命名/删除操作 5. 验证tar格式操作不受影响 PMS: BUG-232441
46ca314 to
10718d1
Compare
fix: update libzip archive data in-memory like libarchive
parameter, cleared all memory data, and re-read from disk via
zip_open() with commented-out error handling on failure
in-memory updates (Delete/Rename/Add), mirroring
LibarchivePlugin::updateArchiveData(), eliminating disk re-read
fragility and restoring proper error handling
rename/delete/add operations without reopening, consistent with
tar format behavior; no signature change, single caller via
virtual dispatch unaffected
Influence:
fix: 修复zip格式压缩包重命名后需重新打开才显示的问题
全部内存数据后通过 zip_open() 从磁盘重读,且 zip_open 失败时
错误处理被注释掉,导致内存数据为空或过时,UI 无法正确刷新
options 参数做内存级更新(Delete/Rename/Add),消除磁盘重读
脆弱性,恢复错误处理
格式行为一致;函数签名不变,单一调用方通过虚函数分派不受影响
Influence:
PMS: BUG-232441
Summary by Sourcery
Keep ZIP archive views synchronized immediately after internal file operations while preventing redundant file-watcher handling.
Bug Fixes:
Enhancements: