Skip to content

Commit

Permalink
Don't use Path.GetTempFileName() (#16966)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAlhayek authored Nov 8, 2024
1 parent 63ecd53 commit 64e03ce
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public async Task<IActionResult> Import(ImportViewModel model)
}

// Create a temporary filename to save the archive
var tempArchiveName = Path.GetTempFileName() + ".zip";
var tempArchiveName = PathExtensions.Combine(Path.GetTempPath(), Path.GetRandomFileName()) + ".zip";

// Create a temporary folder to extract the archive to
var tempArchiveFolder = PathExtensions.Combine(Path.GetTempPath(), Path.GetRandomFileName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public async Task<IActionResult> Import(IFormFile importedPackage)

if (importedPackage != null)
{
var tempArchiveName = Path.GetTempFileName() + Path.GetExtension(importedPackage.FileName);
var tempArchiveName = PathExtensions.Combine(Path.GetTempPath(), Path.GetRandomFileName()) + Path.GetExtension(importedPackage.FileName);
var tempArchiveFolder = PathExtensions.Combine(Path.GetTempPath(), Path.GetRandomFileName());

try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ public async Task<ActionResult> Setup(SetupApiViewModel model)
return BadRequest(S["Either a 'recipe' file or 'RecipeName' is required."]);
}

var tempFilename = Path.GetTempFileName();
var tempFilename = PathExtensions.Combine(Path.GetTempPath(), Path.GetRandomFileName());

await System.IO.File.WriteAllTextAsync(tempFilename, model.Recipe);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ await context.UsingTenantScopeAsync(async scope =>
featureIds.Add(UserConstants.Features.ExternalAuthentication);
}
var tempArchiveName = Path.GetTempFileName() + ".json";
var tempArchiveName = PathExtensions.Combine(Path.GetTempPath(), Path.GetRandomFileName()) + ".json";
var tempArchiveFolder = PathExtensions.Combine(Path.GetTempPath(), Path.GetRandomFileName());
var data = new JsonObject
Expand Down

0 comments on commit 64e03ce

Please sign in to comment.