From 689fee79e5b3300b4502956e9cda02632c10169a Mon Sep 17 00:00:00 2001 From: Nick Vella Date: Sun, 14 Jul 2019 19:08:17 +1000 Subject: [PATCH] ssg: StaticSitePost: ensure Id and safe slug when saving to disk --- .../Clients/StaticSite/StaticSitePost.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/managed/OpenLiveWriter.BlogClient/Clients/StaticSite/StaticSitePost.cs b/src/managed/OpenLiveWriter.BlogClient/Clients/StaticSite/StaticSitePost.cs index e3547893..8801fa0e 100644 --- a/src/managed/OpenLiveWriter.BlogClient/Clients/StaticSite/StaticSitePost.cs +++ b/src/managed/OpenLiveWriter.BlogClient/Clients/StaticSite/StaticSitePost.cs @@ -178,6 +178,17 @@ namespace OpenLiveWriter.BlogClient.Clients.StaticSite /// /// Save the post to the correct directory /// - public void SaveToDisk() => File.WriteAllText(FilePath, ToString()); + public void SaveToDisk() + { + // Generate an ID if one isn't already generated + EnsureId(); + + // Generate a safe slug if one isn't already generated + // This ensures we don't overwrite an existing post + EnsureSafeSlug(); + + // Save the post to disk + File.WriteAllText(FilePath, ToString()); + } } }