From bc8fbf107665aa6df2eb198da0669f61273d43c4 Mon Sep 17 00:00:00 2001 From: Pat Hartl Date: Sun, 2 Apr 2023 21:07:59 -0500 Subject: [PATCH] Fix saves that target a directory in the game's install directory --- .../Services/GameSaveService.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/LANCommander.Playnite.Extension/Services/GameSaveService.cs b/LANCommander.Playnite.Extension/Services/GameSaveService.cs index a650fc9b..0a9dba7d 100644 --- a/LANCommander.Playnite.Extension/Services/GameSaveService.cs +++ b/LANCommander.Playnite.Extension/Services/GameSaveService.cs @@ -94,7 +94,7 @@ namespace LANCommander.PlaynitePlugin.Services File.Move(tempSavePathFile, destination); } - else if (Directory.Exists(tempSavePathFile)) + else if (Directory.Exists(tempSavePath)) { var files = Directory.GetFiles(tempSavePath, "*", SearchOption.AllDirectories); @@ -105,14 +105,20 @@ namespace LANCommander.PlaynitePlugin.Services if (inInstallDir) { // Files are in the game's install directory. Move them there from the save path. - destination = file.Replace(tempSavePath, game.InstallDirectory); + destination = file.Replace(tempSavePath, savePath.Path.Replace('/', '\\').TrimEnd('\\').Replace("{InstallDir}", game.InstallDirectory)); + + if (File.Exists(destination)) + File.Delete(destination); File.Move(file, destination); } else { // Specified path is probably an absolute path, maybe with environment variables. - destination = Environment.ExpandEnvironmentVariables(file.Replace(tempSavePath, savePath.Path.Replace('/', '\\'))); + destination = Environment.ExpandEnvironmentVariables(file.Replace(tempSavePathFile, savePath.Path.Replace('/', '\\'))); + + if (File.Exists(destination)) + File.Delete(destination); File.Move(file, destination); }