mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-21 15:27:43 +01:00
fix: correctly fail when assets don't download
This commit is contained in:
parent
3f2be06abb
commit
811ec77bee
2 changed files with 12 additions and 4 deletions
|
|
@ -91,9 +91,15 @@ namespace Dalamud {
|
||||||
|
|
||||||
Task.Run(async () => {
|
Task.Run(async () => {
|
||||||
try {
|
try {
|
||||||
await AssetManager.EnsureAssets(this.baseDirectory);
|
var res = await AssetManager.EnsureAssets(this.baseDirectory);
|
||||||
|
|
||||||
|
if (!res) {
|
||||||
|
Log.Error("One or more assets failed to download.");
|
||||||
|
Unload();
|
||||||
|
return;
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.Error(e, "Could not ensure assets.");
|
Log.Error(e, "Error in asset task.");
|
||||||
Unload();
|
Unload();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ namespace Dalamud.Interface
|
||||||
{"https://img.finalfantasyxiv.com/lds/pc/global/fonts/FFXIV_Lodestone_SSF.ttf", "UIRes/gamesym.ttf" }
|
{"https://img.finalfantasyxiv.com/lds/pc/global/fonts/FFXIV_Lodestone_SSF.ttf", "UIRes/gamesym.ttf" }
|
||||||
};
|
};
|
||||||
|
|
||||||
public static async Task EnsureAssets(string baseDir) {
|
public static async Task<bool> EnsureAssets(string baseDir) {
|
||||||
using var client = new WebClient();
|
using var client = new WebClient();
|
||||||
|
|
||||||
Log.Verbose("Starting asset download");
|
Log.Verbose("Starting asset download");
|
||||||
|
|
@ -42,11 +42,13 @@ namespace Dalamud.Interface
|
||||||
try {
|
try {
|
||||||
File.WriteAllBytes(filePath, client.DownloadData(entry.Key));
|
File.WriteAllBytes(filePath, client.DownloadData(entry.Key));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
// If another game is running, we don't want to just fail in here
|
|
||||||
Log.Error(ex, "Could not download asset.");
|
Log.Error(ex, "Could not download asset.");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue