Skip to content

fix: forward rn working dir to target path in handleLongNameExtract - #444

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:release/eaglefrom
LiHua000:release/eagle
Jul 30, 2026
Merged

fix: forward rn working dir to target path in handleLongNameExtract#444
deepin-bot[bot] merged 1 commit into
linuxdeepin:release/eaglefrom
LiHua000:release/eagle

Conversation

@LiHua000

@LiHua000 LiHua000 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

7z rn -w prevents rn's temporary archive from stacking on /tmp, avoiding ENOSPC when the working copy in /tmp and rn's internal temp would otherwise double the space requirement.

Bug: https://pms.uniontech.com/bug-view-371965.html

Summary by Sourcery

Bug Fixes:

  • Prevent ENOSPC errors during long-name extraction by forwarding the target extraction path as the working directory to the rename command.

@sourcery-ai

sourcery-ai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR updates the long-name extraction flow to pass the target extraction directory as 7z's working directory for the rename operation, ensuring temporary archives are created in the target path instead of /tmp to avoid ENOSPC issues.

Sequence diagram for updated long-name extract working directory handling

sequenceDiagram
    participant CliInterface
    participant CliProps
    participant MoveProgram

    CliInterface->>CliInterface: handleLongNameExtract(files)
    CliInterface->>CliProps: moveArgs(m_longNameTempArchivePath,m_renameEntries,archiveData,m_longNamePassword)
    CliProps-->>CliInterface: args
    CliInterface->>CliInterface: args append -w options.strTargetPath
    CliInterface->>MoveProgram: startLongNameProcess(program,args)
Loading

File-Level Changes

Change Details Files
Forward the target extraction directory to the 7z rename command as its working directory during long-name extraction.
  • Extend the move/rename arguments list in handleLongNameExtract to append a -w option
  • Use options.strTargetPath as the working directory value passed to the rename program
3rdparty/interface/archiveinterface/cliinterface.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

@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 left some high level feedback:

  • Consider guarding the addition of the -w argument based on the specific moveProgram (e.g. 7z rn) or a capability flag, so that other potential move programs are not passed an unsupported option.
  • It may be worth validating options.strTargetPath (non-empty, valid directory) before appending -w%1 to avoid passing an invalid working directory argument to the rename process.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider guarding the addition of the `-w` argument based on the specific `moveProgram` (e.g. 7z rn) or a capability flag, so that other potential move programs are not passed an unsupported option.
- It may be worth validating `options.strTargetPath` (non-empty, valid directory) before appending `-w%1` to avoid passing an invalid working directory argument to the rename process.

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.

7z rn -w<targetDir> prevents rn's temporary archive from stacking on /tmp,
avoiding ENOSPC when the working copy in /tmp and rn's internal temp
would otherwise double the space requirement.

Bug: https://pms.uniontech.com/bug-view-371965.html
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:95分

■ 【总体评价】

代码正确实现了长文件名解压时工作目录的指定,修复了临时文件创建失败的问题
逻辑清晰且注释完整,因路径拼接未做严格校验轻微扣分

■ 【详细分析】

  • 1.语法逻辑(基本正确)✓

在 CliInterface::handleLongNameExtract 函数中,通过 args.insert(1, ...) 将工作目录参数插入到命令行参数列表的指定位置,符合 7z 的参数解析惯例。startLongNameProcess 函数增加了 options.strTargetPath 参数,需确保函数声明已同步修改。
潜在问题:若 startLongNameProcess 的重载函数未定义,将导致编译错误;args.insert(1, ...) 假设 args 至少有1个元素,若 moveArgs 返回空列表会导致越界。
建议:确保 startLongNameProcess 存在对应签名的实现;在 insert 前检查 args.size() > 0。

  • 2.代码质量(良好)✓

代码添加了清晰的注释说明插入位置的原因,变量命名 wdir 符合规范,逻辑分支处理了目标路径为空时的回退情况。
潜在问题:无
建议:无

  • 3.代码性能(无性能问题)✓

仅涉及简单的字符串操作和列表插入,无复杂计算或资源消耗。
潜在问题:无
建议:无

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
总体风险较低,使用 QProcess 传递参数避免了直接的 Shell 命令注入风险。

  • 建议:虽然当前无安全漏洞,但建议对 options.strTargetPath 进行路径规范化(如 QDir::cleanPath)以防止潜在的路径遍历边缘情况。

■ 【改进建议代码示例】

         QString program = m_cliProps->property("moveProgram").toString();
         QStringList args = m_cliProps->moveArgs(m_longNameTempArchivePath, m_renameEntries,
                                                  DataManager::get_instance().archiveData(), m_longNamePassword);
         // -w 插在命令之后、归档之前,符合 7z 惯例
         QString wdir = QDir::cleanPath(options.strTargetPath);
         if (wdir.isEmpty()) {
             wdir = QDir::tempPath();
         }
         if (args.size() > 1) {
             args.insert(1, QStringLiteral("-w%1").arg(wdir));
         } else {
             args.append(QStringLiteral("-w%1").arg(wdir));
         }
         qInfo() << "handleLongNameExtract: starting async rename" << m_renameEntries.count() << "files";
         if (!startLongNameProcess(program, args, options.strTargetPath)) {
             m_longNamePhase = LNE_None;
             m_longNameTempDir.reset();
             m_renameEntries.clear();

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: LiHua000, max-lvs

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

@LiHua000

Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot
deepin-bot Bot merged commit d50fbb9 into linuxdeepin:release/eagle Jul 30, 2026
17 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