Skip to content

Commit f090df0

Browse files
committed
fix mod blacklist update failing if the new version is shorter
Previously `blacklist-update.json` was updated using `File.OpenWrite`, which doesn't truncate before overwriting. If the previous version was longer, that left the longer part at the end of the file.
1 parent 2993301 commit f090df0

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

‎docs/release-notes.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Improved performance.
77
* Improved error message when a mod is blocked by Windows Smart App Control.
88
* Improved translations. Thanks to To2morrow (updated Korean)!
9+
* Fixed rare edge case where a mod blacklist update could fail.
910
* Updated internal mod blacklist.
1011

1112
* For mod authors:

‎src/SMAPI/Framework/SCore.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1840,7 +1840,7 @@ private async Task CheckForUpdatesAsync(IModMetadata[] mods)
18401840

18411841
// save new file
18421842
await using (Stream downloadStream = await newData.AsStream())
1843-
await using (FileStream stream = File.OpenWrite(Constants.ApiBlacklistFetchedPath))
1843+
await using (FileStream stream = File.Create(Constants.ApiBlacklistFetchedPath))
18441844
await downloadStream.CopyToAsync(stream);
18451845

18461846
this.Monitor.Log($" Mod blacklist updated to match the server (updated from {localHash} to {serverHash}). The changes will take effect on the next SMAPI launch.");

0 commit comments

Comments
 (0)