From c445821ac23bfd9b972bd815219d16851617336f Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Thu, 7 Nov 2024 10:28:24 -0800 Subject: [PATCH] don't bother with async on the File.Delete --- .../Services/PdfMediaFileTextProvider.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Media.Indexing.Pdf/Services/PdfMediaFileTextProvider.cs b/src/OrchardCore.Modules/OrchardCore.Media.Indexing.Pdf/Services/PdfMediaFileTextProvider.cs index 0bfa01f3de4..e0f6d503689 100644 --- a/src/OrchardCore.Modules/OrchardCore.Media.Indexing.Pdf/Services/PdfMediaFileTextProvider.cs +++ b/src/OrchardCore.Modules/OrchardCore.Media.Indexing.Pdf/Services/PdfMediaFileTextProvider.cs @@ -16,7 +16,7 @@ public async Task GetTextAsync(string path, Stream fileStream) { if (!fileStream.CanSeek) { - seekableStream = GetTemporaryFileStream(); + seekableStream = new FileStream(Path.GetTempFileName(), FileMode.Create, FileAccess.Write, FileShare.None, 4096, FileOptions.DeleteOnClose | FileOptions.Asynchronous); await fileStream.CopyToAsync(seekableStream); @@ -38,16 +38,7 @@ public async Task GetTextAsync(string path, Stream fileStream) if (seekableStream != null) { await seekableStream.DisposeAsync(); - - await Task.Run(() => File.Delete(seekableStream.Name)); } } } - - private static FileStream GetTemporaryFileStream() - { - var tempFilePath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); - - return new FileStream(tempFilePath, FileMode.Create, FileAccess.Write); - } }