Commit 7f65f911 authored by Ragnar Thomsen's avatar Ragnar Thomsen
Browse files

Handle "no space left" messages from cliplugins

Previously, Ark didn't handle "no space left" error messages from the
cliplugins. This resulted in either the gui being "busy" continously
(clizip), or that the user didn't get any indication that there was a
problem extracting the archive (cli7z and clirar).

This commit adds a pattern (DiskFullPatterns) for catching these errors.
An errorbox is then displayed to the user. Some of the programs used in
the cliplugins, such as 7z v9.38, doesn't output a specific message,
but then a generic "Extraction failed" message is displayed instead.

BUG: 206383, 206385
FIXED-IN: 16.04.0

Differential Revision: D455
parent 5d56d0c6
......@@ -787,6 +787,7 @@ void CliInterface::readStdout(bool handleAll)
bool foundErrorMessage =
(wrongPasswordMessage ||
checkForErrorMessage(QLatin1String(lines.last()), DiskFullPatterns) ||
checkForErrorMessage(QLatin1String(lines.last()), ExtractionFailedPatterns) ||
checkForPasswordPromptMessage(QLatin1String(lines.last())) ||
checkForErrorMessage(QLatin1String(lines.last()), FileExistsExpression));
......@@ -839,6 +840,7 @@ void CliInterface::handleLine(const QString& line)
}
if (m_operationMode == Copy) {
if (checkForPasswordPromptMessage(line)) {
qCDebug(ARK) << "Found a password prompt";
......@@ -860,6 +862,13 @@ void CliInterface::handleLine(const QString& line)
return;
}
if (checkForErrorMessage(line, DiskFullPatterns)) {
qCWarning(ARK) << "Found disk full message:" << line;
emit error(i18nc("@info", "Extraction failed because the disk is full."));
failOperation();
return;
}
if (checkForErrorMessage(line, WrongPasswordPatterns)) {
qCWarning(ARK) << "Wrong password!";
setPassword(QString());
......@@ -869,7 +878,7 @@ void CliInterface::handleLine(const QString& line)
}
if (checkForErrorMessage(line, ExtractionFailedPatterns)) {
qCWarning(ARK) << "Error in extraction!!";
qCWarning(ARK) << "Error in extraction:" << line;
emit error(i18n("Extraction failed because of an unexpected error."));
failOperation();
return;
......
......@@ -181,6 +181,11 @@ enum CliInterfaceParameters {
* index 4 - Cancel operation
*/
FileExistsInput,
/**
* QStringList
* Regexp patterns capturing disk is full error messages.
*/
DiskFullPatterns,
///////////////[ DELETE ]/////////////
......
......@@ -93,10 +93,11 @@ ParameterList CliPlugin::parameterList() const
<< QStringLiteral("A") //overwrite all
<< QStringLiteral("S") //autoskip
<< QStringLiteral("Q"); //cancel
p[PasswordPromptPattern] = QStringLiteral("Enter password \\(will not be echoed\\)");
p[ExtractionFailedPatterns] = QStringList() << QStringLiteral("ERROR: E_FAIL");
p[CorruptArchivePatterns] = QStringList() << QStringLiteral("Unexpected end of archive")
<< QStringLiteral("Headers Error");
p[DiskFullPatterns] = QStringList() << QStringLiteral("No space left on device");
}
return p;
......
/*
/*
* ark -- archiver for the KDE project
*
* Copyright (C) 2009 Harald Hvaal <haraldhv@stud.ntnu.no>
......@@ -119,6 +119,7 @@ ParameterList CliPlugin::parameterList() const
<< QStringLiteral( "Cannot find volume" );
p[CorruptArchivePatterns] = QStringList() << QStringLiteral("Unexpected end of archive")
<< QStringLiteral("the file header is corrupt");
p[DiskFullPatterns] = QStringList() << QStringLiteral("No space left on device");
}
return p;
......
......@@ -118,6 +118,8 @@ ParameterList CliPlugin::parameterList() const
p[WrongPasswordPatterns] = QStringList() << QStringLiteral("incorrect password");
//p[ExtractionFailedPatterns] = QStringList() << "CRC failed";
p[CorruptArchivePatterns] = QStringList() << QStringLiteral("End-of-central-directory signature not found");
p[DiskFullPatterns] = QStringList() << QStringLiteral("write error \\(disk full\\?\\)")
<< QStringLiteral("No space left on device");
}
return p;
}
......
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