ssg: StaticSiteClient: delete output file on post failure

This commit is contained in:
Nick Vella 2019-07-03 14:24:01 +10:00
parent 5976ae3b32
commit 72b197bdef
1 changed files with 16 additions and 6 deletions

View File

@ -111,8 +111,11 @@ namespace OpenLiveWriter.BlogClient.Clients
// Write to file
var fileName = GetFileNameForPost(post, publish);
File.WriteAllText($"{LocalSitePath}/{PostsPath}/{fileName}.html", outputFile.ToString());
var fullPath = $"{LocalSitePath}/{PostsPath}/{fileName}";
File.WriteAllText(fullPath, outputFile.ToString());
try
{
// Build the site, if required
if (BuildCommand != string.Empty) DoSiteBuild();
@ -120,6 +123,13 @@ namespace OpenLiveWriter.BlogClient.Clients
DoSitePublish();
return "";
} catch (Exception ex)
{
// Clean up our output file
File.Delete(fullPath);
// Throw the exception up
throw ex;
}
}
public bool EditPost(string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish, out string etag, out XmlDocument remotePost)