mirror of
https://github.com/sp-tarkov/installer.git
synced 2025-02-12 16:50:45 -05:00
commit
dc0a201010
@ -59,39 +59,8 @@ public partial class WhyCacheThoughDialog : UserControl
|
|||||||
|
|
||||||
public void ClearCachedMetaData()
|
public void ClearCachedMetaData()
|
||||||
{
|
{
|
||||||
var cachedMetadata =
|
var allDeleted = DownloadCacheHelper.ClearMetadataCache();
|
||||||
new DirectoryInfo(DownloadCacheHelper.CachePath).GetFiles("*.json", SearchOption.TopDirectoryOnly);
|
var message = allDeleted ? "cached metadata removed" : "some files could not be removed. Check logs";
|
||||||
|
|
||||||
var message = "no cached metadata to remove";
|
|
||||||
|
|
||||||
if (cachedMetadata.Length == 0)
|
|
||||||
{
|
|
||||||
AdditionalInfo = message;
|
|
||||||
AdditionalInfoColor = "dodgerblue";
|
|
||||||
Log.Information(message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var allDeleted = true;
|
|
||||||
|
|
||||||
foreach (var file in cachedMetadata)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
file.Delete();
|
|
||||||
file.Refresh();
|
|
||||||
if (file.Exists)
|
|
||||||
{
|
|
||||||
allDeleted = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Log.Error(ex, $"Failed to delete cached metadata file: {file.Name}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
message = allDeleted ? "cached metadata removed" : "some files could not be removed. Check logs";
|
|
||||||
AdditionalInfo = message;
|
AdditionalInfo = message;
|
||||||
AdditionalInfoColor = allDeleted ? "green" : "red";
|
AdditionalInfoColor = allDeleted ? "green" : "red";
|
||||||
Log.Information(message);
|
Log.Information(message);
|
||||||
|
@ -43,6 +43,26 @@ public static class DownloadCacheHelper
|
|||||||
return DirectorySizeHelper.SizeSuffix(cacheSize);
|
return DirectorySizeHelper.SizeSuffix(cacheSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static bool ClearMetadataCache()
|
||||||
|
{
|
||||||
|
var metaData = new DirectoryInfo(CachePath).GetFiles("*.json", SearchOption.TopDirectoryOnly);
|
||||||
|
var allDeleted = true;
|
||||||
|
|
||||||
|
foreach (var file in metaData)
|
||||||
|
{
|
||||||
|
file.Delete();
|
||||||
|
file.Refresh();
|
||||||
|
|
||||||
|
if (file.Exists)
|
||||||
|
{
|
||||||
|
allDeleted = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return allDeleted;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check if a file in the cache already exists
|
/// Check if a file in the cache already exists
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -24,40 +24,70 @@ public class ReleaseCheckTask : InstallerTaskBase
|
|||||||
SetStatus("Checking SPT Releases", "", null, ProgressStyle.Indeterminate);
|
SetStatus("Checking SPT Releases", "", null, ProgressStyle.Indeterminate);
|
||||||
|
|
||||||
var progress = new Progress<double>((d) => { SetStatus(null, null, (int)Math.Floor(d)); });
|
var progress = new Progress<double>((d) => { SetStatus(null, null, (int)Math.Floor(d)); });
|
||||||
var SPTReleaseInfoFile =
|
|
||||||
|
ReleaseInfo? sptReleaseInfo = null;
|
||||||
|
PatchInfo? patchMirrorInfo = null;
|
||||||
|
|
||||||
|
int retries = 1;
|
||||||
|
|
||||||
|
while (retries >= 0)
|
||||||
|
{
|
||||||
|
retries--;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sptReleaseInfoFile =
|
||||||
await DownloadCacheHelper.GetOrDownloadFileAsync("release.json", DownloadCacheHelper.ReleaseMirrorUrl,
|
await DownloadCacheHelper.GetOrDownloadFileAsync("release.json", DownloadCacheHelper.ReleaseMirrorUrl,
|
||||||
progress, DownloadCacheHelper.SuggestedTtl);
|
progress, DownloadCacheHelper.SuggestedTtl);
|
||||||
|
|
||||||
if (SPTReleaseInfoFile == null)
|
if (sptReleaseInfoFile == null)
|
||||||
{
|
{
|
||||||
return Result.FromError("Failed to download release metadata, try clicking the 'Whats this' button below followed by the 'Clear Metadata cache' button");
|
return Result.FromError("Failed to download release metadata, try clicking the 'Whats this' button below followed by the 'Clear Metadata cache' button");
|
||||||
}
|
}
|
||||||
|
|
||||||
var SPTReleaseInfo =
|
|
||||||
JsonConvert.DeserializeObject<ReleaseInfo>(File.ReadAllText(SPTReleaseInfoFile.FullName));
|
|
||||||
|
|
||||||
SetStatus("Checking for Patches", "", null, ProgressStyle.Indeterminate);
|
SetStatus("Checking for Patches", "", null, ProgressStyle.Indeterminate);
|
||||||
|
|
||||||
var SPTPatchMirrorsFile =
|
var sptPatchMirrorsFile =
|
||||||
await DownloadCacheHelper.GetOrDownloadFileAsync("mirrors.json", DownloadCacheHelper.PatchMirrorUrl,
|
await DownloadCacheHelper.GetOrDownloadFileAsync("mirrors.json", DownloadCacheHelper.PatchMirrorUrl,
|
||||||
progress, DownloadCacheHelper.SuggestedTtl);
|
progress, DownloadCacheHelper.SuggestedTtl);
|
||||||
|
|
||||||
if (SPTPatchMirrorsFile == null)
|
if (sptPatchMirrorsFile == null)
|
||||||
{
|
{
|
||||||
return Result.FromError("Failed to download patch mirror data, try clicking the 'Whats this' button below followed by the 'Clear Metadata cache' button");
|
return Result.FromError("Failed to download patch mirror data, try clicking the 'Whats this' button below followed by the 'Clear Metadata cache' button");
|
||||||
}
|
}
|
||||||
|
|
||||||
var patchMirrorInfo =
|
sptReleaseInfo =
|
||||||
JsonConvert.DeserializeObject<PatchInfo>(File.ReadAllText(SPTPatchMirrorsFile.FullName));
|
JsonConvert.DeserializeObject<ReleaseInfo>(File.ReadAllText(sptReleaseInfoFile.FullName));
|
||||||
|
|
||||||
if (SPTReleaseInfo == null || patchMirrorInfo == null)
|
patchMirrorInfo =
|
||||||
|
JsonConvert.DeserializeObject<PatchInfo>(File.ReadAllText(sptPatchMirrorsFile.FullName));
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
return Result.FromError("An error occurred while deserializing SPT or patch data, try clicking the 'Whats this' button below followed by the 'Clear Metadata cache' button");
|
if (retries >= 0)
|
||||||
|
{
|
||||||
|
SetStatus("Clearing cache and retrying ...", "", null, ProgressStyle.Indeterminate);
|
||||||
|
await Task.Delay(1000);
|
||||||
|
DownloadCacheHelper.ClearMetadataCache();
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
_data.ReleaseInfo = SPTReleaseInfo;
|
return Result.FromError(
|
||||||
|
$"An error occurred while deserializing SPT or patch data.\n\nMost likely we are uploading a new patch.\nPlease wait and try again in an hour\n\nERROR: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sptReleaseInfo == null || patchMirrorInfo == null)
|
||||||
|
{
|
||||||
|
return Result.FromError(
|
||||||
|
"Release or mirror info was null. If you are seeing this report it. This should never be hit");
|
||||||
|
}
|
||||||
|
|
||||||
|
_data.ReleaseInfo = sptReleaseInfo;
|
||||||
_data.PatchInfo = patchMirrorInfo;
|
_data.PatchInfo = patchMirrorInfo;
|
||||||
int intSPTVersion = int.Parse(SPTReleaseInfo.ClientVersion);
|
int intSPTVersion = int.Parse(sptReleaseInfo.ClientVersion);
|
||||||
int intGameVersion = int.Parse(_data.OriginalGameVersion);
|
int intGameVersion = int.Parse(_data.OriginalGameVersion);
|
||||||
|
|
||||||
// note: it's possible the game version could be lower than the SPT version and still need a patch if the major version numbers change
|
// note: it's possible the game version could be lower than the SPT version and still need a patch if the major version numbers change
|
||||||
@ -99,10 +129,10 @@ public class ReleaseCheckTask : InstallerTaskBase
|
|||||||
if (sptClientIsOutdated)
|
if (sptClientIsOutdated)
|
||||||
{
|
{
|
||||||
return Result.FromError(
|
return Result.FromError(
|
||||||
"Could not find a downgrade patcher for the version of EFT you have installed." +
|
"Live EFT has recently updated. The SPT team needs to make a new patcher." +
|
||||||
"\nThis can happen due to one of the following reasons:" +
|
"\n* It's usually made within 24 hours." +
|
||||||
"\n* Live EFT just updated. The SPT team will create a new patcher within 24 hours, hold tight!" +
|
"\n* The patcher is only for turning your EFT files into an older version for SPT to use." +
|
||||||
"\n* Live EFT just updated. You have not installed it on your computer using your Battlestate Games launcher");
|
"\n* This does not mean SPT is being updated to a newer version.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (liveClientIsOutdated)
|
if (liveClientIsOutdated)
|
||||||
@ -113,7 +143,7 @@ public class ReleaseCheckTask : InstallerTaskBase
|
|||||||
_data.PatchNeeded = patchNeedCheck;
|
_data.PatchNeeded = patchNeedCheck;
|
||||||
|
|
||||||
string status =
|
string status =
|
||||||
$"Current Release: {SPTReleaseInfo.ClientVersion} - {(_data.PatchNeeded ? "Patch Available" : "No Patch Needed")}";
|
$"Current Release: {sptReleaseInfo.ClientVersion} - {(_data.PatchNeeded ? "Patch Available" : "No Patch Needed")}";
|
||||||
|
|
||||||
SetStatus(null, status);
|
SetStatus(null, status);
|
||||||
|
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
<PackageIcon>icon.ico</PackageIcon>
|
<PackageIcon>icon.ico</PackageIcon>
|
||||||
<ApplicationIcon>Assets\spt_installer.ico</ApplicationIcon>
|
<ApplicationIcon>Assets\spt_installer.ico</ApplicationIcon>
|
||||||
<Configurations>Debug;Release;TEST</Configurations>
|
<Configurations>Debug;Release;TEST</Configurations>
|
||||||
<AssemblyVersion>2.94</AssemblyVersion>
|
<AssemblyVersion>2.96</AssemblyVersion>
|
||||||
<FileVersion>2.94</FileVersion>
|
<FileVersion>2.96</FileVersion>
|
||||||
<Company>SPT</Company>
|
<Company>SPT</Company>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
@ -245,28 +245,43 @@ public class PreChecksViewModel : ViewModelBase
|
|||||||
|
|
||||||
var progress = new Progress<double>((d) => { });
|
var progress = new Progress<double>((d) => { });
|
||||||
|
|
||||||
var SPTReleaseInfoFile =
|
ReleaseInfo? sptReleaseInfo = null;
|
||||||
|
var retries = 1;
|
||||||
|
|
||||||
|
while (retries >= 0)
|
||||||
|
{
|
||||||
|
retries--;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sptReleaseInfoFile =
|
||||||
await DownloadCacheHelper.GetOrDownloadFileAsync("release.json", DownloadCacheHelper.ReleaseMirrorUrl,
|
await DownloadCacheHelper.GetOrDownloadFileAsync("release.json", DownloadCacheHelper.ReleaseMirrorUrl,
|
||||||
progress, DownloadCacheHelper.SuggestedTtl);
|
progress, DownloadCacheHelper.SuggestedTtl);
|
||||||
|
|
||||||
if (SPTReleaseInfoFile == null)
|
if (sptReleaseInfoFile == null)
|
||||||
{
|
{
|
||||||
InstallButtonText = "Could not get SPT release metadata";
|
InstallButtonText = "Could not get SPT release metadata";
|
||||||
InstallButtonCheckState = StatusSpinner.SpinnerState.Error;
|
InstallButtonCheckState = StatusSpinner.SpinnerState.Error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var SPTReleaseInfo =
|
sptReleaseInfo =
|
||||||
JsonConvert.DeserializeObject<ReleaseInfo>(File.ReadAllText(SPTReleaseInfoFile.FullName));
|
JsonConvert.DeserializeObject<ReleaseInfo>(File.ReadAllText(sptReleaseInfoFile.FullName));
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
DownloadCacheHelper.ClearMetadataCache();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (SPTReleaseInfo == null)
|
if (sptReleaseInfo == null)
|
||||||
{
|
{
|
||||||
InstallButtonText = "Could not parse latest SPT release";
|
InstallButtonText = "Could not parse latest SPT release";
|
||||||
InstallButtonCheckState = StatusSpinner.SpinnerState.Error;
|
InstallButtonCheckState = StatusSpinner.SpinnerState.Error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
InstallButtonText = $"Start Install: SPT v{SPTReleaseInfo.SPTVersion}";
|
InstallButtonText = $"Start Install: SPT v{sptReleaseInfo.SPTVersion}";
|
||||||
InstallButtonCheckState = StatusSpinner.SpinnerState.OK;
|
InstallButtonCheckState = StatusSpinner.SpinnerState.OK;
|
||||||
|
|
||||||
AllowDetailsButton = true;
|
AllowDetailsButton = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user