From 9e66ee65601941aea7bd9fb591831806efd29056 Mon Sep 17 00:00:00 2001 From: Lombiq Date: Fri, 8 May 2015 16:30:26 +0200 Subject: [PATCH] Revert "Rolling back streams in storage providers, fixes #4860" This reverts commit f8e82be4b90bf31a9d591229e54b1f101daa832c. There are Stream implementation that don't support seeking so we can't do Position resetting just every time. --- .../FileSystems/Media/AzureBlobStorageProvider.cs | 4 ---- .../FileSystems/Media/FileSystemStorageProvider.cs | 12 ++++-------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Azure/Services/FileSystems/Media/AzureBlobStorageProvider.cs b/src/Orchard.Web/Modules/Orchard.Azure/Services/FileSystems/Media/AzureBlobStorageProvider.cs index 1b162cb11..2e38b1cfa 100644 --- a/src/Orchard.Web/Modules/Orchard.Azure/Services/FileSystems/Media/AzureBlobStorageProvider.cs +++ b/src/Orchard.Web/Modules/Orchard.Azure/Services/FileSystems/Media/AzureBlobStorageProvider.cs @@ -43,8 +43,6 @@ namespace Orchard.Azure.Services.FileSystems.Media { // Create the file. The CreateFile() method will map the still relative path. var file = CreateFile(path); - inputStream.Position = 0; // We need to read from the beginning of the stream, even if it isn't at it's beginning. - using (var outputStream = file.OpenWrite()) { var buffer = new byte[8192]; while (true) { @@ -54,8 +52,6 @@ namespace Orchard.Azure.Services.FileSystems.Media { outputStream.Write(buffer, 0, length); } } - - inputStream.Position = 0; // Rolling back the stream so external readers will have it easier. } /// diff --git a/src/Orchard/FileSystems/Media/FileSystemStorageProvider.cs b/src/Orchard/FileSystems/Media/FileSystemStorageProvider.cs index dcf5a5a76..e4ad40152 100644 --- a/src/Orchard/FileSystems/Media/FileSystemStorageProvider.cs +++ b/src/Orchard/FileSystems/Media/FileSystemStorageProvider.cs @@ -312,10 +312,10 @@ namespace Orchard.FileSystems.Media { /// True if success; False otherwise. public bool TrySaveStream(string path, Stream inputStream) { try { - if (FileExists(path)) { - return false; - } - + if (FileExists(path)) { + return false; + } + SaveStream(path, inputStream); } catch { @@ -336,8 +336,6 @@ namespace Orchard.FileSystems.Media { // The CreateFile method will map the still relative path var file = CreateFile(path); - inputStream.Position = 0; // We need to read from the beginning of the stream, even if it isn't at it's beginning. - using (var outputStream = file.OpenWrite()) { var buffer = new byte[8192]; for (; ; ) { @@ -348,8 +346,6 @@ namespace Orchard.FileSystems.Media { outputStream.Write(buffer, 0, length); } } - - inputStream.Position = 0; // Rolling back the stream so external readers will have it easier. } ///