Skip to content

Commit 2d870ff

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 290fed2 commit 2d870ff

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
@@ -168,6 +168,7 @@ PluginFinishType LibzipPlugin::extractFiles(const QList<FileEntry> &files, const
168168
if (options.bAllExtract) { // 全部解压
169169
qlonglong qExtractSize = 0;
170170
zip_int64_t nofEntries = zip_get_num_entries(archive, 0);
171+
zip_int64_t lastNeedPasswordIndex = -1;
171172
for (zip_int64_t i = 0; i < nofEntries; ++i) {
172173
if (QThread::currentThread()->isInterruptionRequested()) {
173174
m_bCancel = false; // 重置标志位
@@ -192,14 +193,16 @@ PluginFinishType LibzipPlugin::extractFiles(const QList<FileEntry> &files, const
192193
zip_close(archive);
193194
return PFT_Cancel;
194195
} else { // 处理错误
195-
//密码错误, 给出错误提示
196-
if(ET_WrongPassword == m_eErrorType && !m_strPassword.isEmpty()) {
197-
zip_close(archive);
198-
m_strPassword = "";
199-
return PFT_Error;
200-
}
201196
// 判断是否需要密码,若需要密码,弹出密码输入对话框,用户输入密码之后,重新解压当前文件
202197
if (ET_WrongPassword == m_eErrorType || ET_NeedPassword == m_eErrorType) {
198+
199+
// 询问输入密码后,仍然输入错误密码,则直接返回,给出错误提示
200+
if (lastNeedPasswordIndex == i) {
201+
zip_close(archive);
202+
m_strPassword = "";
203+
return PFT_Error;
204+
}
205+
203206
PasswordNeededQuery query(strFileName);
204207
emit signalQuery(&query);
205208
query.waitForResponse();
@@ -211,6 +214,7 @@ PluginFinishType LibzipPlugin::extractFiles(const QList<FileEntry> &files, const
211214
} else {
212215
setPassword(query.password());
213216
zip_set_default_password(archive, m_strPassword.toUtf8().constData());
217+
lastNeedPasswordIndex = i;
214218
i--;
215219
}
216220
} else {

0 commit comments

Comments
 (0)