Fix: [zipplugin] Show password error.#326
Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:develop/snipefrom Nov 21, 2025
Merged
Fix: [zipplugin] Show password error.#326deepin-bot[bot] merged 1 commit intolinuxdeepin:develop/snipefrom
deepin-bot[bot] merged 1 commit intolinuxdeepin:develop/snipefrom
Conversation
-- When enter the right password, show password error. -- Not judge the Second password, so add code logic the adjust it. Log: fix issue Bug: https://pms.uniontech.com/bug-view-329305.html
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe patch enhances the password handling in extractFiles by introducing a tracking index for password prompts, ensuring that a second failed entry for the same file triggers an immediate error return instead of re-prompting indefinitely. Sequence diagram for improved password error handling during extractionsequenceDiagram
participant LibzipPlugin_extractFiles
participant PasswordNeededQuery
participant User
participant zip_archive
LibzipPlugin_extractFiles->>zip_archive: Attempt to extract file
alt Password required or wrong password
LibzipPlugin_extractFiles->>PasswordNeededQuery: Prompt for password
PasswordNeededQuery->>User: Request password
User->>PasswordNeededQuery: Enter password
PasswordNeededQuery->>LibzipPlugin_extractFiles: Return password
LibzipPlugin_extractFiles->>zip_archive: Set password and retry
alt Second wrong password for same file
LibzipPlugin_extractFiles->>zip_archive: Close archive
LibzipPlugin_extractFiles->>User: Show password error
else Password correct or first wrong attempt
LibzipPlugin_extractFiles->>zip_archive: Retry extraction
end
end
Class diagram for updated password handling in LibzipPluginclassDiagram
class LibzipPlugin {
+extractFiles(files, options)
-m_eErrorType
-m_strPassword
-m_bCancel
+signalQuery(query)
}
class PasswordNeededQuery {
+password()
+waitForResponse()
}
LibzipPlugin "1" -- "1" PasswordNeededQuery : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review我来帮你审查这段代码的修改。这段代码主要处理压缩文件解压时的密码验证逻辑。
具体改进建议: // 建议将密码验证逻辑抽取为单独的函数
bool handlePasswordValidation(zip_int64_t currentIndex, zip_int64_t &lastNeedPasswordIndex, zip *archive, const QString &strFileName) {
// 如果是同一文件的密码重试,直接返回失败
if (lastNeedPasswordIndex == currentIndex) {
zip_close(archive);
m_strPassword = "";
return false;
}
PasswordNeededQuery query(strFileName);
emit signalQuery(&query);
query.waitForResponse();
if (query.responseCancelled()) {
return false;
} else {
setPassword(query.password());
zip_set_default_password(archive, m_strPassword.toUtf8().constData());
lastNeedPasswordIndex = currentIndex;
return true;
}
}
// 在主函数中使用
if (ET_WrongPassword == m_eErrorType || ET_NeedPassword == m_eErrorType) {
if (!handlePasswordValidation(i, lastNeedPasswordIndex, archive, strFileName)) {
return PFT_Error;
}
i--; // 重试当前文件
}这样改进后的代码:
总体来说,原始修改是合理的,主要解决了密码验证时的无限循环问题。建议的改进主要是从代码组织和可维护性角度出发。 |
lzwind
approved these changes
Nov 21, 2025
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Contributor
Author
|
/merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
-- When enter the right password, show password error. -- Not judge the Second password, so add code logic the adjust it.
Log: fix issue
Bug: https://pms.uniontech.com/bug-view-329305.html
Summary by Sourcery
Bug Fixes: