diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-08-16 17:22:44 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-08-25 18:18:37 -0400 |
commit | 68e629f17c349b685ef3c4836552adcbed0c4976 (patch) | |
tree | c17931e92b3914d08d8bdff8e4d35e6ea26bdba6 /src/SMAPI/Framework/ModHelpers | |
parent | c20fcec169d75b395636b06adcbec8d5101447fd (diff) | |
download | SMAPI-68e629f17c349b685ef3c4836552adcbed0c4976.tar.gz SMAPI-68e629f17c349b685ef3c4836552adcbed0c4976.tar.bz2 SMAPI-68e629f17c349b685ef3c4836552adcbed0c4976.zip |
fix data helper's WriteJsonFile not deleting file if data is null (#799)
Diffstat (limited to 'src/SMAPI/Framework/ModHelpers')
-rw-r--r-- | src/SMAPI/Framework/ModHelpers/DataHelper.cs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/SMAPI/Framework/ModHelpers/DataHelper.cs b/src/SMAPI/Framework/ModHelpers/DataHelper.cs index 0fe3209f..4cbfd73f 100644 --- a/src/SMAPI/Framework/ModHelpers/DataHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/DataHelper.cs @@ -58,7 +58,11 @@ namespace StardewModdingAPI.Framework.ModHelpers throw new InvalidOperationException($"You must call {nameof(IMod.Helper)}.{nameof(IModHelper.Data)}.{nameof(this.WriteJsonFile)} with a relative path (without directory climbing)."); path = Path.Combine(this.ModFolderPath, PathUtilities.NormalizePath(path)); - this.JsonHelper.WriteJsonFile(path, data); + + if (data != null) + this.JsonHelper.WriteJsonFile(path, data); + else + File.Delete(path); } /**** |