resolved bug with space in filename

This commit is contained in:
Daniel Tartavel 2024-10-18 15:52:13 +02:00
parent 67fb0a4b7e
commit 74e2283aa0
4 changed files with 19 additions and 8 deletions

View File

@ -74,7 +74,7 @@ void MainWindow::download()
param << "--port" << QString::number(this->downloading.port).trimmed(); param << "--port" << QString::number(this->downloading.port).trimmed();
param << "-aXP"; 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(" ")); info(DEBUGMACRO, cmd + " " + param.join(" "));

View File

@ -486,7 +486,7 @@ bool MainWindow::testServerPresence(QString service, bool askPassword)
{ {
param << "-" + QString::number(this->connexion.ipversion); 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 = new QProcess(this);
myProcess->setProcessChannelMode(QProcess::MergedChannels); myProcess->setProcessChannelMode(QProcess::MergedChannels);
myProcess->start(cmd, param); myProcess->start(cmd, param);
@ -623,10 +623,11 @@ bool MainWindow::scanDir(Connexion * connexion, QTreeWidgetItem *parent, QString
static uint looping; static uint looping;
QStringList dirs; QStringList dirs;
QString server = connexion->server; QString server = connexion->server;
bool ret = false;
info(DEBUGMACRO, "scandir() => connect to rsync server to get list of files"); 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 = new QProcess(this);
myProcess->setProcessChannelMode(QProcess::MergedChannels); myProcess->setProcessChannelMode(QProcess::MergedChannels);
@ -656,7 +657,7 @@ bool MainWindow::scanDir(Connexion * connexion, QTreeWidgetItem *parent, QString
user = "anonymous@"; user = "anonymous@";
env.insert("RSYNC_PASSWORD", "anonymous"); // Add an environment variable 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(" ")); info(DEBUGMACRO, cmd + " " + param.join(" "));
@ -757,12 +758,12 @@ bool MainWindow::scanDir(Connexion * connexion, QTreeWidgetItem *parent, QString
}while(readOk); }while(readOk);
// buffer empty go to waiting new datas // buffer empty go to waiting new datas
testRsyncReturn(this, myProcess); ret = testRsyncReturn(this, myProcess);
myProcess->close(); myProcess->close();
} }
ui->listWidget->setCursor(Qt::ArrowCursor); ui->listWidget->setCursor(Qt::ArrowCursor);
return false; return ret;
} }
// validate address server // validate address server
@ -1027,6 +1028,7 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadD
QString str; QString str;
QMessageBox::StandardButton reply; QMessageBox::StandardButton reply;
int sizeFromRsync; int sizeFromRsync;
bool ret = false;
info(DEBUGMACRO, "on_treeWidget_itemClicked() => Slot activated when a file is clicked in the treeview"); 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) //if (this->rescan)
//{ //{
info(DEBUGMACRO, "Re-scanning path: " + this->connexion.service + "/" + path +"/"); info(DEBUGMACRO, "Re-scanning path: " + this->connexion.service + "/" + path +"/");
scanDir(&this->connexion, item, this->connexion.service + "/" + path +"/"); ret = scanDir(&this->connexion, item, this->connexion.service + "/" + path +"/");
item->setExpanded(true); if(!ret)
{
item->setExpanded(true);
}
//} //}
}else }else
{ {

View File

@ -53,6 +53,11 @@ QString getFileType(QString filename)
return returnValue; return returnValue;
} }
QString preparePath(QString path)
{
return path.trimmed().replace(' ', "\ ");
}
int whatIpVersion(QString ipAddress) int whatIpVersion(QString ipAddress)
{ {
QStringList fieldList; QStringList fieldList;

View File

@ -22,5 +22,6 @@ int whatIpVersion(QString server);
void warning(QString message); void warning(QString message);
void error(QString message); void error(QString message);
void info(QString debugHeader, QString message); void info(QString debugHeader, QString message);
QString preparePath(QString path);
#endif // TOOLS_H #endif // TOOLS_H