Skip to content

Commit

Permalink
Fix issue TumblThreeApp#135 Wrong calculation of downloaded items
Browse files Browse the repository at this point in the history
- For every crawl one statistics item was added.
- Crawls itself are not changing the statistics.
- Old (wrong) statistics cannot be fixed.
  • Loading branch information
thomas694 committed Apr 4, 2021
1 parent 08d2ace commit ceacd44
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/TumblThree/TumblThree.Domain/Models/Blogs/Blog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/TumblThree/TumblThree.Domain/Models/Blogs/IBlog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public interface IBlog : INotifyPropertyChanged

List<string> Links { get; }

void UpdateProgress();
void UpdateProgress(bool calcOnly);

void UpdatePostCount(string propertyName);

Expand Down

0 comments on commit ceacd44

Please sign in to comment.