Skip to content

Conversation

@GongHeng2017
Copy link

@GongHeng2017 GongHeng2017 commented Nov 20, 2025

-- Optimize the default 7z compression efficiency.

Log: fix issue
Bug: https://pms.uniontech.com/bug-view-287203.html

Summary by Sourcery

Bug Fixes:

  • Set the default 7z compression level to 1 for improved performance

@sourcery-ai
Copy link

sourcery-ai bot commented Nov 20, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The PR improves default 7z compression efficiency by explicitly setting the compression level when initializing a 7z archive operation.

Sequence diagram for setting 7z compression level during archive creation

sequenceDiagram
    participant MainWindow
    participant CompressOptions
    participant 7zArchive
    MainWindow->>CompressOptions: set iCompressionLevel = 1
    MainWindow->>7zArchive: initialize with CompressOptions
    7zArchive->>7zArchive: use iCompressionLevel = 1 for compression
Loading

Class diagram for updated CompressOptions usage in 7z compression

classDiagram
    class CompressOptions {
        int iCompressionLevel
        // other attributes
    }
    class MainWindow {
        slotFinishCalculateSize(size, strArchiveFullPath, listAddEntry, stOptions, listAllEntry)
    }
    MainWindow --> CompressOptions: uses
    CompressOptions <.. 7zArchive: passed to
    class 7zArchive {
        // uses CompressOptions.iCompressionLevel
    }
Loading

File-Level Changes

Change Details Files
Force default 7z compression to level 1
  • Add assignment to stOptions.iCompressionLevel within slotFinishCalculateSize for 7z startup path
src/source/mainwindow.cpp

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

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot
Copy link

deepin pr auto review

我来对这段代码变更进行审查:

  1. 语法逻辑:
  • 代码在语法上是正确的,没有语法错误。
  • slotFinishCalculateSize 函数中,当启动类型为 ST_Compresstozip7z 时,直接将压缩级别设置为 1。
  1. 代码质量:
  • 存在一个明显的缩进问题:#ifdef 块的缩进与 if 语句不一致,这会影响代码的可读性。
  • 建议使用常量或枚举来定义压缩级别,而不是直接使用魔法数字 1。
  • 缺少对设置压缩级别的注释说明,为什么要强制设置为 1?
  1. 代码性能:
  • 这个变更对性能影响较小,只是简单的赋值操作。
  1. 代码安全:
  • 直接设置压缩级别为 1 可能会影响压缩效果,建议:
    • 添加注释说明为什么需要强制设置压缩级别
    • 考虑是否应该允许用户配置这个值
    • 验证压缩级别 1 是否在有效范围内

改进建议:

void MainWindow::slotFinishCalculateSize(qint64 size, QString strArchiveFullPath, QList<FileEntry> listAddEntry, CompressOptions stOptions, QList<FileEntry> listAllEntry)
{
    if (StartupType::ST_Compresstozip7z == m_eStartupType) {
        // 对于 zip7z 格式,使用最低压缩级别以确保兼容性和速度
        stOptions.iCompressionLevel = CompressionLevel::LOWEST;  // 建议定义常量
        
#ifdef DTKCORE_CLASS_DConfigFile
        if (m_pCompressSettingPage->isOrderMode()) {
            DConfig *dconfig = DConfig::create("org.deepin.compressor","org.deepin.compressor.method");

建议:

  1. 定义压缩级别常量:
namespace CompressionLevel {
    const int LOWEST = 1;
    const int NORMAL = 5;
    const int HIGHEST = 9;
}
  1. 添加适当的注释说明为什么需要这样设置。

  2. 考虑是否需要将这个设置作为可配置项,而不是硬编码。

  3. 修复代码缩进问题,保持代码风格一致性。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: GongHeng2017, lzwind

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

@GongHeng2017
Copy link
Author

/merge

@deepin-bot deepin-bot bot merged commit bbf1e37 into linuxdeepin:develop/snipe Nov 20, 2025
15 checks passed
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.

3 participants