Commit b7789735 authored by Albert Astals Cid's avatar Albert Astals Cid

Warn when trying to add folders that contain unsupported filenames

In Qt anything that is not propertly utf8 is transparently not returned,
i.e. QDir will simply pretend the file doesn't exist.

This isn't ideal since people may be asuming a backup is totally done
since no error was reported and one file was not really copied.

This doesn't fix the fact that the file is not copied but at least warns
the file could not by found.

It does so by using KIO::listDir instead of QDir

BUGS: 428115
(cherry picked from commit 22b1d093)
parent c60c656e
......@@ -39,6 +39,7 @@
#include <KLocalizedString>
#include <KMessageBox>
#include <KStandardGuiItem>
#include <kio/listjob.h>
#include <QDir>
#include <QFileInfo>
......@@ -523,9 +524,15 @@ void K3b::DataUrlAddingDialog::slotAddUrls()
dir->addDataItem( newDirItem );
}
QDir newDir( absoluteFilePath );
foreach( const QString& dir, newDir.entryList( QDir::AllEntries|QDir::Hidden|QDir::System|QDir::NoDotAndDotDot ) ) {
m_urlQueue.append( qMakePair( QUrl::fromLocalFile(absoluteFilePath + '/' + dir ), newDirItem ) );
KIO::ListJob *lj = KIO::listDir(QUrl::fromLocalFile(absoluteFilePath), KIO::HideProgressInfo);
KIO::UDSEntryList list;
connect(lj, &KIO::ListJob::entries, this, [&](KIO::Job *, const KIO::UDSEntryList &l) { list = l; });
lj->exec();
foreach( const KIO::UDSEntry& entry, list ) {
const QString fileName = entry.stringValue( KIO::UDSEntry::UDS_NAME );
if (fileName != QStringLiteral(".") && fileName != QStringLiteral("..")) {
m_urlQueue.append( qMakePair( QUrl::fromLocalFile(absoluteFilePath + '/' + fileName ), newDirItem ) );
}
}
}
else {
......
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