Skip to content

Commit

Permalink
fix issues introduced with the path detection change
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewSav committed Jul 3, 2024
1 parent 7915214 commit 2017ed1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
7 changes: 4 additions & 3 deletions Helpers/BackupFolders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,17 @@ private static string GetTargetBackupFolder(string profileName, DateTime lastCha
public static int MakeBackup(this GameProfile profile, DateTime x)
{
string targetPath = GetTargetBackupFolder(profile.BackupFolder, x);
string savesFolder = profile.GetSavesFolder();
if (string.IsNullOrEmpty(profile.BackupFilter))
{
CopyFolder(profile.GetSavesFolder(), targetPath);
CopyFolder(savesFolder, targetPath);
return -1;
}

int counter = 0;
foreach (string path in ApplyFilter(profile.GetSavesFolder(), profile.BackupFilter))
foreach (string path in ApplyFilter(savesFolder, profile.BackupFilter))
{
string target = path.Replace(profile.GetSavesFolder(), targetPath);
string target = path.Replace(savesFolder, targetPath);
Directory.CreateDirectory(Path.GetDirectoryName(target)!);
File.Copy(path, target, true);
counter++;
Expand Down
2 changes: 1 addition & 1 deletion Memento.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows7.0</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<Version>1.6.1</Version>
<Version>1.6.2</Version>
<ApplicationIcon>Resources\Main.ico</ApplicationIcon>
<AssemblyName>Memento</AssemblyName>
<RootNamespace>Memento</RootNamespace>
Expand Down
20 changes: 6 additions & 14 deletions Models/GameProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ private static string Replace(string source, string search, string replace)

private string DetectPath(Dictionary<string,string> pathCollection, Dictionary<string, Dictionary<string, List<string>>> prefixMap)
{
if (prefixMap == null)
{
Log($"Cannot detect path for {ProfileName} on {Environment.MachineName} because prefix map is not specified");
return null;
}

Log($"Detecting path for {ProfileName} on {Environment.MachineName}");

if (!prefixMap.TryGetValue(Environment.MachineName, out Dictionary<string, List<string>> localPrefixes))
Expand Down Expand Up @@ -173,20 +179,6 @@ string UseFirstPrefix()
return null;
}

//private static readonly Dictionary<string, Dictionary<string, List<string>>> PrefixMap = new()
//{
// ["IREALM2022"]= new()
// {
// ["UserProfilePrefix"] = [@"C:\Users\andrewsav\"],
// ["SteamPathPrefix"] = [@"D:\steam\", @"C:\steam\"]
// },
// ["13960-ASAV"] = new()
// {
// ["UserProfilePrefix"] = [@"C:\Users\admas$\"],
// ["SteamPathPrefix"] = [@"D:\Misc\steam\"]
// }
//};

public string GetSavesFolder()
{

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ To create a release via GitHub actions update version in `Memento.csproj`and cre

## Change Log

* 1.6.2
* Fixed crash if path detection would run, but no prefix map was specified
* Resolved slow downs with path detections on certain code paths
* 1.6.1
* GitHub Actions build process
* 1.6.0
Expand Down

0 comments on commit 2017ed1

Please sign in to comment.