Commit 070f0bdd authored by Toni Asensi Esteve's avatar Toni Asensi Esteve

Solve large delays browsing big 7z archives

FIXED: [ 425846 ] Too long delays are noticed when entering big 7z files
BUG: 425846

Revision: !28
parent f501bc90
......@@ -1738,7 +1738,9 @@ void kio_krarcProtocol::checkIf7zIsEncrypted(bool &encrypted, QString fileName)
lastData = encryptedArchPath = "";
KrLinecountingProcess proc;
proc << a7zExecutable << "-y" << "t" << fileName;
// Note: That command uses information given in a comment from
// https://stackoverflow.com/questions/5248572/how-do-i-know-if-7zip-used-aes256
proc << a7zExecutable << "l" << "-slt" << fileName;
connect(&proc, &KrLinecountingProcess::newOutputData, this, &kio_krarcProtocol::check7zOutputForPassword);
proc.start();
proc.waitForFinished();
......@@ -1763,13 +1765,14 @@ void kio_krarcProtocol::check7zOutputForPassword(KProcess * proc, QByteArray & b
lastData = lines[ lines.count() - 1 ];
for (int i = 0; i != lines.count(); i++) {
QString line = lines[ i ].trimmed().toLower();
int ndx = line.indexOf("testing");
int ndx = line.indexOf("listing"); // Reminder: Lower-case letters are used
if (ndx >= 0)
line.truncate(ndx);
if (line.isEmpty())
continue;
if (line.contains("password") && line.contains("enter")) {
if ((line.contains("password") && line.contains("enter")) ||
line == QStringLiteral("encrypted = +")) {
KRDEBUG("Encrypted 7z archive found!");
encrypted = true;
proc->kill();
......
......@@ -47,15 +47,17 @@ void Kr7zEncryptionChecker::receivedOutput()
lastData = lines[ lines.count() - 1 ];
for (int i = 0; i != lines.count(); i++) {
QString line = lines[ i ].trimmed().toLower();
int ndx = line.indexOf("testing");
int ndx = line.indexOf("listing"); // Reminder: Lower-case letters are used
if (ndx >= 0)
line.truncate(ndx);
if (line.isEmpty())
continue;
if (line.contains("password") && line.contains("enter")) {
if ((line.contains("password") && line.contains("enter")) ||
line == QStringLiteral("encrypted = +")) {
encrypted = true;
::kill(- pid(), SIGKILL); // kill the whole process group by giving the negative PID
break;
}
}
}
......
......@@ -708,8 +708,9 @@ void KrArcHandler::checkIf7zIsEncrypted(bool &encrypted, QString fileName)
Kr7zEncryptionChecker proc;
// TODO incorporate all this in Kr7zEncryptionChecker
proc << find7zExecutable() << "-y" << "t";
proc << fileName;
// Note: That command uses information given in a comment from
// https://stackoverflow.com/questions/5248572/how-do-i-know-if-7zip-used-aes256
proc << find7zExecutable() << "l" << "-slt" << fileName;
proc.start();
proc.waitForFinished();
encrypted = proc.isEncrypted();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment