Organize: Update collection directory ID and song path immediately

Fixes #781
This commit is contained in:
Jonas Kvinge
2021-09-27 19:29:12 +02:00
parent 62e53b53f0
commit 8c6ad52437
8 changed files with 24 additions and 8 deletions

View File

@@ -21,6 +21,8 @@
#include "config.h"
#include <optional>
#include <QtGlobal>
#include <QObject>
#include <QApplication>
@@ -429,7 +431,7 @@ SongList CollectionBackend::SongsWithMissingFingerprint(const int id) {
}
void CollectionBackend::SongPathChanged(const Song &song, const QFileInfo &new_file) {
void CollectionBackend::SongPathChanged(const Song &song, const QFileInfo &new_file, const std::optional<int> new_collection_directory_id) {
// Take a song and update its path
Song updated_song = song;
@@ -437,6 +439,9 @@ void CollectionBackend::SongPathChanged(const Song &song, const QFileInfo &new_f
updated_song.set_url(QUrl::fromLocalFile(new_file.absoluteFilePath()));
updated_song.set_basefilename(new_file.fileName());
updated_song.InitArtManual();
if (updated_song.is_collection_song() && new_collection_directory_id) {
updated_song.set_directory_id(new_collection_directory_id.value());
}
AddOrUpdateSongs(SongList() << updated_song);