Skip to content

Commit

Permalink
Try moving directory first to reduce time and disk writing
Browse files Browse the repository at this point in the history
  • Loading branch information
ccloli committed Apr 6, 2023
1 parent 0793639 commit 15bd325
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
24 changes: 16 additions & 8 deletions LegacyInstaller/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,22 @@ private async Task InstallVersion(Version version)
await _steamProcess.Downloader.DownloadDepot(version.ManifestId, FileSystemChanged);

// Copy files
this.Dispatcher.Invoke((Action)delegate { installStateLabel.Content = "Copying..."; });
Directory.CreateDirectory(SelectedVersionInstallDir);
var watcher = new FileSystemWatcher(SelectedVersionInstallDir);
watcher.NotifyFilter = NotifyFilters.Attributes | NotifyFilters.CreationTime | NotifyFilters.DirectoryName | NotifyFilters.FileName | NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.Security | NotifyFilters.Size;
watcher.IncludeSubdirectories = true;
watcher.EnableRaisingEvents = true;
watcher.Changed += FileSystemChanged;
await Utilities.CopyDirectory(_steamProcess.Downloader.ContentAppDepotDir, SelectedVersionInstallDir);
try
{
this.Dispatcher.Invoke((Action)delegate { installStateLabel.Content = "Moving..."; });
Utilities.MoveDirectory(_steamProcess.Downloader.ContentAppDepotDir, SelectedVersionInstallDir);
}
catch
{
this.Dispatcher.Invoke((Action)delegate { installStateLabel.Content = "Copying..."; });
Directory.CreateDirectory(SelectedVersionInstallDir);
var watcher = new FileSystemWatcher(SelectedVersionInstallDir);
watcher.NotifyFilter = NotifyFilters.Attributes | NotifyFilters.CreationTime | NotifyFilters.DirectoryName | NotifyFilters.FileName | NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.Security | NotifyFilters.Size;
watcher.IncludeSubdirectories = true;
watcher.EnableRaisingEvents = true;
watcher.Changed += FileSystemChanged;
await Utilities.CopyDirectory(_steamProcess.Downloader.ContentAppDepotDir, SelectedVersionInstallDir);
}

// Install to steam
this.Dispatcher.Invoke((Action)delegate { installStateLabel.Content = "Installing..."; });
Expand Down
5 changes: 5 additions & 0 deletions LegacyInstaller/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ public static async Task CopyDirectory(string sourceDir, string targetDir)
catch { }
}

public static void MoveDirectory(string sourceDir, string targetDir)
{
Directory.Move(sourceDir, targetDir);
}

public static int Search(byte[] src, byte[] pattern)
{
int maxFirstCharSlot = src.Length - pattern.Length + 1;
Expand Down

0 comments on commit 15bd325

Please sign in to comment.