From 21fd4093df8055b3349ff910e5001c4a4ad281e7 Mon Sep 17 00:00:00 2001
From: Manuel Thalmann <m@nuth.ch>
Date: Tue, 1 Aug 2023 12:48:27 +0200
Subject: [PATCH] Allow archives to not be split

---
 scripts/Windows/OS/Manage.ps1       |  2 +-
 scripts/Windows/Scripts/Context.ps1 | 17 ++++++++++++++---
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/scripts/Windows/OS/Manage.ps1 b/scripts/Windows/OS/Manage.ps1
index 1231ee34..b3d2c044 100644
--- a/scripts/Windows/OS/Manage.ps1
+++ b/scripts/Windows/OS/Manage.ps1
@@ -10,7 +10,7 @@ function Backup-WindowsInstallation([Context] $context) {
     $backupRoot = $context.BackupRoot();
     Backup-PersonalFiles $context;
     Backup-PersonalApps $context;
-    $context.Backup($backupRoot, "$backupRoot.7z");
+    $context.Backup($backupRoot, "$backupRoot.7z", @(), $false);
     $context.Cleanup();
 }
 
diff --git a/scripts/Windows/Scripts/Context.ps1 b/scripts/Windows/Scripts/Context.ps1
index f5c4f729..f4fb2540 100644
--- a/scripts/Windows/Scripts/Context.ps1
+++ b/scripts/Windows/Scripts/Context.ps1
@@ -151,6 +151,10 @@ class Context {
     }
 
     [void] Backup([string]$sourcePath, [string]$archivePath, [string[]]$arguments) {
+        $this.Backup($sourcePath, $archivePath, $arguments, $true);
+    }
+
+    [void] Backup([string]$sourcePath, [string]$archivePath, [string[]]$arguments, [bool]$split) {
         if (Test-Path $archivePath) {
             Remove-Item -Recurse $archivePath;
         }
@@ -163,16 +167,23 @@ class Context {
                     "-xr!desktop.ini",
                     "-xr!thumbs.db",
                     "-xr!Thumbs.db",
-                    "-v3g",
                     "-slp",
                     #"-mx=9",
-                    $archivePath) + $arguments) `
+                    $archivePath) + $arguments + (
+                        if ($split) {
+                            @("-v3g");
+                        } else {
+                            @();
+                        }
+                    )) `
             -Wait `
             -NoNewWindow;
     }
 
     [void] Restore([string]$archivePath, [string]$destinationPath) {
-        $archivePath = "$archivePath.001";
+        if (-not (Test-Path -PathType Leaf $archivePath)) {
+            $archivePath = "$archivePath.001";
+        }
 
         if (-not (Test-Path -PathType Leaf $archivePath)) {
             Write-Information (