Skip to content

Commit f26897c

Browse files
GongHeng2017deepin-bot[bot]
authored andcommitted
Fix: [zipplugin] Show password error.
-- 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
1 parent b107a2d commit f26897c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

3rdparty/libzipplugin/libzipplugin.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ PluginFinishType LibzipPlugin::extractFiles(const QList<FileEntry> &files, const
171171
if (options.bAllExtract) { // 全部解压
172172
qlonglong qExtractSize = 0;
173173
zip_int64_t nofEntries = zip_get_num_entries(archive, 0);
174+
zip_int64_t lastNeedPasswordIndex = -1;
174175
for (zip_int64_t i = 0; i < nofEntries; ++i) {
175176
if (QThread::currentThread()->isInterruptionRequested()) {
176177
m_bCancel = false; // 重置标志位
@@ -195,14 +196,16 @@ PluginFinishType LibzipPlugin::extractFiles(const QList<FileEntry> &files, const
195196
zip_close(archive);
196197
return PFT_Cancel;
197198
} else { // 处理错误
198-
// 密码错误, 给出错误提示
199-
if(ET_WrongPassword == m_eErrorType && !m_strPassword.isEmpty()) {
200-
zip_close(archive);
201-
m_strPassword = "";
202-
return PFT_Error;
203-
}
204199
// 判断是否需要密码,若需要密码,弹出密码输入对话框,用户输入密码之后,重新解压当前文件
205200
if (ET_WrongPassword == m_eErrorType || ET_NeedPassword == m_eErrorType) {
201+
202+
// 询问输入密码后,仍然输入错误密码,则直接返回,给出错误提示
203+
if (lastNeedPasswordIndex == i) {
204+
zip_close(archive);
205+
m_strPassword = "";
206+
return PFT_Error;
207+
}
208+
206209
PasswordNeededQuery query(strFileName);
207210
emit signalQuery(&query);
208211
query.waitForResponse();
@@ -214,6 +217,7 @@ PluginFinishType LibzipPlugin::extractFiles(const QList<FileEntry> &files, const
214217
} else {
215218
setPassword(query.password());
216219
zip_set_default_password(archive, m_strPassword.toUtf8().constData());
220+
lastNeedPasswordIndex = i;
217221
i--;
218222
}
219223
} else {

0 commit comments

Comments
 (0)