Commit ad31f89e authored by Ragnar Thomsen's avatar Ragnar Thomsen
Browse files

Fix adding subfolders to RAR archives

When adding folders to RAR archives, any subfolders were not added. This
was due to a trailing slash added to the path of subfolders, which
caused rar to not add these to the archive.

BUG: 365323
FIXED-IN: 16.08.0
Differential Revision: D2197
parent 4a8d9ea2
......@@ -1175,24 +1175,13 @@ void Part::slotAddFiles(const QStringList& filesToAdd, const QString& path)
qCDebug(ARK) << "Adding " << filesToAdd << " to " << path;
// Add a trailing slash to directories.
QStringList cleanFilesToAdd(filesToAdd);
for (int i = 0; i < cleanFilesToAdd.size(); ++i) {
QString& file = cleanFilesToAdd[i];
if (QFileInfo(file).isDir()) {
if (!file.endsWith(QLatin1Char( '/' ))) {
file += QLatin1Char( '/' );
}
}
}
// GlobalWorkDir is used by AddJob and should contain the part of the
// absolute path of files to be added that should NOT be included in the
// directory structure within the archive.
// Example: We add file "/home/user/somedir/somefile.txt" and want the file
// to have the relative path within the archive "somedir/somefile.txt".
// GlobalWorkDir is then: "/home/user"
QString globalWorkDir = cleanFilesToAdd.first();
QString globalWorkDir = filesToAdd.first();
// path represents the path of the file within the archive. This needs to
// be removed from globalWorkDir, otherwise the files will be added to the
......@@ -1214,7 +1203,7 @@ void Part::slotAddFiles(const QStringList& filesToAdd, const QString& path)
qCDebug(ARK) << "Detected GlobalWorkDir to be " << globalWorkDir;
options[QStringLiteral("GlobalWorkDir")] = globalWorkDir;
AddJob *job = m_model->addFiles(cleanFilesToAdd, options);
AddJob *job = m_model->addFiles(filesToAdd, options);
if (!job) {
return;
}
......
Supports Markdown
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