Skip to content

fix: use custom MIME type for zip split archives - #561

Draft
LiHua000 wants to merge 1 commit into
linuxdeepin:release/eaglefrom
LiHua000:agent/bugfix/383799
Draft

LiHua000 wants to merge 1 commit into
linuxdeepin:release/eaglefrom
LiHua000:agent/bugfix/383799

Conversation

@LiHua000

@LiHua000 LiHua000 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Root Cause Analysis

commit 9de63eab (BUG-268375) registered zip split archive globs (*.zip.[0-9][0-9][0-9], *.z[0-9]) under the standard MIME type application/zip in deepin-compressor.xml with weight=80, higher than the system *.zip glob (weight=50). update-mime-database merged these globs into application/zip, causing Qt's QMimeType::preferredSuffix() to return "zip.[0-9][0-9][0-9]" (literal brackets) instead of "zip". This polluted suffix propagated through refreshMenu() (display text) and slotCompressClicked() (filename construction), ultimately causing determineMimeType() to fail matching and produce "plugin failed" error.

Key evidence: src/assets/mimetype/deepin-compressor.xml:14-20, compresssettingpage.cpp:162, repro/before.log (Scenario 3 merged environment reproduced preferredSuffix="zip.[0-9][0-9][0-9]").

Fix Approach

Changed MIME type name from application/zip to custom application/x-zip-split in deepin-compressor.xml, so split archive globs no longer merge with standard application/zip. preferredSuffix() for application/zip restores to "zip", while split archive icon display is preserved via unchanged generic-icon configuration. This matches the root-cause-level fix (Plan A) adopted by the verifier, with no deviation from the analysis report's recommendation.

Change Safety Assessment

Code Safety

  • Risk Level: Low
  • Only 1 XML attribute value changed; no function signatures, code logic, or public API affected
  • Historical insight: target line is from commit 9de63eab (BUG-268375 icon fix), but that fix relies on generic-icon which is preserved unchanged — no regression to icon display

Business Impact Scope

  • Zip compression: format dropdown correctly displays "zip" instead of glob pattern; compression completes without "plugin failed" error
  • Zip split archive icon display (BUG-268375): unaffected, generic-icon configuration preserved
  • 7z format: unaffected

Verification Suggestion

Test zip compression (right-click → compress → select zip → verify "zip" shown and compression succeeds); verify .zip.001 and .z01 split archive icons still display; verify 7z compression unaffected.


根因分析

commit 9de63eab(BUG-268375)在 deepin-compressor.xml 中将 zip 分卷压缩包 glob(*.zip.[0-9][0-9][0-9]、*.z[0-9])注册在标准 MIME 类型 application/zip 下(weight=80),高于系统 *.zip(weight=50)。update-mime-database 将这些 glob 合并进 application/zip,导致 Qt 的 QMimeType::preferredSuffix() 返回 "zip.[0-9][0-9][0-9]"(含字面方括号)而非 "zip"。该错误后缀通过 refreshMenu()(显示文本)和 slotCompressClicked()(文件名拼接)传播,最终导致 determineMimeType() 匹配失败,产生"插件失败"错误。

关键证据:src/assets/mimetype/deepin-compressor.xml:14-20、compresssettingpage.cpp:162、repro/before.log(Scenario 3 合并环境复现 preferredSuffix="zip.[0-9][0-9][0-9]")。

修复方案

将 deepin-compressor.xml 中 MIME 类型名从 application/zip 改为自定义 application/x-zip-split,使分卷 glob 不再与标准 application/zip 合并。application/zip 的 preferredSuffix() 恢复返回 "zip",分卷压缩包图标显示通过不变的 generic-icon 配置保持正常。与复核采纳的方案 A(根因层修复)一致,无偏离。

改动安全评估

代码安全评估

  • 风险等级: 低风险
  • 仅修改 1 个 XML 属性值,不涉及函数签名、代码逻辑或公开 API
  • 历史洞察:目标行来自 commit 9de63eab(BUG-268375 图标修复),但该修复依赖 generic-icon,本次改动保留不变,不回退图标修复

业务影响范围

  • zip 压缩:格式下拉菜单正确显示 "zip" 而非 glob 模式;压缩功能正常完成,不再提示"插件失败"
  • zip 分卷压缩包图标显示(BUG-268375):不受影响,generic-icon 配置保留不变
  • 7z 格式:不受影响

验证建议

测试 zip 压缩(右键 → 压缩 → 选择 zip → 验证显示 "zip" 且压缩成功);验证 .zip.001 和 .z01 分卷文件图标正常;验证 7z 压缩不受影响。

Summary by Sourcery

Separate split ZIP archives from the standard ZIP MIME type while preserving their archive functionality and associations.

Bug Fixes:

  • Prevent split ZIP MIME associations from corrupting the standard ZIP suffix and causing compression failures.
  • Preserve ZIP-specific archive handling and editing capabilities for split ZIP archives after introducing the custom MIME type.

Enhancements:

  • Use a dedicated MIME type for split ZIP archives while retaining their existing icon association.
  • Map split ZIP MIME types to ZIP during archive association checks and related plugin selection.

Chores:

  • Update the MIME metadata copyright range.

@LiHua000
LiHua000 marked this pull request as draft November 23, 2026 12:23
@sourcery-ai

sourcery-ai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Handle the new split-ZIP MIME type in archive recognition, plugin selection, and archive parameter setup so split archives remain usable.

  • src/source/common/uitools.cpp L138-141, L233, L273
  • src/source/mainwindow.cpp L512-513, L2870

Configuration

Register split-ZIP globs under a dedicated MIME type to keep them from changing the preferred suffix for standard ZIP files.

  • src/assets/mimetype/deepin-compressor.xml L4, L15

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot

Copy link
Copy Markdown

[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.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@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.

Hey - I've found 3 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/assets/mimetype/deepin-compressor.xml" line_range="15" />
<code_context>
 		<glob pattern="*.7z.*" weight="80"/>
 	</mime-type>
-	<mime-type type="application/zip">
+	<mime-type type="application/x-zip-split">
 		<comment>Zip split archive</comment>
 		<generic-icon name="deepin-compressor"/>
</code_context>
<issue_to_address>
**Split ZIP archives cannot open**

When a split ZIP volume is detected as `application/x-zip-split`, `determineMimeType()` returns `application/x-zip-split`, but the MIME type has no `application/zip` parent and the archive plugins advertise only `application/zip`. `PluginManager::filterBy()` finds no compatible plugin, so the archive cannot be opened or extracted.

Add an `application/zip` parent to the `application/x-zip-split` MIME definition.
</issue_to_address>

### Comment 2
<location path="src/assets/mimetype/deepin-compressor.xml" line_range="15" />
<code_context>
 		<glob pattern="*.7z.*" weight="80"/>
 	</mime-type>
-	<mime-type type="application/zip">
+	<mime-type type="application/x-zip-split">
 		<comment>Zip split archive</comment>
 		<generic-icon name="deepin-compressor"/>
</code_context>
<issue_to_address>
**Misdetected split ZIPs lose ZIP identity**

When a valid split ZIP volume is assigned a non-default, non-ZIP MIME type by content detection, `determineMimeType()` no longer treats these filenames as ZIP extensions, so it skips the `file` fallback for a non-default content result and returns the content MIME type instead. Valid split ZIP volumes that content detection misidentifies as another type are therefore not recognized as ZIP archives.

Include the split ZIP MIME type in the ZIP detection fallback and map successful ZIP detection to a MIME type handled as ZIP.
</issue_to_address>

### Comment 3
<location path="src/assets/mimetype/deepin-compressor.xml" line_range="15" />
<code_context>
 		<glob pattern="*.7z.*" weight="80"/>
 	</mime-type>
-	<mime-type type="application/zip">
+	<mime-type type="application/x-zip-split">
 		<comment>Zip split archive</comment>
 		<generic-icon name="deepin-compressor"/>
</code_context>
<issue_to_address>
**File manager omits split ZIP actions**

When the file manager matches a split ZIP file to `application/x-zip-split`, the desktop entry and file-manager extraction declarations list `application/zip`, not `application/x-zip-split`, so the file manager omits the compressor association and extract actions for split archives.

Add `application/x-zip-split` to the desktop entry and file-manager extraction MIME declarations.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

<glob pattern="*.7z.*" weight="80"/>
</mime-type>
<mime-type type="application/zip">
<mime-type type="application/x-zip-split">

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High · Split ZIP archives cannot open

When a split ZIP volume is detected as application/x-zip-split, determineMimeType() returns application/x-zip-split, but the MIME type has no application/zip parent and the archive plugins advertise only application/zip. PluginManager::filterBy() finds no compatible plugin, so the archive cannot be opened or extracted.

Add an application/zip parent to the application/x-zip-split MIME definition.

Prompt for AI agents
In `src/assets/mimetype/deepin-compressor.xml` at line 15:

**Split ZIP archives cannot open**

When a split ZIP volume is detected as `application/x-zip-split`, `determineMimeType()` returns `application/x-zip-split`, but the MIME type has no `application/zip` parent and the archive plugins advertise only `application/zip`. `PluginManager::filterBy()` finds no compatible plugin, so the archive cannot be opened or extracted.

Add an `application/zip` parent to the `application/x-zip-split` MIME definition.

<glob pattern="*.7z.*" weight="80"/>
</mime-type>
<mime-type type="application/zip">
<mime-type type="application/x-zip-split">

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Misdetected split ZIPs lose ZIP identity

When a valid split ZIP volume is assigned a non-default, non-ZIP MIME type by content detection, determineMimeType() no longer treats these filenames as ZIP extensions, so it skips the file fallback for a non-default content result and returns the content MIME type instead. Valid split ZIP volumes that content detection misidentifies as another type are therefore not recognized as ZIP archives.

Include the split ZIP MIME type in the ZIP detection fallback and map successful ZIP detection to a MIME type handled as ZIP.

Prompt for AI agents
In `src/assets/mimetype/deepin-compressor.xml` at line 15:

**Misdetected split ZIPs lose ZIP identity**

When a valid split ZIP volume is assigned a non-default, non-ZIP MIME type by content detection, `determineMimeType()` no longer treats these filenames as ZIP extensions, so it skips the `file` fallback for a non-default content result and returns the content MIME type instead. Valid split ZIP volumes that content detection misidentifies as another type are therefore not recognized as ZIP archives.

Include the split ZIP MIME type in the ZIP detection fallback and map successful ZIP detection to a MIME type handled as ZIP.

<glob pattern="*.7z.*" weight="80"/>
</mime-type>
<mime-type type="application/zip">
<mime-type type="application/x-zip-split">

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High · File manager omits split ZIP actions

When the file manager matches a split ZIP file to application/x-zip-split, the desktop entry and file-manager extraction declarations list application/zip, not application/x-zip-split, so the file manager omits the compressor association and extract actions for split archives.

Add application/x-zip-split to the desktop entry and file-manager extraction MIME declarations.

Prompt for AI agents
In `src/assets/mimetype/deepin-compressor.xml` at line 15:

**File manager omits split ZIP actions**

When the file manager matches a split ZIP file to `application/x-zip-split`, the desktop entry and file-manager extraction declarations list `application/zip`, not `application/x-zip-split`, so the file manager omits the compressor association and extract actions for split archives.

Add `application/x-zip-split` to the desktop entry and file-manager extraction MIME declarations.

1. Root cause: deepin-compressor.xml registered zip split archive
   globs under standard MIME type application/zip, causing
   update-mime-database to merge *.zip.[0-9][0-9][0-9] and *.z[0-9]
   into application/zip; preferredSuffix() then returned the glob
   pattern string instead of "zip", polluting zip format display
2. Fix: change MIME type name from application/zip to custom
   application/x-zip-split so split archive globs no longer merge
   with standard application/zip; add x-zip-split handling in
   isArchiveFile, createInterface, and MainWindow parameter setup
   so split zip archives are still recognized as zip
3. Impact: zip format dropdown shows correct suffix "zip" instead
   of glob pattern; zip compression works without "plugin failed"
   error; split zip archives (.zip.001) remain recognized and
   extractable; split archive icon display preserved

Log: fix zip format dropdown showing wrong suffix and compression failure

Influence:
1. Test zip compression: right-click compress, select zip format,
   verify dropdown shows "zip" and compression completes
2. Test zip split archive (.zip.001) recognition and extraction
3. Test zip split archive icon display for .zip.001 and .z01 files
4. Test 7z format compression is unaffected

fix: 修复 zip 分卷压缩包 MIME 类型污染导致的格式显示错误

1. 根因:deepin-compressor.xml 将 zip 分卷压缩包 glob 注册在标准
   MIME 类型 application/zip 下,update-mime-database 将
   *.zip.[0-9][0-9][0-9] 和 *.z[0-9] 合并进 application/zip,
   导致 preferredSuffix() 返回 glob 模式字符串而非 "zip",污染
   zip 格式显示
2. 方案:将 MIME 类型名从 application/zip 改为自定义
   application/x-zip-split,使分卷 glob 不再与标准
   application/zip 合并;同时在 isArchiveFile、createInterface
   及 MainWindow 参数设置中增加 x-zip-split 等价处理,确保分卷
   zip 压缩包仍被识别为 zip
3. 影响:zip 格式下拉菜单正确显示 "zip" 而非 glob 模式;zip
   压缩功能正常,不再提示"插件失败";分卷 zip 压缩包
   (.zip.001)仍可正常识别和解压;分卷压缩包图标显示保持不变

Log: 修复 zip 格式下拉菜单显示错误后缀及压缩失败问题

Influence:
1. 测试 zip 压缩:右键压缩,选择 zip 格式,验证下拉菜单显示 "zip" 且压缩完成
2. 测试 zip 分卷压缩包(.zip.001)识别和解压功能正常
3. 测试 zip 分卷压缩包(.zip.001、.z01)图标显示正常
4. 测试 7z 格式压缩不受影响

PMS: BUG-383799
@LiHua000
LiHua000 force-pushed the agent/bugfix/383799 branch from c16898a to 6e34ba3 Compare November 23, 2026 12:31
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.

2 participants