Commit 802a3979 authored by Ragnar Thomsen's avatar Ragnar Thomsen

libarchiveplugin: Also set compression level when adding files

Previously, the compresion level was only set when creating new
archives.
parent 50f0cbb4
......@@ -147,18 +147,6 @@ bool ReadWriteLibarchivePlugin::addFiles(const QStringList& files, const Compres
return false;
}
// Set compression level if passed in CompressionOptions.
if (options.contains(QStringLiteral("CompressionLevel"))) {
qCDebug(ARK) << "Using compression level:" << options.value(QStringLiteral("CompressionLevel")).toString();
ret = archive_write_set_filter_option(arch_writer.data(), NULL, "compression-level", options.value(QStringLiteral("CompressionLevel")).toString().toUtf8());
if (ret != ARCHIVE_OK) {
qCWarning(ARK) << "Failed to set compression level";
emit error(xi18nc("@info", "Setting the compression level failed with the following error:<nl/><message>%1</message>",
QLatin1String(archive_error_string(arch_writer.data()))));
return false;
}
}
} else {
switch (archive_filter_code(arch_reader.data(), 0)) {
case ARCHIVE_FILTER_GZIP:
......@@ -210,6 +198,18 @@ bool ReadWriteLibarchivePlugin::addFiles(const QStringList& files, const Compres
}
}
// Set compression level if passed in CompressionOptions.
if (options.contains(QStringLiteral("CompressionLevel"))) {
qCDebug(ARK) << "Using compression level:" << options.value(QStringLiteral("CompressionLevel")).toString();
ret = archive_write_set_filter_option(arch_writer.data(), NULL, "compression-level", options.value(QStringLiteral("CompressionLevel")).toString().toUtf8());
if (ret != ARCHIVE_OK) {
qCWarning(ARK) << "Failed to set compression level";
emit error(xi18nc("@info", "Setting the compression level failed with the following error:<nl/><message>%1</message>",
QLatin1String(archive_error_string(arch_writer.data()))));
return false;
}
}
ret = archive_write_open_fd(arch_writer.data(), tempFile.handle());
if (ret != ARCHIVE_OK) {
emit error(xi18nc("@info", "Opening the archive for writing failed with the following error:<nl/><message>%1</message>",
......
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