Skip to content

Commit

Permalink
feat: Prevent "TAS Files" directory inside Studio install from being …
Browse files Browse the repository at this point in the history
…deleted
  • Loading branch information
psyGamer committed Sep 8, 2024
1 parent d6e433f commit 20cdc1c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions CelesteTAS-EverestInterop/EverestInterop/StudioHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,21 @@ private static void Load() {
"Process killed".Log(LogLevel.Verbose);
}

// If Studio fails to find the game directory for some reason, that's where "TAS Files" will be placed
// Merge the content into the proper location to prevent data loss
if (Directory.Exists(Path.Combine(StudioDirectory, "TAS Files"))) {
foreach (string path in Directory.GetFiles(Path.Combine(StudioDirectory, "TAS Files"), "*", new EnumerationOptions { RecurseSubdirectories = true, AttributesToSkip = FileAttributes.Directory })) {
string relativePath = Path.GetRelativePath(Path.Combine(StudioDirectory, "TAS Files"), path);
string? relativeDirectory = Path.GetDirectoryName(relativePath);

if (relativeDirectory != null && !Directory.Exists(Path.Combine(Everest.PathGame, "TAS Files", relativeDirectory))) {
Directory.CreateDirectory(Path.Combine(Everest.PathGame, "TAS Files", relativeDirectory));
}

File.Move(path, Path.Combine(Everest.PathGame, "TAS Files", relativePath));
}
}

// Reset everything
$"Cleaning directory '{StudioDirectory}'...".Log(LogLevel.Verbose);
if (Directory.Exists(StudioDirectory)) {
Expand Down

0 comments on commit 20cdc1c

Please sign in to comment.