public static string GetTaggedFolderName(DirectoryInfo directoryInfo, PostDownloadStatusType status)
        {
            if (status == PostDownloadStatusType.NoError)
            {
                throw new InvalidOperationException("Can't tag a folder with a None-error status. " + status);
            }

            string cleanName = RemoveStatusFromFolderName(directoryInfo.Name);
            string newName   = string.Format("_{0}_{1}", status, cleanName);

            return(Path.Combine(directoryInfo.Parent.FullName, newName));
        }
Example #2
0
        public virtual void SetPostDownloadStatus(List<int> episodeIds, PostDownloadStatusType postDownloadStatus)
        {
            if (episodeIds.Count == 0) throw new ArgumentException("episodeIds should contain one or more episode ids.");

            var episodeIdString = String.Join(", ", episodeIds);

            var episodeIdQuery = String.Format(@"UPDATE Episodes SET PostDownloadStatus = {0}
                                                    WHERE EpisodeId IN ({1})", (int)postDownloadStatus, episodeIdString);

            logger.Trace("Updating PostDownloadStatus for all episodeIds in {0}", episodeIdString);
            _database.Execute(episodeIdQuery);
        }
        private void TagFolder(DirectoryInfo directory, PostDownloadStatusType status)
        {
            //Turning off tagging folder for now, to stop messing people's series folders.
            return;

            var target = GetTaggedFolderName(directory, status);

            if (!DiskProvider.PathEquals(target, directory.FullName))
            {
                Logger.Warn("Unable to download [{0}]. Status: {1}", directory.Name, status);
                _diskProvider.MoveDirectory(directory.FullName, target);
            }
            else
            {
                Logger.Debug("Unable to download [{0}], {1}", directory.Name, status);
            }
        }
 public void GetFolderNameWithStatus_should_throw_if_status_is_not_an_error(PostDownloadStatusType status)
 {
     PostDownloadProvider.GetTaggedFolderName(new DirectoryInfo(TempFolder), status);
 }
 public void GetFolderNameWithStatus_should_return_a_string_with_the_error_removing_existing_error(string currentName, string excpectedName, PostDownloadStatusType status)
 {
     PostDownloadProvider.GetTaggedFolderName(new DirectoryInfo(currentName), status).Should().Be(
         excpectedName);
 }
        public void SetPostDownloadStatus(string folderName, PostDownloadStatusType postDownloadStatus, int episodeCount)
        {
            WithRealDb();

            var fakeSeries = Builder<Series>.CreateNew()
                .With(s => s.SeriesId = 12345)
                .With(s => s.CleanTitle = "officeus")
                .Build();

            var fakeEpisodes = Builder<Episode>.CreateListOfSize(episodeCount)
                .All()
                .With(c => c.SeriesId = 12345)
                .With(c => c.SeasonNumber = 1)
                .With(c => c.PostDownloadStatus = PostDownloadStatusType.Unknown)
                .Build();

            Db.Insert(fakeSeries);
            Db.InsertMany(fakeEpisodes);

            Mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries("officeus")).Returns(fakeSeries);

            //Act
            Mocker.Resolve<EpisodeProvider>().SetPostDownloadStatus(fakeEpisodes.Select(e => e.EpisodeId).ToList(), postDownloadStatus);

            //Assert
            var result = Db.Fetch<Episode>();
            result.Where(e => e.PostDownloadStatus == postDownloadStatus).Count().Should().Be(episodeCount);
        }
        public void episode_downloaded_post_download_status_is_used(bool hasEpisodes, bool ignored,
                                                    EpisodeStatusType status, PostDownloadStatusType postDownloadStatus)
        {
            Episode episode = Builder<Episode>.CreateNew()
                .With(e => e.Ignored = ignored)
                .With(e => e.EpisodeFileId = 0)
                .With(e => e.GrabDate = DateTime.Now.AddHours(22))
                .With(e => e.PostDownloadStatus = postDownloadStatus)
                .Build();

            if (hasEpisodes)
            {
                episode.EpisodeFileId = 12;
            }

            Assert.AreEqual(status, episode.Status);
        }
        public static string GetTaggedFolderName(DirectoryInfo directoryInfo, PostDownloadStatusType status)
        {
            if (status == PostDownloadStatusType.NoError)
                throw new InvalidOperationException("Can't tag a folder with a None-error status. " + status);

            string cleanName = RemoveStatusFromFolderName(directoryInfo.Name);
            string newName = string.Format("_{0}_{1}", status, cleanName);

            return Path.Combine(directoryInfo.Parent.FullName, newName);
        }
        private void TagFolder(DirectoryInfo directory, PostDownloadStatusType status)
        {
            //Turning off tagging folder for now, to stop messing people's series folders.
            return;
            var target = GetTaggedFolderName(directory, status);

            if (!DiskProvider.PathEquals(target, directory.FullName))
            {
                Logger.Warn("Unable to download [{0}]. Status: {1}",directory.Name, status);
                _diskProvider.MoveDirectory(directory.FullName, target);
            }
            else
            {
                Logger.Debug("Unable to download [{0}], {1}", directory.Name, status);    
            }
        }
        public void episode_downloaded_post_download_status_is_used(bool hasEpisodes, bool ignored,
                                                                    EpisodeStatusType status, PostDownloadStatusType postDownloadStatus)
        {
            Episode episode = Builder <Episode> .CreateNew()
                              .With(e => e.Ignored            = ignored)
                              .With(e => e.EpisodeFileId      = 0)
                              .With(e => e.GrabDate           = DateTime.Now.AddHours(22))
                              .With(e => e.PostDownloadStatus = postDownloadStatus)
                              .Build();

            if (hasEpisodes)
            {
                episode.EpisodeFileId = 12;
            }

            Assert.AreEqual(status, episode.Status);
        }
 public void GetFolderNameWithStatus_should_throw_if_status_is_not_an_error(PostDownloadStatusType status)
 {
     PostDownloadProvider.GetTaggedFolderName(new DirectoryInfo(TempFolder), status);
 }
 public void GetFolderNameWithStatus_should_return_a_string_with_the_error_removing_existing_error(string currentName, string excpectedName, PostDownloadStatusType status)
 {
     PostDownloadProvider.GetTaggedFolderName(new DirectoryInfo(currentName), status).Should().Be(
         excpectedName);
 }