summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2018-08-19 21:08:58 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2018-08-19 21:08:58 -0400
commit307bf6ce55e8880f0e0382cb678d7fcc6c74c11e (patch)
tree98b83ee9144ffca37a73067cfe9fa561a21045ac
parent100e303b488a36e8410ff67e32c35bff80f21ba2 (diff)
downloadSMAPI-307bf6ce55e8880f0e0382cb678d7fcc6c74c11e.tar.gz
SMAPI-307bf6ce55e8880f0e0382cb678d7fcc6c74c11e.tar.bz2
SMAPI-307bf6ce55e8880f0e0382cb678d7fcc6c74c11e.zip
adjust SaveBackup mod to simplify installer logic (#583)
-rw-r--r--docs/release-notes.md4
-rw-r--r--src/SMAPI.Installer/InteractiveInstaller.cs30
-rw-r--r--src/SMAPI.Mods.SaveBackup/Framework/ModConfig.cs9
-rw-r--r--src/SMAPI.Mods.SaveBackup/ModEntry.cs13
-rw-r--r--src/SMAPI.Mods.SaveBackup/StardewModdingAPI.Mods.SaveBackup.csproj3
5 files changed, 15 insertions, 44 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md
index c742204e..7a30b0b6 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -3,6 +3,7 @@
* For players:
* Added support for subfolders under `Mods`, for players who want to organise their mods.
* Moved most SMAPI files into a `smapi-internal` subfolder.
+ * Moved save backups into a `save-backups` subfolder (instead of `Mods/SaveBackup/backups`).
* Updated compatibility list.
* For modders:
@@ -12,6 +13,9 @@
* Fixed `IContentPack.ReadJsonFile` allowing non-relative paths.
* **Breaking change:** most SMAPI files have been moved into a `smapi-internal` subfolder. This won't affect compiled mods, but you'll need to update the mod build config NuGet package when compiling mods.
+* For SMAPI developers:
+ * Adjusted `SaveBackup` mod to make it easier to account for custom mod subfolders in the installer.
+
## 2.7
* For players:
* Updated for Stardew Valley 1.3.28.
diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs
index f9e1ff94..a92edadf 100644
--- a/src/SMAPI.Installer/InteractiveInstaller.cs
+++ b/src/SMAPI.Installer/InteractiveInstaller.cs
@@ -22,12 +22,6 @@ namespace StardewModdingApi.Installer
/// <summary>The name of the installer file in the package.</summary>
private readonly string InstallerFileName = "install.exe";
- /// <summary>Mod files which shouldn't be deleted when deploying bundled mods (mod folder name => file names).</summary>
- private readonly IDictionary<string, HashSet<string>> ProtectBundledFiles = new Dictionary<string, HashSet<string>>(StringComparer.InvariantCultureIgnoreCase)
- {
- ["SaveBackup"] = new HashSet<string>(new[] { "backups", "config.json" }, StringComparer.InvariantCultureIgnoreCase)
- };
-
/// <summary>The <see cref="Environment.OSVersion"/> value that represents Windows 7.</summary>
private readonly Version Windows7Version = new Version(6, 1);
@@ -474,18 +468,6 @@ namespace StardewModdingApi.Installer
{
this.PrintDebug("Adding bundled mods...");
- // special case: rename Omegasis' SaveBackup mod
- {
- DirectoryInfo oldFolder = new DirectoryInfo(Path.Combine(paths.ModsDir.FullName, "SaveBackup"));
- DirectoryInfo newFolder = new DirectoryInfo(Path.Combine(paths.ModsDir.FullName, "AdvancedSaveBackup"));
- FileInfo manifest = new FileInfo(Path.Combine(oldFolder.FullName, "manifest.json"));
- if (manifest.Exists && !newFolder.Exists && File.ReadLines(manifest.FullName).Any(p => p.IndexOf("Omegasis", StringComparison.InvariantCultureIgnoreCase) != -1))
- {
- this.PrintDebug($" moving {oldFolder.Name} to {newFolder.Name}...");
- this.Move(oldFolder, newFolder.FullName);
- }
- }
-
// add bundled mods
foreach (DirectoryInfo sourceDir in packagedModsDir.EnumerateDirectories())
{
@@ -494,16 +476,8 @@ namespace StardewModdingApi.Installer
// init/clear target dir
DirectoryInfo targetDir = new DirectoryInfo(Path.Combine(paths.ModsDir.FullName, sourceDir.Name));
if (targetDir.Exists)
- {
- this.ProtectBundledFiles.TryGetValue(targetDir.Name, out HashSet<string> protectedFiles);
- foreach (FileSystemInfo entry in targetDir.EnumerateFileSystemInfos())
- {
- if (protectedFiles == null || !protectedFiles.Contains(entry.Name))
- this.InteractivelyDelete(entry.FullName);
- }
- }
- else
- targetDir.Create();
+ this.InteractivelyDelete(targetDir.FullName);
+ targetDir.Create();
// copy files
foreach (FileInfo sourceFile in sourceDir.EnumerateFiles().Where(this.ShouldCopy))
diff --git a/src/SMAPI.Mods.SaveBackup/Framework/ModConfig.cs b/src/SMAPI.Mods.SaveBackup/Framework/ModConfig.cs
deleted file mode 100644
index c9dcb216..00000000
--- a/src/SMAPI.Mods.SaveBackup/Framework/ModConfig.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace StardewModdingAPI.Mods.SaveBackup.Framework
-{
- /// <summary>The mod configuration.</summary>
- internal class ModConfig
- {
- /// <summary>The number of backups to keep.</summary>
- public int BackupsToKeep { get; set; } = 10;
- }
-}
diff --git a/src/SMAPI.Mods.SaveBackup/ModEntry.cs b/src/SMAPI.Mods.SaveBackup/ModEntry.cs
index 78578c3c..4d56789a 100644
--- a/src/SMAPI.Mods.SaveBackup/ModEntry.cs
+++ b/src/SMAPI.Mods.SaveBackup/ModEntry.cs
@@ -4,7 +4,6 @@ using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
-using StardewModdingAPI.Mods.SaveBackup.Framework;
using StardewValley;
namespace StardewModdingAPI.Mods.SaveBackup
@@ -15,6 +14,12 @@ namespace StardewModdingAPI.Mods.SaveBackup
/*********
** Properties
*********/
+ /// <summary>The number of backups to keep.</summary>
+ private readonly int BackupsToKeep = 10;
+
+ /// <summary>The absolute path to the folder in which to store save backups.</summary>
+ private readonly string BackupFolder = Path.Combine(Constants.ExecutionPath, "save-backups");
+
/// <summary>The name of the save archive to create.</summary>
private readonly string FileName = $"{DateTime.UtcNow:yyyy-MM-dd} - SMAPI {Constants.ApiVersion} with Stardew Valley {Game1.version}.zip";
@@ -28,15 +33,13 @@ namespace StardewModdingAPI.Mods.SaveBackup
{
try
{
- ModConfig config = this.Helper.ReadConfig<ModConfig>();
-
// init backup folder
- DirectoryInfo backupFolder = new DirectoryInfo(Path.Combine(this.Helper.DirectoryPath, "backups"));
+ DirectoryInfo backupFolder = new DirectoryInfo(this.BackupFolder);
backupFolder.Create();
// back up saves
this.CreateBackup(backupFolder);
- this.PruneBackups(backupFolder, config.BackupsToKeep);
+ this.PruneBackups(backupFolder, this.BackupsToKeep);
}
catch (Exception ex)
{
diff --git a/src/SMAPI.Mods.SaveBackup/StardewModdingAPI.Mods.SaveBackup.csproj b/src/SMAPI.Mods.SaveBackup/StardewModdingAPI.Mods.SaveBackup.csproj
index 0ccbcc6c..fafa4d25 100644
--- a/src/SMAPI.Mods.SaveBackup/StardewModdingAPI.Mods.SaveBackup.csproj
+++ b/src/SMAPI.Mods.SaveBackup/StardewModdingAPI.Mods.SaveBackup.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
@@ -36,7 +36,6 @@
<Compile Include="..\..\build\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
- <Compile Include="Framework\ModConfig.cs" />
<Compile Include="ModEntry.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>