Skip to content

fix: ask for the password again after a wrong password - #547

Open
liuwenhuan wants to merge 2 commits into
linuxdeepin:masterfrom
liuwenhuan:fix-wrong-password-retry
Open

liuwenhuan wants to merge 2 commits into
linuxdeepin:masterfrom
liuwenhuan:fix-wrong-password-retry

Conversation

@liuwenhuan

@liuwenhuan liuwenhuan commented Nov 9, 2026 •

Copy link
Copy Markdown

A wrong password ends an extraction or load on the failure page, with "Wrong password, please retry". The retry options are poor:

  • Extract here / Extract to (started from the file manager): Retry is disabled. Back clears the window to an empty home page.
  • Archive opened in the window: Retry goes back to the list, and the user has to click Extract again. Back also clears the window to the empty home page and loses the opened archive.

This PR:

  1. Restarts the same extraction (same destination the user chose, same file-manager mode) or load after a wrong password. The password dialog asks again.
    • It says "Wrong password", using the existing, translated MainWindow string, so no new string is added.
    • The field is marked until the user types.
    • Cancel behaves as before: a file-manager extraction closes, otherwise the window returns to the list.
    • Batch extraction keeps the failure page.
    • A retry that ends without showing the dialog also keeps the failure page, so it cannot loop.
  2. Makes Back on the extraction failure page return to the file list of an archive opened in the window.
  3. Releases the process of the preliminary listing ("Extract here" of a header-encrypted archive) when it fails, so the retry can start a new one.

The first commit, "fix: reset a reused plugin's result when a job starts", is shared with #549, so either PR can be merged alone. ArchiveManager reuses the interface for later operations on the same archive, and the finish type and error type of a failed operation stayed on it: after a wrong password, an extraction that succeeded still ended as PFT_Error, and the window showed "The archive is damaged" (the existing Retry path has the same problem). ReadOnlyArchiveInterface::resetResult() / CliInterface::resetResult() clear them once per job, from SingleJob::start() and UpdateJob::start(); an error found earlier in the same job, such as ET_LongNameError before the long-name extraction refreshes the list, is kept.

Tested on deepin-compressor 6.5.32.3 (Qt 6.8, unrar 7.1.8, 7zip 25.01) with this change backported:

  • RAR5 multi-volume with data encrypted, RAR5 with headers encrypted (-hp), 7z, and zip.
  • Wrong password, then the right one, from "Extract here" and from the window. Every file was extracted and matched its sha256.
  • Cancel in the second dialog.
  • A long-file-name failure followed by Back, which returned to the list.
  • After the review, with the revised change on the same 6.5.32 build: "Extract here" of a -hp RAR (wrong, then right password), extraction in the window to the chosen folder (wrong, then right: no extra folder level), a 7z entry with a 300-byte name (success page still says the name was shortened), and a damaged -hp RAR ("The archive is damaged").

This PR compiles on master (6.5.40, Qt 6.8.2). It was not run on master.


输错密码后,解压或加载直接进入失败页。从文件管理器启动时"重试"不可用,"返回"会回到空白首页。本 PR 改为以同样方式重新解压或加载,密码框再次弹出并提示"密码错误"。在窗口中打开的压缩包解压失败后,"返回"会回到文件列表。第一个提交(与 #549 共用)在每个任务开始时重置复用插件对象的结果:以前输错密码后再次解压成功,仍会提示"压缩包已损坏"。

Summary by Sourcery

Retry password-protected archive operations in place after incorrect credentials while preserving the correct archive state and navigation behavior.

New Features:

  • Retry archive loading and extraction after an incorrect password by reopening the password prompt with a clear error indication.
  • Return to an opened archive’s file list from the extraction failure page.

Bug Fixes:

  • Prevent reused archive interfaces from carrying failure results into subsequent successful operations, avoiding incorrect damaged-archive errors.
  • Preserve existing failure-page behavior for batch extraction and retries that do not reach a password prompt.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T01:30:37.959271Z 2d82f24 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@sourcery-ai

sourcery-ai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Data structures

Add a reset operation to the archive interface and its CLI implementation so each new job clears stale error and finish results.

  • 3rdparty/interface/archiveinterface/archiveinterface.cpp L79-83
  • 3rdparty/interface/archiveinterface/archiveinterface.h L119-124
  • 3rdparty/interface/archiveinterface/cliinterface.cpp L69-74
  • 3rdparty/interface/archiveinterface/cliinterface.h L69-74

API

Expose retry handling for wrong-password job failures and retain the unanswered-prompt state and chosen extraction destination needed by that behavior.

  • src/source/mainwindow.h L188-194, L589-590

Uses of the API

Reset reused archive-interface results once when each single or update job starts, preserving errors that arise later within that job.

  • src/source/archivemanager/singlejob.cpp L59-62, L539-542

Implementation

Release a failed CLI process and add password-query state that can carry a wrong-password hint to the next prompt.

  • 3rdparty/interface/archiveinterface/cliinterface.cpp L793-795
  • 3rdparty/interface/queries.cpp L16, L463-474
  • 3rdparty/interface/queries.h L252-264

Retry the same load or extraction after a wrong password, prevent repeated retries when no prompt was shown, preserve the chosen destination, and restore the open archive list on Back.

  • src/source/mainwindow.cpp L1326-1330, L1370-1417, L3609-3615 (+2 small edits)

UI

Show a translated wrong-password hint and mark the password field until the user edits it.

  • 3rdparty/interface/queries.cpp L530-540

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 reviewed your changes and they look great!


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

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2d82f2453e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/source/mainwindow.cpp
Comment on lines +1408 to +1409
QTimer::singleShot(0, this, [this, strPath]() {
slotUncompressClicked(strPath);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid adding the archive folder again on password retry

With automatic folder creation enabled (the default), m_stUnCompressParameter.strExtractPath already includes the archive-named folder added by slotUncompressClicked(). Passing that effective destination back into the same slot appends the folder again: extracting a.zip to /dest after one wrong password writes to /dest/a/a instead of /dest/a, and each subsequent wrong password adds another level. This can also separate files extracted before the password failure from those extracted afterward. Preserve the original base destination or restart with the saved extraction options rather than reapplying destination construction.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Agreed. The retry now uses the destination the user chose (m_strUncompressBasePath, saved at the start of slotUncompressClicked()) instead of m_stUnCompressParameter.strExtractPath, so the archive-named folder is added once.

Comment thread src/source/mainwindow.cpp
Comment on lines +1394 to +1395
QTimer::singleShot(0, this, [this, eType, strArchive]() {
rightExtract2Path(eType, QStringList() << strArchive);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Release the failed listing process before restarting extraction

For a file-manager extraction that first runs the preliminary tmpList process, such as a header-encrypted 7z/RAR on a non-LNFS target, a wrong password leaves m_process allocated: the nonzero-exit branch in CliInterface::runProcess() emits failure without calling deleteProcess(). This retry reuses that interface through ArchiveManager::extractFiles(), so the next runProcess() trips Q_ASSERT(!m_process) in assertion-enabled builds; release builds overwrite and leak the process pointer instead. Clean up the failed preliminary process or recreate the interface before restarting.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Agreed. When the preliminary tmpList listing fails, the finished handler now calls deleteProcess() before reporting PFT_Error, so the retry starts with no process left on the interface (no Q_ASSERT(!m_process) failure, no leak).

1. ArchiveManager reuses the plugin interface for later operations on the
   same archive. The finish type and the error type of a failed operation
   stayed on the interface, so the next operation could end with the old
   error: after a wrong password, extracting again with the right
   password reported "The archive is damaged".
2. ReadOnlyArchiveInterface::resetResult() clears the error type;
   CliInterface also clears the finish type. SingleJob::start() and
   UpdateJob::start() call it, once per job, so an error found earlier in
   the same job (for example ET_LongNameError before the long-name
   extraction refreshes the list) is kept.

Log: Forget the result of the previous operation when a new one starts.

Influence:
1. Extract an encrypted archive with a wrong password, then with the
   right one: the second extraction succeeds.
2. Extracting a file with a long name still reports the long-name case.

fix: 任务开始时重置复用插件的结果

1. ArchiveManager 对同一压缩包的后续操作复用插件对象。失败操作的结束类型
   和错误类型留在插件对象上,下一次操作可能带着旧错误结束:输错密码后再用
   正确密码解压,提示"压缩包已损坏"。
2. ReadOnlyArchiveInterface::resetResult() 清除错误类型,CliInterface 还
   清除结束类型。SingleJob::start() 和 UpdateJob::start() 每个任务调用一
   次,因此同一任务中较早发现的错误(如长文件名解压刷新列表前设置的
   ET_LongNameError)得以保留。

Log: 新操作开始时清除上一次操作的结果。

Influence:
1. 加密压缩包先输错密码再输对密码解压:第二次解压成功。
2. 解压长文件名文件仍按长文件名情况处理。
1. A wrong password ended an extraction or load on the failure page.
   Started from the file manager (extract here / extract to) its Retry
   button was disabled, and Back cleared the window to an empty home
   page, also when the archive had been opened in the window.
2. Now a wrong password restarts the same extraction (same destination
   the user chose, same file-manager mode) or load, and the password dialog asks again with
   "Wrong password" (the existing, translated MainWindow string) and the
   field marked until the user types. Cancel behaves as before. Batch
   extraction keeps the failure page, and so does a retry that ends
   without showing the dialog, so it cannot loop.
3. Back on the extraction failure page returns to the file list of an
   archive opened in the window.
4. When the preliminary listing of "Extract here" fails, the plugin
   releases its process, so the retry can start a new one.
5. The retry needs "fix: reset a reused plugin's result when a job
   starts": without it the extraction after the right password ends
   with the previous run's error.

Log: Ask for the password again after a wrong password instead of failing.

Influence:
1. RAR (data or headers encrypted), 7z and zip: enter a wrong password,
   then the right one, from "Extract here" and from the window.
2. Cancel the second password dialog.
3. A failed extraction of an opened archive, then Back.

fix: 密码错误后重新询问密码

1. 输错密码后解压或加载直接进入失败页面。从文件管理器"解压到当前文件夹"
   启动时重试按钮不可用,返回按钮会清空窗口回到空白首页,在窗口中打开的
   压缩包也一样。
2. 现在输错密码会以相同方式(用户选择的同一目标位置)重新解压或加载,密码框再次弹出并提示"密码错误"
   (复用已翻译的 MainWindow 字符串),输入框标红直到重新输入。取消的行为
   不变。批量解压仍显示失败页;重试后未弹出密码框即结束时也显示失败页,
   不会循环。
3. 在窗口中打开的压缩包解压失败后,返回按钮回到文件列表。
4. "解压到当前文件夹"的预先列出失败时,插件释放其进程,重试才能启动新进程。
5. 重试依赖"fix: 任务开始时重置复用插件的结果":否则输对密码后的解压仍以上
   一次的错误结束。

Log: 输错密码后重新询问密码,而不是直接失败。

Influence:
1. RAR(加密数据或文件头)、7z、zip:先输错再输对,分别从"解压到当前
   文件夹"和窗口中解压。
2. 第二次密码框点取消。
3. 在窗口中打开的压缩包解压失败后点返回。
@liuwenhuan
liuwenhuan force-pushed the fix-wrong-password-retry branch from 2d82f24 to 1b5fa90 Compare November 9, 2026 05:42
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: liuwenhuan

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

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