mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-23 07:50:13 +01:00
Remove watch for removed subdirectories
This commit is contained in:
parent
83c4c91a2e
commit
fd35f20d26
@ -119,6 +119,12 @@ LibraryWatcher::ScanTransaction::~ScanTransaction() {
|
||||
|
||||
watcher_->task_manager_->SetTaskFinished(task_id_);
|
||||
|
||||
for (const Subdirectory &subdir : deleted_subdirs) {
|
||||
if (watcher_->watched_dirs_.contains(dir_)) {
|
||||
watcher_->RemoveWatch(watcher_->watched_dirs_[dir_], subdir);
|
||||
}
|
||||
}
|
||||
|
||||
if (watcher_->monitor_) {
|
||||
// Watch the new subdirectories
|
||||
for (const Subdirectory& subdir : new_subdirs) {
|
||||
@ -411,6 +417,10 @@ void LibraryWatcher::ScanSubdirectory(const QString& path,
|
||||
else
|
||||
t->touched_subdirs << updated_subdir;
|
||||
|
||||
if (updated_subdir.mtime == 0) { // Subdirectory deleted, mark it for removal from the watcher.
|
||||
t->deleted_subdirs << updated_subdir;
|
||||
}
|
||||
|
||||
t->AddToProgress(1);
|
||||
|
||||
// Recurse into the new subdirs that we found
|
||||
@ -585,6 +595,17 @@ void LibraryWatcher::AddWatch(const Directory& dir, const QString& path) {
|
||||
subdir_mapping_[path] = dir;
|
||||
}
|
||||
|
||||
void LibraryWatcher::RemoveWatch(const Directory &dir, const Subdirectory &subdir) {
|
||||
|
||||
for (const QString &subdir_path : subdir_mapping_.keys(dir)) {
|
||||
if (subdir_path != subdir.path) continue;
|
||||
fs_watcher_->RemovePath(subdir_path);
|
||||
subdir_mapping_.remove(subdir_path);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void LibraryWatcher::RemoveDirectory(const Directory& dir) {
|
||||
rescan_queue_.remove(dir.id);
|
||||
watched_dirs_.remove(dir.id);
|
||||
|
@ -109,6 +109,7 @@ signals:
|
||||
SongList touched_songs;
|
||||
SubdirectoryList new_subdirs;
|
||||
SubdirectoryList touched_subdirs;
|
||||
SubdirectoryList deleted_subdirs;
|
||||
|
||||
private:
|
||||
ScanTransaction(const ScanTransaction&) {}
|
||||
@ -155,6 +156,7 @@ signals:
|
||||
QString ImageForSong(const QString& path,
|
||||
QMap<QString, QStringList>& album_art);
|
||||
void AddWatch(const Directory& dir, const QString& path);
|
||||
void RemoveWatch(const Directory &dir, const Subdirectory &subdir);
|
||||
uint GetMtimeForCue(const QString& cue_path);
|
||||
void PerformScan(bool incremental, bool ignore_mtimes);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user