Skip to content

Commit

Permalink
Dumpfiles: Limit time to download dump files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoltanar committed Oct 29, 2024
1 parent acd5fac commit 980955b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 3 additions & 2 deletions Happy Reader/ViewModel/CharactersTabViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ public CharactersTabViewModel(MainWindowViewModel mainViewModel) : base(mainView
FiltersViewModel = new(StaticMethods.AllFilters.CharacterFilters, StaticMethods.AllFilters.CharacterPermanentFilter, this);
}

public override async Task Initialize()
public override Task Initialize()
{
MainViewModel.StatusText = "Loading Characters...";
OnPropertyChanged(nameof(ProducerList));
LocalDatabase.SetCharactersAttachedVisualNovels();
SelectedFilterIndex = 0;
}
return Task.CompletedTask;
}

protected override Func<IDataItem<int>, double?> GetSuggestion { get; } = i => ((CharacterItem)i).TraitScore;

Expand Down
10 changes: 7 additions & 3 deletions HappySearchObjectClasses/DumpFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
Expand Down Expand Up @@ -124,8 +125,8 @@ private static bool GetTagDump()
{
int tries = 0;
bool complete = false;
//tag dump section
while (!complete && tries < MaxTries)
Stopwatch timeTaken = Stopwatch.StartNew();
while (!complete && tries < MaxTries && (tries == 0 || timeTaken.Elapsed < Timeout))
{
if (File.Exists(TagsJsonGz)) continue;
tries++;
Expand Down Expand Up @@ -154,14 +155,17 @@ private static bool GetTagDump()
return true;
}

private static readonly TimeSpan Timeout = new TimeSpan(0, 0, 0, 30);

/// <summary>
/// Return true if a new file was downloaded
/// </summary>
private static bool GetTraitDump()
{
int tries = 0;
bool complete = false;
while (!complete && tries < MaxTries)
Stopwatch timeTaken = Stopwatch.StartNew();
while (!complete && tries < MaxTries && (tries == 0 || timeTaken.Elapsed < Timeout))
{
if (File.Exists(TraitsJsonGz)) continue;
tries++;
Expand Down

0 comments on commit 980955b

Please sign in to comment.