Skip to content

Commit

Permalink
updatws
Browse files Browse the repository at this point in the history
  • Loading branch information
Bod9001 committed Dec 10, 2024
1 parent 3d7c1b2 commit b1c6f48
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
10 changes: 5 additions & 5 deletions UnitystationLauncher/Services/CodeScanConfigService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ public CodeScanConfigService(HttpClient httpClient, IPreferencesService preferen

string pathBase = _preferencesService.GetPreferences().InstallationPath;
string folderName = GetFolderName(version);
string versionPath = Path.Combine(pathBase, version, folderName);
string versionPath = Path.Combine(pathBase, "nonbuild", version, folderName);

if (Directory.Exists(versionPath) == false)
{
string zipExtractPath = Path.Combine(pathBase, version);
string zipExtractPath = Path.Combine(pathBase, "nonbuild", version);
HttpResponseMessage request = await _httpClient.GetAsync($"{ApiUrls.GoodFilesBaseUrl}/{version}/{folderName}.zip", HttpCompletionOption.ResponseHeadersRead);
await using Stream responseStream = await request.Content.ReadAsStreamAsync();
ZipArchive archive = new(responseStream);
Expand Down Expand Up @@ -183,12 +183,12 @@ private string GetZipFolderName()
switch (os)
{
case CurrentEnvironment.WindowsStandalone:
return "Windows";
return "StandaloneWindows64";
case CurrentEnvironment.LinuxFlatpak:
case CurrentEnvironment.LinuxStandalone:
return "Linux";
return "StandaloneLinux64";
case CurrentEnvironment.MacOsStandalone:
return "Mac";
return "StandaloneOSX";
default:
throw new UnsupportedPlatformException($"Unable to determine OS Version {os}");
}
Expand Down
6 changes: 4 additions & 2 deletions UnitystationLauncher/Services/CodeScanService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ public async Task<bool> OnScanAsync(ZipArchive archive, string targetDirectory,
// TODO: Enable extraction cancelling
DirectoryInfo root = new(_preferencesService.GetPreferences().InstallationPath);

DirectoryInfo stagingDirectory = root.CreateSubdirectory("UnsafeBuildZipDirectory");
DirectoryInfo processingDirectory = root.CreateSubdirectory("UnsafeBuildProcessing");
var nonbuild = root.CreateSubdirectory("nonbuild");

DirectoryInfo stagingDirectory = nonbuild.CreateSubdirectory("UnsafeBuildZipDirectory");
DirectoryInfo processingDirectory = nonbuild.CreateSubdirectory("UnsafeBuildProcessing");
DirectoryInfo? dataPath = null;
archive.ExtractToDirectory(stagingDirectory.ToString(), true);
try
Expand Down
11 changes: 11 additions & 0 deletions UnitystationLauncher/Services/InstallationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@ public List<Installation> GetInstallations()

string installationBasePath = _preferencesService.GetPreferences().InstallationPath;
// should be something like {basePath}/{forkName}/{version}
if (server.ForkName.SanitiseStringPath() == "nonbuild")
{
throw new Exception($" bad server.ForkName {server.ForkName.SanitiseStringPath()} Not allowed as save location (nonbuild)");

Check warning on line 120 in UnitystationLauncher/Services/InstallationService.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

UnitystationLauncher/Services/InstallationService.cs#L120

'System.Exception' should not be thrown by user code.

Check failure on line 120 in UnitystationLauncher/Services/InstallationService.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

UnitystationLauncher/Services/InstallationService.cs#L120

Replace the string 'server' with 'nameof(server)'.
}

if (server.ForkName.SanitiseStringPath() == "tts")
{
throw new Exception($" bad server.ForkName {server.ForkName.SanitiseStringPath()} Not allowed as save location (tts) ");
}


string installationPath = Path.Combine(installationBasePath, server.ForkName.SanitiseStringPath(), server.GoodFileVersion.SanitiseStringPath(), server.BuildVersion.ToString());

download = new(downloadUrl, installationPath, server.ForkName, server.BuildVersion, server.GoodFileVersion);
Expand Down

0 comments on commit b1c6f48

Please sign in to comment.