From ceacd4463a6f2de95973bc52df509bfdd1d886b0 Mon Sep 17 00:00:00 2001 From: Thomas <71355143+thomas694@users.noreply.github.com> Date: Sun, 4 Apr 2021 23:31:29 +0200 Subject: [PATCH] Fix issue #135 Wrong calculation of downloaded items - For every crawl one statistics item was added. - Crawls itself are not changing the statistics. - Old (wrong) statistics cannot be fixed. --- .../TumblThree.Applications/Controllers/CrawlerController.cs | 2 +- .../TumblThree.Applications/Downloader/AbstractDownloader.cs | 2 +- src/TumblThree/TumblThree.Domain/Models/Blogs/Blog.cs | 4 ++-- src/TumblThree/TumblThree.Domain/Models/Blogs/IBlog.cs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/TumblThree/TumblThree.Applications/Controllers/CrawlerController.cs b/src/TumblThree/TumblThree.Applications/Controllers/CrawlerController.cs index 1edab8a0..e8be9bb1 100644 --- a/src/TumblThree/TumblThree.Applications/Controllers/CrawlerController.cs +++ b/src/TumblThree/TumblThree.Applications/Controllers/CrawlerController.cs @@ -258,7 +258,7 @@ private async Task StartSiteSpecificDownloaderAsync(QueueListItem queueListItem, ICrawler crawler = _crawlerFactory.GetCrawler(blog, progress, pt, ct); await crawler.CrawlAsync(); - blog.UpdateProgress(); + blog.UpdateProgress(true); crawler.Dispose(); Monitor.Enter(_lockObject); diff --git a/src/TumblThree/TumblThree.Applications/Downloader/AbstractDownloader.cs b/src/TumblThree/TumblThree.Applications/Downloader/AbstractDownloader.cs index ed0bc0d7..2a605b8b 100644 --- a/src/TumblThree/TumblThree.Applications/Downloader/AbstractDownloader.cs +++ b/src/TumblThree/TumblThree.Applications/Downloader/AbstractDownloader.cs @@ -345,7 +345,7 @@ private void DownloadTextPost(TumblrPost downloadItem) private void UpdateBlogDB(string postType) { blog.UpdatePostCount(postType); - blog.UpdateProgress(); + blog.UpdateProgress(false); } protected void SetFileDate(string fileLocation, DateTime postDate) diff --git a/src/TumblThree/TumblThree.Domain/Models/Blogs/Blog.cs b/src/TumblThree/TumblThree.Domain/Models/Blogs/Blog.cs index d020028b..7fa3c81a 100644 --- a/src/TumblThree/TumblThree.Domain/Models/Blogs/Blog.cs +++ b/src/TumblThree/TumblThree.Domain/Models/Blogs/Blog.cs @@ -888,11 +888,11 @@ public bool GroupPhotoSets } } - public void UpdateProgress() + public void UpdateProgress(bool calcOnly) { lock (lockObjectProgress) { - DownloadedImages++; + if (!calcOnly) DownloadedImages++; Progress = (int)(DownloadedImages / (double)TotalCount * 100); } } diff --git a/src/TumblThree/TumblThree.Domain/Models/Blogs/IBlog.cs b/src/TumblThree/TumblThree.Domain/Models/Blogs/IBlog.cs index 38845abb..018a413e 100644 --- a/src/TumblThree/TumblThree.Domain/Models/Blogs/IBlog.cs +++ b/src/TumblThree/TumblThree.Domain/Models/Blogs/IBlog.cs @@ -198,7 +198,7 @@ public interface IBlog : INotifyPropertyChanged List Links { get; } - void UpdateProgress(); + void UpdateProgress(bool calcOnly); void UpdatePostCount(string propertyName);