From 6b23728efafc7847930854f0cbf4c9a587d48568 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Fri, 28 Jan 2022 23:32:49 +0100 Subject: [PATCH] Fix deleting songs from filesystemdevices --- src/collection/collectionwatcher.cpp | 16 +++++++++++----- src/collection/collectionwatcher.h | 2 ++ src/device/filesystemdevice.cpp | 3 +++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/collection/collectionwatcher.cpp b/src/collection/collectionwatcher.cpp index 2a52bb2d7..7018c82a4 100644 --- a/src/collection/collectionwatcher.cpp +++ b/src/collection/collectionwatcher.cpp @@ -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 { diff --git a/src/collection/collectionwatcher.h b/src/collection/collectionwatcher.h index 76c078916..06bce4a34 100644 --- a/src/collection/collectionwatcher.h +++ b/src/collection/collectionwatcher.h @@ -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; } diff --git a/src/device/filesystemdevice.cpp b/src/device/filesystemdevice.cpp index d9703d98d..dcbd39ea2 100644 --- a/src/device/filesystemdevice.cpp +++ b/src/device/filesystemdevice.cpp @@ -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); }