public static async Task RemovePodcastLocalDataAsync(Podcast podcast, bool silent, bool deleteFolder = true) { foreach (var episode in podcast.Episodes) { if (episode.IsAlreadyDownloaded) { await episode.DeleteDownloadAsync(silent); lock (DownloadedEpisodes) { DownloadedEpisodes.Remove(episode); } } else if (episode.DownloadInProgress) { episode.CancelDownload(silent); lock (DownloadedEpisodes) { DownloadedEpisodes.Remove(episode); } } } if (deleteFolder) { await FileHelper.DeleteFolderAsync(podcast.Root, true); } }
internal static async void RemoveDownloadedEpisode(Episode episode) { if (Notifier.Dispatcher == null) { return; } if (Notifier.Dispatcher.HasThreadAccess) { lock (DownloadedEpisodes) { if (!DownloadedEpisodes.Contains(episode)) { return; } DownloadedEpisodes.Remove(episode); } } else { await Notifier.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { lock (DownloadedEpisodes) { if (!DownloadedEpisodes.Contains(episode)) { return; } DownloadedEpisodes.Remove(episode); } }); } }