Fix deleting songs from filesystemdevices

This commit is contained in:
Jonas Kvinge 2022-01-28 23:32:49 +01:00
parent ff0f7ee483
commit 6b23728efa
3 changed files with 16 additions and 5 deletions

View File

@ -84,8 +84,8 @@ CollectionWatcher::CollectionWatcher(Song::Source source, QObject *parent)
original_thread_(nullptr),
scan_on_startup_(true),
monitor_(true),
song_tracking_(true),
mark_songs_unavailable_(true),
song_tracking_(false),
mark_songs_unavailable_(source_ == Song::Source_Collection),
expire_unavailable_songs_days_(60),
overwrite_rating_(false),
stop_requested_(false),
@ -149,8 +149,14 @@ void CollectionWatcher::ReloadSettings() {
scan_on_startup_ = s.value("startup_scan", true).toBool();
monitor_ = s.value("monitor", true).toBool();
QStringList filters = s.value("cover_art_patterns", QStringList() << "front" << "cover").toStringList();
song_tracking_ = s.value("song_tracking", false).toBool();
mark_songs_unavailable_ = song_tracking_ ? true : s.value("mark_songs_unavailable", true).toBool();
if (source_ == Song::Source_Collection) {
song_tracking_ = s.value("song_tracking", false).toBool();
mark_songs_unavailable_ = song_tracking_ ? true : s.value("mark_songs_unavailable", true).toBool();
}
else {
song_tracking_ = false;
mark_songs_unavailable_ = false;
}
expire_unavailable_songs_days_ = s.value("expire_unavailable_songs", 60).toInt();
overwrite_rating_ = s.value("overwrite_rating", false).toBool();
s.endGroup();
@ -238,7 +244,7 @@ void CollectionWatcher::ScanTransaction::AddToProgressMax(const quint64 n) {
void CollectionWatcher::ScanTransaction::CommitNewOrUpdatedSongs() {
if (!deleted_songs.isEmpty()) {
if (mark_songs_unavailable_) {
if (mark_songs_unavailable_ && watcher_->source() == Song::Source_Collection) {
emit watcher_->SongsUnavailable(deleted_songs);
}
else {

View File

@ -51,6 +51,8 @@ class CollectionWatcher : public QObject {
public:
explicit CollectionWatcher(Song::Source source, QObject *parent = nullptr);
Song::Source source() { return source_; }
void set_backend(CollectionBackend *backend) { backend_ = backend; }
void set_task_manager(TaskManager *task_manager) { task_manager_ = task_manager; }
void set_device_name(const QString &device_name) { device_name_ = device_name; }

View File

@ -58,9 +58,12 @@ FilesystemDevice::FilesystemDevice(const QUrl &url, DeviceLister *lister, const
QObject::connect(watcher_, &CollectionWatcher::NewOrUpdatedSongs, backend_, &CollectionBackend::AddOrUpdateSongs);
QObject::connect(watcher_, &CollectionWatcher::SongsMTimeUpdated, backend_, &CollectionBackend::UpdateMTimesOnly);
QObject::connect(watcher_, &CollectionWatcher::SongsDeleted, backend_, &CollectionBackend::DeleteSongs);
QObject::connect(watcher_, &CollectionWatcher::SongsUnavailable, backend_, &CollectionBackend::MarkSongsUnavailable);
QObject::connect(watcher_, &CollectionWatcher::SongsReadded, backend_, &CollectionBackend::MarkSongsUnavailable);
QObject::connect(watcher_, &CollectionWatcher::SubdirsDiscovered, backend_, &CollectionBackend::AddOrUpdateSubdirs);
QObject::connect(watcher_, &CollectionWatcher::SubdirsMTimeUpdated, backend_, &CollectionBackend::AddOrUpdateSubdirs);
QObject::connect(watcher_, &CollectionWatcher::CompilationsNeedUpdating, backend_, &CollectionBackend::CompilationsNeedUpdating);
QObject::connect(watcher_, &CollectionWatcher::UpdateLastSeen, backend_, &CollectionBackend::UpdateLastSeen);
QObject::connect(watcher_, &CollectionWatcher::ScanStarted, this, &FilesystemDevice::TaskStarted);
}