From 74e2283aa0730767d4890b0e7a8f8f8cb7db4ca8 Mon Sep 17 00:00:00 2001 From: Daniel Tartavel Date: Fri, 18 Oct 2024 15:52:13 +0200 Subject: [PATCH] resolved bug with space in filename --- downloadfile.cpp | 2 +- mainwindow.cpp | 19 ++++++++++++------- tools.cpp | 5 +++++ tools.h | 1 + 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/downloadfile.cpp b/downloadfile.cpp index 37a2e57..951f131 100644 --- a/downloadfile.cpp +++ b/downloadfile.cpp @@ -74,7 +74,7 @@ void MainWindow::download() param << "--port" << QString::number(this->downloading.port).trimmed(); param << "-aXP"; - param << "[" + server + "]::" + this->downloading.service.trimmed() + "/" + this->downloading.path.trimmed() << this->downloading.savePath.trimmed() + "/"; + param << "\"[" + server + "]::" + this->downloading.service.trimmed() + "/" + preparePath(this->downloading.path) << preparePath(this->downloading.savePath) + "/"; info(DEBUGMACRO, cmd + " " + param.join(" ")); diff --git a/mainwindow.cpp b/mainwindow.cpp index 646e1bc..5420a52 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -486,7 +486,7 @@ bool MainWindow::testServerPresence(QString service, bool askPassword) { param << "-" + QString::number(this->connexion.ipversion); } - param << "--contimeout=10" << "-nq" << "--port=" + QString::number(this->connexion.port) << + "[" + this->connexion.server + "]::" + service; + param << "--contimeout=10" << "-nq" << "--port=" + QString::number(this->connexion.port) << + "[" + this->connexion.server + "]::" + preparePath(service); myProcess = new QProcess(this); myProcess->setProcessChannelMode(QProcess::MergedChannels); myProcess->start(cmd, param); @@ -623,10 +623,11 @@ bool MainWindow::scanDir(Connexion * connexion, QTreeWidgetItem *parent, QString static uint looping; QStringList dirs; QString server = connexion->server; + bool ret = false; info(DEBUGMACRO, "scandir() => connect to rsync server to get list of files"); - QGuiApplication::setOverrideCursor(Qt::WaitCursor); + ui->listWidget->setCursor(Qt::WaitCursor); myProcess = new QProcess(this); myProcess->setProcessChannelMode(QProcess::MergedChannels); @@ -656,7 +657,7 @@ bool MainWindow::scanDir(Connexion * connexion, QTreeWidgetItem *parent, QString user = "anonymous@"; env.insert("RSYNC_PASSWORD", "anonymous"); // Add an environment variable } - param << "--contimeout=20" << "--port=" + QString::number(connexion->port) << user + "[" + server + "]::" + path; + param << "--contimeout=20" << "--port=" + QString::number(connexion->port) << user + "[" + server + "]::" + preparePath(path) ; info(DEBUGMACRO, cmd + " " + param.join(" ")); @@ -757,12 +758,12 @@ bool MainWindow::scanDir(Connexion * connexion, QTreeWidgetItem *parent, QString }while(readOk); // buffer empty go to waiting new datas - testRsyncReturn(this, myProcess); + ret = testRsyncReturn(this, myProcess); myProcess->close(); } ui->listWidget->setCursor(Qt::ArrowCursor); - return false; + return ret; } // validate address server @@ -1027,6 +1028,7 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadD QString str; QMessageBox::StandardButton reply; int sizeFromRsync; + bool ret = false; info(DEBUGMACRO, "on_treeWidget_itemClicked() => Slot activated when a file is clicked in the treeview"); @@ -1151,8 +1153,11 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadD //if (this->rescan) //{ info(DEBUGMACRO, "Re-scanning path: " + this->connexion.service + "/" + path +"/"); - scanDir(&this->connexion, item, this->connexion.service + "/" + path +"/"); - item->setExpanded(true); + ret = scanDir(&this->connexion, item, this->connexion.service + "/" + path +"/"); + if(!ret) + { + item->setExpanded(true); + } //} }else { diff --git a/tools.cpp b/tools.cpp index 55afc9f..c6c816d 100644 --- a/tools.cpp +++ b/tools.cpp @@ -53,6 +53,11 @@ QString getFileType(QString filename) return returnValue; } +QString preparePath(QString path) +{ + return path.trimmed().replace(' ', "\ "); +} + int whatIpVersion(QString ipAddress) { QStringList fieldList; diff --git a/tools.h b/tools.h index 6feca4a..cfee902 100644 --- a/tools.h +++ b/tools.h @@ -22,5 +22,6 @@ int whatIpVersion(QString server); void warning(QString message); void error(QString message); void info(QString debugHeader, QString message); +QString preparePath(QString path); #endif // TOOLS_H