Unverified Commit f74fd9d1 authored by Andre Heinecke's avatar Andre Heinecke
Browse files

Fix same disk detection in moveDir

Under some setups it can happen that Qt returns
an empty device for an existing srcDevice. So
this must be checked before renaming to avoid
a move error. This also makes it more robust
to fall back to the copy move in case of
a rename error.

GnuPG-Bug-Id: T6147
parent dbdb8950
......@@ -153,9 +153,13 @@ bool Kleo::recursivelyCopy(const QString &src,const QString &dest)
bool Kleo::moveDir(const QString &src, const QString &dest)
{
if (QStorageInfo(src).device() == QStorageInfo(dest).device()) {
// Easy same partition we can use qt.
return QFile::rename(src, dest);
// Need an existing path to query the device
const QString parentDest = QFileInfo(dest).dir().absolutePath();
const auto srcDevice = QStorageInfo(src).device();
if (!srcDevice.isEmpty() && srcDevice == QStorageInfo(parentDest).device() &&
QFile::rename(src, dest)) {
qCDebug(KLEOPATRA_LOG) << "Renamed" << src << "to" << dest;
return true;
}
// first copy
if (!recursivelyCopy(src, dest)) {
......
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