mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
fix #1750
This commit is contained in:
@@ -45,6 +45,17 @@ internal static class FileOperation
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool Delete(string path)
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
File.Delete(path);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static unsafe bool UnsafeDelete(string path)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
@@ -81,31 +81,21 @@ internal sealed partial class PackageConverter
|
||||
|
||||
public async ValueTask EnsureDeprecatedFilesAndSdkAsync(GameChannelSDK? channelSDK, DeprecatedFilesWrapper? deprecatedFiles, string gameFolder)
|
||||
{
|
||||
string sdkDllBackup = Path.Combine(gameFolder, YuanShenData, "Plugins\\PCGameSDK.dll.backup");
|
||||
string sdkDll = Path.Combine(gameFolder, YuanShenData, "Plugins\\PCGameSDK.dll");
|
||||
// Just try to delete these files, always download from server when needed
|
||||
FileOperation.Delete(Path.Combine(gameFolder, YuanShenData, "Plugins\\PCGameSDK.dll"));
|
||||
FileOperation.Delete(Path.Combine(gameFolder, GenshinImpactData, "Plugins\\PCGameSDK.dll"));
|
||||
FileOperation.Delete(Path.Combine(gameFolder, YuanShenData, "Plugins\\EOSSDK-Win64-Shipping.dll"));
|
||||
FileOperation.Delete(Path.Combine(gameFolder, GenshinImpactData, "Plugins\\EOSSDK-Win64-Shipping.dll"));
|
||||
FileOperation.Delete(Path.Combine(gameFolder, YuanShenData, "Plugins\\PluginEOSSDK.dll"));
|
||||
FileOperation.Delete(Path.Combine(gameFolder, GenshinImpactData, "Plugins\\PluginEOSSDK.dll"));
|
||||
FileOperation.Delete(Path.Combine(gameFolder, "sdk_pkg_version"));
|
||||
|
||||
string sdkVersionBackup = Path.Combine(gameFolder, "sdk_pkg_version.backup");
|
||||
string sdkVersion = Path.Combine(gameFolder, "sdk_pkg_version");
|
||||
|
||||
// Only bilibili's sdk is not null
|
||||
if (channelSDK is not null)
|
||||
{
|
||||
using (Stream sdkWebStream = await httpClient.GetStreamAsync(channelSDK.ChannelSdkPackage.Url).ConfigureAwait(false))
|
||||
{
|
||||
ZipFile.ExtractToDirectory(sdkWebStream, gameFolder, true);
|
||||
}
|
||||
|
||||
if (File.Exists(sdkDllBackup) && File.Exists(sdkVersionBackup))
|
||||
{
|
||||
File.Delete(sdkDllBackup);
|
||||
File.Delete(sdkVersionBackup);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Backup
|
||||
FileOperation.Move(sdkDll, sdkDllBackup, true);
|
||||
FileOperation.Move(sdkVersion, sdkVersionBackup, true);
|
||||
}
|
||||
|
||||
if (deprecatedFiles is not null)
|
||||
|
||||
Reference in New Issue
Block a user