* Take another attempt at http://opensimulator.org/mantis/view.php?id=3191
* Return something more sensible if a file isn't found0.6.6-post-fixes
parent
14f0d5e77f
commit
01ca3a91ad
|
@ -423,15 +423,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private Stream GetStream(string path)
|
private Stream GetStream(string path)
|
||||||
{
|
{
|
||||||
try
|
if (File.Exists(path))
|
||||||
{
|
{
|
||||||
if (File.Exists(path))
|
return new FileStream(path, FileMode.Open, FileAccess.Read);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
return new FileStream(path, FileMode.Open, FileAccess.Read);
|
Uri uri = new Uri(path);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Uri uri = new Uri(path); // throw exception if not valid URI
|
|
||||||
if (uri.Scheme == "file")
|
if (uri.Scheme == "file")
|
||||||
{
|
{
|
||||||
return new FileStream(uri.AbsolutePath, FileMode.Open, FileAccess.Read);
|
return new FileStream(uri.AbsolutePath, FileMode.Open, FileAccess.Read);
|
||||||
|
@ -446,16 +446,18 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||||
return URIFetch(uri);
|
return URIFetch(uri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
catch (UriFormatException)
|
||||||
catch (Exception e)
|
{
|
||||||
{
|
// In many cases the user will put in a plain old filename that cannot be found so assume that
|
||||||
throw new Exception(String.Format("Unable to create file input stream for {0}: {1}", path, e.Message));
|
// this is the problem rather than confusing the issue with a UriFormatException
|
||||||
|
throw new Exception(String.Format("Cannot find file {0}", path));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Stream URIFetch(Uri uri)
|
private static Stream URIFetch(Uri uri)
|
||||||
{
|
{
|
||||||
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(uri);
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
|
||||||
|
|
||||||
// request.Credentials = credentials;
|
// request.Credentials = credentials;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue