Workshop - Fix library virtualization

Workshop - Tweak screenshots scaling
This commit is contained in:
Robert committed 2024-01-14 20:38:17 +01:00
1 parent 28edabae89
commit 8b4b5d8810
13 files changed
+92 -37

No files matched your search

@@ -1,10 +1,12 @@
namespace Artemis.WebClient.Workshop.Handlers.InstallationHandlers;
using Artemis.WebClient.Workshop.Services;
namespace Artemis.WebClient.Workshop.Handlers.InstallationHandlers;
public class EntryInstallResult
{
public bool IsSuccess { get; set; }
public string? Message { get; set; }
public object? Result { get; set; }
public InstalledEntry? Entry { get; set; }
public static EntryInstallResult FromFailure(string? message)
{
@@ -15,12 +17,12 @@ public class EntryInstallResult
};
}
public static EntryInstallResult FromSuccess(object installationResult)
public static EntryInstallResult FromSuccess(InstalledEntry installedEntry)
{
return new EntryInstallResult
{
IsSuccess = true,
Result = installationResult
Entry = installedEntry
};
}
}
@@ -41,28 +41,28 @@ public class LayoutEntryInstallationHandler : IEntryInstallationHandler
// Ensure there is an installed entry
InstalledEntry installedEntry = _workshopService.GetInstalledEntry(entry) ?? new InstalledEntry(entry, release);
DirectoryInfo entryDirectory = installedEntry.GetReleaseDirectory(release);
DirectoryInfo releaseDirectory = installedEntry.GetReleaseDirectory(release);
// If the folder already exists, remove it so that if the layout now contains less files, old things dont stick around
if (entryDirectory.Exists)
entryDirectory.Delete(true);
entryDirectory.Create();
if (releaseDirectory.Exists)
releaseDirectory.Delete(true);
releaseDirectory.Create();
// Extract the archive, we could go through the hoops of keeping track of progress but this should be so quick it doesn't matter
stream.Seek(0, SeekOrigin.Begin);
using ZipArchive archive = new(stream);
archive.ExtractToDirectory(entryDirectory.FullName);
archive.ExtractToDirectory(releaseDirectory.FullName);
ArtemisLayout layout = new(Path.Combine(entryDirectory.FullName, "layout.xml"));
ArtemisLayout layout = new(Path.Combine(releaseDirectory.FullName, "layout.xml"));
if (layout.IsValid)
{
installedEntry.ApplyRelease(release);
_workshopService.SaveInstalledEntry(installedEntry);
return EntryInstallResult.FromSuccess(layout);
return EntryInstallResult.FromSuccess(installedEntry);
}
// If the layout ended up being invalid yoink it out again, shoooo
entryDirectory.Delete(true);
releaseDirectory.Delete(true);
_workshopService.RemoveInstalledEntry(installedEntry);
return EntryInstallResult.FromFailure("Layout failed to load because it is invalid");
}
@@ -46,7 +46,7 @@ public class ProfileEntryInstallationHandler : IEntryInstallationHandler
// Update the release and return the profile configuration
UpdateRelease(installedEntry, release);
return EntryInstallResult.FromSuccess(overwritten);
return EntryInstallResult.FromSuccess(installedEntry);
}
}
@@ -60,7 +60,7 @@ public class ProfileEntryInstallationHandler : IEntryInstallationHandler
// Update the release and return the profile configuration
UpdateRelease(installedEntry, release);
return EntryInstallResult.FromSuccess(imported);
return EntryInstallResult.FromSuccess(installedEntry);
}
public async Task<EntryUninstallResult> UninstallAsync(InstalledEntry installedEntry, CancellationToken cancellationToken)