Use the canonical file path (resolve symlinks and '..') when adding directories to the library, and when adding files to the playlist. Fixes issue #1494
This commit is contained in:
parent
3d593e696c
commit
002ae13817
|
@ -192,7 +192,7 @@ bool CommandlineOptions::Parse() {
|
||||||
if (value.contains("://"))
|
if (value.contains("://"))
|
||||||
urls_ << value;
|
urls_ << value;
|
||||||
else
|
else
|
||||||
urls_ << QUrl::fromLocalFile(QFileInfo(value).absoluteFilePath());
|
urls_ << QUrl::fromLocalFile(QFileInfo(value).canonicalFilePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -22,12 +22,13 @@
|
||||||
#include "core/scopedtransaction.h"
|
#include "core/scopedtransaction.h"
|
||||||
#include "smartplaylists/search.h"
|
#include "smartplaylists/search.h"
|
||||||
|
|
||||||
#include <QDir>
|
|
||||||
#include <QVariant>
|
|
||||||
#include <QSettings>
|
|
||||||
#include <QtDebug>
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
const char* LibraryBackend::kNewScoreSql =
|
const char* LibraryBackend::kNewScoreSql =
|
||||||
"case when playcount <= 0 then (%1 * 100 + score) / 2"
|
"case when playcount <= 0 then (%1 * 100 + score) / 2"
|
||||||
|
@ -178,18 +179,20 @@ void LibraryBackend::UpdateTotalSongCount() {
|
||||||
emit TotalSongCountUpdated(q.value(0).toInt());
|
emit TotalSongCountUpdated(q.value(0).toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryBackend::AddDirectory(const QString &path) {
|
void LibraryBackend::AddDirectory(const QString& path) {
|
||||||
|
QString canonical_path = QFileInfo(path).canonicalFilePath();
|
||||||
|
|
||||||
QMutexLocker l(db_->Mutex());
|
QMutexLocker l(db_->Mutex());
|
||||||
QSqlDatabase db(db_->Connect());
|
QSqlDatabase db(db_->Connect());
|
||||||
|
|
||||||
QSqlQuery q(QString("INSERT INTO %1 (path, subdirs)"
|
QSqlQuery q(QString("INSERT INTO %1 (path, subdirs)"
|
||||||
" VALUES (:path, 1)").arg(dirs_table_), db);
|
" VALUES (:path, 1)").arg(dirs_table_), db);
|
||||||
q.bindValue(":path", path);
|
q.bindValue(":path", canonical_path);
|
||||||
q.exec();
|
q.exec();
|
||||||
if (db_->CheckErrors(q)) return;
|
if (db_->CheckErrors(q)) return;
|
||||||
|
|
||||||
Directory dir;
|
Directory dir;
|
||||||
dir.path = path;
|
dir.path = canonical_path;
|
||||||
dir.id = q.lastInsertId().toInt();
|
dir.id = q.lastInsertId().toInt();
|
||||||
|
|
||||||
emit DirectoryDiscovered(dir, SubdirectoryList());
|
emit DirectoryDiscovered(dir, SubdirectoryList());
|
||||||
|
|
|
@ -1342,7 +1342,7 @@ void MainWindow::AddFile() {
|
||||||
// Convert to URLs
|
// Convert to URLs
|
||||||
QList<QUrl> urls;
|
QList<QUrl> urls;
|
||||||
foreach (const QString& path, file_names) {
|
foreach (const QString& path, file_names) {
|
||||||
urls << QUrl::fromLocalFile(path);
|
urls << QUrl::fromLocalFile(QFileInfo(path).canonicalFilePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
MimeData* data = new MimeData;
|
MimeData* data = new MimeData;
|
||||||
|
@ -1364,7 +1364,7 @@ void MainWindow::AddFolder() {
|
||||||
|
|
||||||
// Add media
|
// Add media
|
||||||
MimeData* data = new MimeData;
|
MimeData* data = new MimeData;
|
||||||
data->setUrls(QList<QUrl>() << QUrl::fromLocalFile(directory));
|
data->setUrls(QList<QUrl>() << QUrl::fromLocalFile(QFileInfo(directory).canonicalFilePath()));
|
||||||
AddToPlaylist(data);
|
AddToPlaylist(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ QList<QUrl> FileViewList::UrlListFromSelection() const {
|
||||||
foreach (const QModelIndex& index, menu_selection_.indexes()) {
|
foreach (const QModelIndex& index, menu_selection_.indexes()) {
|
||||||
if (index.column() == 0)
|
if (index.column() == 0)
|
||||||
urls << QUrl::fromLocalFile(
|
urls << QUrl::fromLocalFile(
|
||||||
static_cast<QFileSystemModel*>(model())->filePath(index));
|
static_cast<QFileSystemModel*>(model())->fileInfo(index).canonicalFilePath());
|
||||||
}
|
}
|
||||||
return urls;
|
return urls;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue