Example #1
0
        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);
            }
        }
Example #2
0
        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);
                    }
                });
            }
        }