void LocalCollection::Unscan (const QString& path) { if (!RootPaths_.contains (path)) return; QStringList toRemove; auto pred = [&path] (const QString& subPath) { return subPath.startsWith (path); }; std::copy_if (PresentPaths_.begin (), PresentPaths_.end (), std::back_inserter (toRemove), pred); PresentPaths_.subtract (QSet<QString>::fromList (toRemove)); try { std::for_each (toRemove.begin (), toRemove.end (), [this] (const QString& path) { RemoveTrack (path); }); } catch (const std::runtime_error& e) { qWarning () << Q_FUNC_INFO << "error unscanning" << path << e.what (); return; } RemoveRootPaths (QStringList (path)); }
void MediaTrackList::RemoveTracks() { while (!mTracks.IsEmpty()) { RefPtr<MediaTrack> track = mTracks.LastElement(); RemoveTrack(track); } }
void LocalCollection::CheckRemovedFiles (const QSet<QString>& scanned, const QString& rootPath) { auto toRemove = PresentPaths_; toRemove.subtract (scanned); for (auto pos = toRemove.begin (); pos != toRemove.end (); ) { if (pos->startsWith (rootPath)) ++pos; else pos = toRemove.erase (pos); } Q_FOREACH (const auto& path, toRemove) RemoveTrack (path); }
void LocalCollection::HandleExistingInfos (const QList<MediaInfo>& infos) { Q_FOREACH (const auto& info, infos) { const auto& path = info.LocalPath_; const auto trackIdx = FindTrack (path); const auto trackAlbum = GetTrackAlbum (trackIdx); if (!trackAlbum) { qWarning () << Q_FUNC_INFO << "no album for track" << path; continue; } const auto pos = std::find_if (trackAlbum->Tracks_.begin (), trackAlbum->Tracks_.end (), [trackIdx] (decltype (trackAlbum->Tracks_.front ()) track) { return track.ID_ == trackIdx; }); const auto& track = pos != trackAlbum->Tracks_.end () ? *pos : Collection::Track (); const auto& artist = GetArtist (AlbumID2ArtistID_ [trackAlbum->ID_]); if (artist.Name_ == info.Artist_ && trackAlbum->Name_ == info.Album_ && trackAlbum->Year_ == info.Year_ && track.Number_ == info.TrackNumber_ && track.Name_ == info.Title_ && track.Genres_ == info.Genres_) continue; auto stats = GetTrackStats (path); RemoveTrack (path); const auto& newArts = Storage_->AddToCollection ({ info }); HandleNewArtists (newArts); const auto newTrackIdx = FindTrack (path); stats.TrackID_ = newTrackIdx; Storage_->SetTrackStats (stats); } }
void f_ree(void *ptr) { RemoveTrack((unsigned long)ptr); free(ptr); return; }