Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: update the rotation download method.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Apr 9, 2023
1 parent 55ea4b9 commit 658a5b8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions RotationSolver/SpeechHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ internal static void Speak(string text)
{
try
{
VoiceNames ??= _speech.GetInstalledVoices().Select(v => v.VoiceInfo.Name).ToArray();
_speech ??= new SpeechSynthesizer();
_speech.Volume = Service.Config.VoiceVolume;
_speech.SelectVoice(Service.Config.VoiceName);
VoiceNames ??= _speech.GetInstalledVoices().Select(v => v.VoiceInfo.Name).ToArray();
}
catch(Exception ex)
catch (Exception ex)
{
if (!_errored)
{
Expand Down
15 changes: 12 additions & 3 deletions RotationSolver/Updaters/RotationUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public static async void GetAllCustomRotations()
var relayFolder = Service.Interface.ConfigDirectory.FullName;
if (!Directory.Exists(relayFolder)) Directory.CreateDirectory(relayFolder);

LoadRotationsFromLocal(relayFolder);

bool hasDownload = false;
using (var client = new HttpClient())
{
IEnumerable<string> libs = Service.Config.OtherLibs;
Expand Down Expand Up @@ -59,6 +62,7 @@ await response.Content.CopyToAsync(new FileStream(filePath, File.Exists(filePath
? FileMode.Open : FileMode.CreateNew));
}

hasDownload = true;
PluginLog.Log($"Successfully download the {filePath}");
}
catch (Exception ex)
Expand All @@ -68,10 +72,15 @@ await response.Content.CopyToAsync(new FileStream(filePath, File.Exists(filePath
}
}

if (hasDownload) LoadRotationsFromLocal(relayFolder);
}

private static void LoadRotationsFromLocal(string relayFolder)
{
var directories = Service.Config.OtherLibs
.Where(Directory.Exists)
.Append(Path.GetDirectoryName(Assembly.GetAssembly(typeof(ICustomRotation)).Location))
.Append(relayFolder);
.Where(Directory.Exists)
.Append(Path.GetDirectoryName(Assembly.GetAssembly(typeof(ICustomRotation)).Location))
.Append(relayFolder);

var assemblies = from dir in directories
where Directory.Exists(dir)
Expand Down

0 comments on commit 658a5b8

Please sign in to comment.