Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use Path.GetTempFileName() #16966

Merged
merged 2 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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