Skip to content

Commit

Permalink
New snapshot folder (#6)
Browse files Browse the repository at this point in the history
* new snapshot folder

Unsure when this changes but now snapshots are stored in the root containers folder.

* Support Win10 and Win11
  • Loading branch information
oopsmishap authored Oct 13, 2024
1 parent c0d5f6e commit cd02e6e
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions Installer/Installer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,37 @@ static int Main(string[] args)
Console.WriteLine("Success!");

// Without this the sandbox can use a snapshot and load the original bootmgfw.efi
var snapshotFolder = Path.Combine(guid, "Snapshot");
if (Directory.Exists(snapshotFolder))
// Win10: Containers/BaseImages/{GUID}/Snapshot
// Win11: Microsoft/Windows/Containers/Snapshots/{GUID}
var snapshotFolderWin11 = Path.Combine(programData, "Microsoft", "Windows", "Containers", "Snapshots");
var snapshotFolderWin10 = Path.Combine(guid, "Snapshot");
var snapshotDeleted = false;

if (Directory.Exists(snapshotFolderWin11))
{
foreach(var snapshot in Directory.EnumerateDirectories(snapshotFolderWin11))
{
Directory.Delete(snapshot, true);
Info($"Deleted snapshot: {snapshot}");
}

snapshotDeleted = true;
}
else if (Directory.Exists(snapshotFolderWin10))
{
Directory.Delete(snapshotFolderWin10, true);

Info($"Delted snapshot folder: {snapshotFolderWin10}");

snapshotDeleted = true;
}
else
{
Info($"Snapshot folder not found: {snapshotFolderWin11} or {snapshotFolderWin10}, not restarting CmService");
}

if (snapshotDeleted)
{
Info($"Deleting sandbox snapshots");
Directory.Delete(snapshotFolder, true);
Info($"Restarting CmService");
Exec("sc", "stop CmService");
WaitForService("CmService", "STOPPED");
Expand Down

0 comments on commit cd02e6e

Please sign in to comment.