Set source in backends to fix losing source in InitFromFilePartial()
when updating path
This commit is contained in:
@@ -55,7 +55,7 @@ SCollection::SCollection(Application *app, QObject *parent)
|
||||
backend_ = new CollectionBackend();
|
||||
backend()->moveToThread(app->database()->thread());
|
||||
|
||||
backend_->Init(app->database(), kSongsTable, kDirsTable, kSubdirsTable, kFtsTable);
|
||||
backend_->Init(app->database(), Song::Source_Collection, kSongsTable, kDirsTable, kSubdirsTable, kFtsTable);
|
||||
|
||||
model_ = new CollectionModel(backend_, app_, this);
|
||||
|
||||
|
||||
@@ -53,8 +53,9 @@ CollectionBackend::CollectionBackend(QObject *parent) :
|
||||
CollectionBackendInterface(parent),
|
||||
db_(nullptr) {}
|
||||
|
||||
void CollectionBackend::Init(Database *db, const QString &songs_table, const QString &dirs_table, const QString &subdirs_table, const QString &fts_table) {
|
||||
void CollectionBackend::Init(Database *db, const Song::Source source, const QString &songs_table, const QString &dirs_table, const QString &subdirs_table, const QString &fts_table) {
|
||||
db_ = db;
|
||||
source_ = source;
|
||||
songs_table_ = songs_table;
|
||||
dirs_table_ = dirs_table;
|
||||
subdirs_table_ = subdirs_table;
|
||||
@@ -328,6 +329,7 @@ void CollectionBackend::SongPathChanged(const Song &song, const QFileInfo &new_f
|
||||
// Take a song and update its path
|
||||
Song updated_song = song;
|
||||
updated_song.InitFromFilePartial(new_file.absoluteFilePath());
|
||||
updated_song.set_source(source_);
|
||||
SongList updated_songs;
|
||||
updated_songs << updated_song;
|
||||
AddOrUpdateSongs(updated_songs);
|
||||
|
||||
@@ -123,7 +123,7 @@ class CollectionBackend : public CollectionBackendInterface {
|
||||
static const char *kSettingsGroup;
|
||||
|
||||
Q_INVOKABLE CollectionBackend(QObject *parent = nullptr);
|
||||
void Init(Database *db, const QString &songs_table, const QString &dirs_table, const QString &subdirs_table, const QString &fts_table);
|
||||
void Init(Database *db, const Song::Source source, const QString &songs_table, const QString &dirs_table, const QString &subdirs_table, const QString &fts_table);
|
||||
|
||||
Database *db() const { return db_; }
|
||||
|
||||
@@ -238,6 +238,7 @@ signals:
|
||||
|
||||
private:
|
||||
Database *db_;
|
||||
Song::Source source_;
|
||||
QString songs_table_;
|
||||
QString dirs_table_;
|
||||
QString subdirs_table_;
|
||||
|
||||
@@ -357,7 +357,7 @@ void CollectionWatcher::ScanSubdirectory(const QString &path, const Subdirectory
|
||||
// associated cue
|
||||
QString matching_cue = NoExtensionPart(file) + ".cue";
|
||||
|
||||
Song matching_song;
|
||||
Song matching_song(source_);
|
||||
if (FindSongByPath(songs_in_db, file, &matching_song)) {
|
||||
uint matching_cue_mtime = GetMtimeForCue(matching_cue);
|
||||
|
||||
@@ -553,6 +553,7 @@ SongList CollectionWatcher::ScanNewFile(const QString &file, const QString &path
|
||||
Song song(source_);
|
||||
TagReaderClient::Instance()->ReadFileBlocking(file, &song);
|
||||
if (song.is_valid()) {
|
||||
song.set_source(source_);
|
||||
song_list << song;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user