mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-31 19:45:31 +01:00
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("://"))
|
||||
urls_ << value;
|
||||
else
|
||||
urls_ << QUrl::fromLocalFile(QFileInfo(value).absoluteFilePath());
|
||||
urls_ << QUrl::fromLocalFile(QFileInfo(value).canonicalFilePath());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -22,12 +22,13 @@
|
||||
#include "core/scopedtransaction.h"
|
||||
#include "smartplaylists/search.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QVariant>
|
||||
#include <QSettings>
|
||||
#include <QtDebug>
|
||||
#include <QCoreApplication>
|
||||
#include <QDateTime>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QSettings>
|
||||
#include <QVariant>
|
||||
#include <QtDebug>
|
||||
|
||||
const char* LibraryBackend::kNewScoreSql =
|
||||
"case when playcount <= 0 then (%1 * 100 + score) / 2"
|
||||
@ -178,18 +179,20 @@ void LibraryBackend::UpdateTotalSongCount() {
|
||||
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());
|
||||
QSqlDatabase db(db_->Connect());
|
||||
|
||||
QSqlQuery q(QString("INSERT INTO %1 (path, subdirs)"
|
||||
" VALUES (:path, 1)").arg(dirs_table_), db);
|
||||
q.bindValue(":path", path);
|
||||
q.bindValue(":path", canonical_path);
|
||||
q.exec();
|
||||
if (db_->CheckErrors(q)) return;
|
||||
|
||||
Directory dir;
|
||||
dir.path = path;
|
||||
dir.path = canonical_path;
|
||||
dir.id = q.lastInsertId().toInt();
|
||||
|
||||
emit DirectoryDiscovered(dir, SubdirectoryList());
|
||||
|
@ -1342,7 +1342,7 @@ void MainWindow::AddFile() {
|
||||
// Convert to URLs
|
||||
QList<QUrl> urls;
|
||||
foreach (const QString& path, file_names) {
|
||||
urls << QUrl::fromLocalFile(path);
|
||||
urls << QUrl::fromLocalFile(QFileInfo(path).canonicalFilePath());
|
||||
}
|
||||
|
||||
MimeData* data = new MimeData;
|
||||
@ -1364,7 +1364,7 @@ void MainWindow::AddFolder() {
|
||||
|
||||
// Add media
|
||||
MimeData* data = new MimeData;
|
||||
data->setUrls(QList<QUrl>() << QUrl::fromLocalFile(directory));
|
||||
data->setUrls(QList<QUrl>() << QUrl::fromLocalFile(QFileInfo(directory).canonicalFilePath()));
|
||||
AddToPlaylist(data);
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ QList<QUrl> FileViewList::UrlListFromSelection() const {
|
||||
foreach (const QModelIndex& index, menu_selection_.indexes()) {
|
||||
if (index.column() == 0)
|
||||
urls << QUrl::fromLocalFile(
|
||||
static_cast<QFileSystemModel*>(model())->filePath(index));
|
||||
static_cast<QFileSystemModel*>(model())->fileInfo(index).canonicalFilePath());
|
||||
}
|
||||
return urls;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user