Adding more fallbacks for BufferingHelper temporary folder location
Fixes: https://github.com/aspnet/HttpAbstractions/issues/168
This commit is contained in:
parent
543e0f4863
commit
a6670114b1
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Microsoft.AspNet.Http;
|
|
||||||
using Microsoft.AspNet.WebUtilities;
|
using Microsoft.AspNet.WebUtilities;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Http.Core
|
namespace Microsoft.AspNet.Http.Core
|
||||||
|
|
@ -16,11 +15,9 @@ namespace Microsoft.AspNet.Http.Core
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var temp = Environment.GetEnvironmentVariable("ASPNET_TEMP");
|
// Look for folders in the following order.
|
||||||
if (string.IsNullOrEmpty(temp))
|
var temp = Environment.GetEnvironmentVariable("ASPNET_TEMP") ?? // ASPNET_TEMP - User set temporary location.
|
||||||
{
|
Path.GetTempPath(); // Fall back.
|
||||||
temp = Environment.GetEnvironmentVariable("TEMP");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Directory.Exists(temp))
|
if (!Directory.Exists(temp))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System.IO;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.Http.Core.Tests
|
||||||
|
{
|
||||||
|
public class BufferingHelperTests
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void GetTempDirectory_Returns_Valid_Location()
|
||||||
|
{
|
||||||
|
var tempDirectory = BufferingHelper.TempDirectory;
|
||||||
|
Assert.NotNull(tempDirectory);
|
||||||
|
Assert.True(Directory.Exists(tempDirectory));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue