hatstand code review update 1

This commit is contained in:
Matthieu Bruel 2020-12-16 10:39:02 +01:00 committed by John Maguire
parent 114802a0ca
commit 41513527cd
2 changed files with 36 additions and 33 deletions

View File

@ -446,24 +446,28 @@ void IncomingDataParser::AppendFilesToPlaylist(const pb::remote::Message& msg) {
if (relative_path.startsWith("/")) relative_path.remove(0, 1); if (relative_path.startsWith("/")) relative_path.remove(0, 1);
QFileInfo fi_folder(root_dir, relative_path); QFileInfo fi_folder(root_dir, relative_path);
if (!fi_folder.exists()) if (!fi_folder.exists()) {
qLog(Warning) << "Remote relative path " << relative_path qLog(Warning) << "Remote relative path " << relative_path
<< " doesn't exist..."; << " doesn't exist...";
else if (!fi_folder.isDir()) return;
} else if (!fi_folder.isDir()) {
qLog(Warning) << "Remote relative path " << relative_path qLog(Warning) << "Remote relative path " << relative_path
<< " is not a directory..."; << " is not a directory...";
else if (root_dir.relativeFilePath(fi_folder.absoluteFilePath()) return;
.startsWith("../")) } else if (root_dir.relativeFilePath(fi_folder.absoluteFilePath())
.startsWith("../")) {
qLog(Warning) << "Remote relative path " << relative_path qLog(Warning) << "Remote relative path " << relative_path
<< " should not be accessed..."; << " should not be accessed...";
else { return;
}
QList<QUrl> urls; QList<QUrl> urls;
QDir dir(fi_folder.absoluteFilePath()); QDir dir(fi_folder.absoluteFilePath());
for (const auto& file : req_append.files()) { for (const auto& file : req_append.files()) {
QFileInfo fi(dir, file.c_str()); QFileInfo fi(dir, file.c_str());
if (fi.exists()) urls << QUrl::fromLocalFile(fi.canonicalFilePath()); if (fi.exists()) urls << QUrl::fromLocalFile(fi.canonicalFilePath());
} }
if (urls.size()) { if (!urls.isEmpty()) {
MimeData* data = new MimeData; MimeData* data = new MimeData;
data->setUrls(urls); data->setUrls(urls);
if (req_append.has_play_now()) data->play_now_ = req_append.play_now(); if (req_append.has_play_now()) data->play_now_ = req_append.play_now();
@ -486,5 +490,4 @@ void IncomingDataParser::AppendFilesToPlaylist(const pb::remote::Message& msg) {
} }
emit AddToPlaylistSignal(data); emit AddToPlaylistSignal(data);
} }
}
} }

View File

@ -185,7 +185,7 @@ void OutgoingDataCreator::SendClementineInfo() {
// allowed extensions for REQUEST_FILES and LIST_FILES // allowed extensions for REQUEST_FILES and LIST_FILES
for (const QString& ext : files_music_extensions_) for (const QString& ext : files_music_extensions_)
*info->add_files_music_extensions() = ext.toStdString(); info->add_files_music_extensions(ext.toStdString());
QString version = QString version =
QString("%1 %2").arg(QCoreApplication::applicationName(), QString("%1 %2").arg(QCoreApplication::applicationName(),