Skip to content

Commit 9a799fd

Browse files
committed
Ensure the replay file is written if the directory already exists
1 parent adb4d75 commit 9a799fd

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/DownloadLib.Shared/DownloadHelpers.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -511,15 +511,16 @@ await Task.WhenAll(
511511
if (!Directory.Exists(OutputFolder))
512512
{
513513
_ = Directory.CreateDirectory(OutputFolder);
514+
}
514515

515-
string tmpname = update.Xml.LocalizedProperties.Title + " (" + MachineType.ToString() + ").uupmcreplay";
516-
illegalCharacters = new Regex(@"[\\/:*?""<>|]");
517-
tmpname = illegalCharacters.Replace(tmpname, "");
518-
string filename = Path.Combine(OutputFolder, tmpname);
519-
if (WriteMetadata && !File.Exists(filename))
520-
{
521-
File.WriteAllText(filename, JsonSerializer.Serialize(update, new JsonSerializerOptions() { WriteIndented = true, IncludeFields = true }));
522-
}
516+
string tmpname = update.Xml.LocalizedProperties.Title + " (" + MachineType.ToString() + ").uupmcreplay";
517+
illegalCharacters = new Regex(@"[\\/:*?""<>|]");
518+
tmpname = illegalCharacters.Replace(tmpname, "");
519+
string filename = Path.Combine(OutputFolder, tmpname);
520+
521+
if (WriteMetadata && !File.Exists(filename))
522+
{
523+
File.WriteAllText(filename, JsonSerializer.Serialize(update, new JsonSerializerOptions() { WriteIndented = true, IncludeFields = true }));
523524
}
524525

525526
using HttpDownloader helperDl = new(OutputFolder, downloadThreads);

0 commit comments

Comments
 (0)