mirror of
https://github.com/opensim/opensim.git
synced 2026-08-08 10:15:33 +08:00
Merge branch 'master' into careminster-presence-refactor
This commit is contained in:
@@ -37,7 +37,6 @@ using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Communications;
|
||||
|
||||
using OpenSim.Framework.Communications.Osp;
|
||||
using OpenSim.Framework.Serialization;
|
||||
using OpenSim.Framework.Serialization.External;
|
||||
@@ -72,7 +71,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
scene,
|
||||
userInfo,
|
||||
invPath,
|
||||
new GZipStream(new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress))
|
||||
new GZipStream(ArchiveHelpers.GetStream(loadPath), CompressionMode.Decompress))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ using OpenSim.Framework;
|
||||
using OpenSim.Framework.Serialization;
|
||||
using OpenSim.Framework.Serialization.External;
|
||||
using OpenSim.Framework.Communications;
|
||||
|
||||
using OpenSim.Framework.Communications.Osp;
|
||||
using OpenSim.Region.CoreModules.World.Archiver;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
@@ -91,13 +91,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
|
||||
scene.AddCommand(
|
||||
this, "load iar",
|
||||
"load iar <first> <last> <inventory path> <password> [<archive path>]",
|
||||
"Load user inventory archive.", HandleLoadInvConsoleCommand);
|
||||
"load iar <first> <last> <inventory path> <password> [<IAR path>]",
|
||||
"Load user inventory archive (IAR).",
|
||||
"<first> is user's first name." + Environment.NewLine
|
||||
+ "<last> is user's last name." + Environment.NewLine
|
||||
+ "<inventory path> is the path inside the user's inventory where the IAR should be loaded." + Environment.NewLine
|
||||
+ "<password> is the user's password." + Environment.NewLine
|
||||
+ "<IAR path> is the filesystem path or URI from which to load the IAR."
|
||||
+ string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME),
|
||||
HandleLoadInvConsoleCommand);
|
||||
|
||||
scene.AddCommand(
|
||||
this, "save iar",
|
||||
"save iar <first> <last> <inventory path> <password> [<archive path>]",
|
||||
"Save user inventory archive.", HandleSaveInvConsoleCommand);
|
||||
"save iar <first> <last> <inventory path> <password> [<IAR path>]",
|
||||
"Save user inventory archive (IAR).",
|
||||
"<first> is the user's first name." + Environment.NewLine
|
||||
+ "<last> is the user's last name." + Environment.NewLine
|
||||
+ "<inventory path> is the path inside the user's inventory for the folder/item to be saved." + Environment.NewLine
|
||||
+ "<IAR path> is the filesystem path at which to save the IAR."
|
||||
+ string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME),
|
||||
HandleSaveInvConsoleCommand);
|
||||
|
||||
m_aScene = scene;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ using OpenSim.Framework;
|
||||
using OpenSim.Framework.Serialization;
|
||||
using OpenSim.Framework.Serialization.External;
|
||||
using OpenSim.Framework.Communications;
|
||||
|
||||
using OpenSim.Framework.Communications.Osp;
|
||||
using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
|
||||
using OpenSim.Region.CoreModules.World.Serialiser;
|
||||
@@ -77,125 +76,118 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||
// Commenting for now! The mock inventory service needs more beef, at least for
|
||||
// GetFolderForType
|
||||
// REFACTORING PROBLEM. This needs to be rewritten.
|
||||
//[Test]
|
||||
public void TestSaveIarV0_1()
|
||||
{
|
||||
TestHelper.InMethod();
|
||||
log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
// [Test]
|
||||
// public void TestSaveIarV0_1()
|
||||
// {
|
||||
// TestHelper.InMethod();
|
||||
// //log4net.Config.XmlConfigurator.Configure();
|
||||
InventoryArchiverModule archiverModule = new InventoryArchiverModule(true);
|
||||
|
||||
// InventoryArchiverModule archiverModule = new InventoryArchiverModule(true);
|
||||
Scene scene = SceneSetupHelpers.SetupScene("Inventory");
|
||||
SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
|
||||
|
||||
// Scene scene = SceneSetupHelpers.SetupScene("Inventory");
|
||||
// SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
|
||||
// CommunicationsManager cm = scene.CommsManager;
|
||||
|
||||
// // Create user
|
||||
// string userFirstName = "Jock";
|
||||
// string userLastName = "Stirrup";
|
||||
// UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
|
||||
|
||||
// lock (this)
|
||||
// {
|
||||
// UserProfileTestUtils.CreateUserWithInventory(
|
||||
// cm, userFirstName, userLastName, userId, InventoryReceived);
|
||||
// Monitor.Wait(this, 60000);
|
||||
// }
|
||||
// Create user
|
||||
string userFirstName = "Jock";
|
||||
string userLastName = "Stirrup";
|
||||
string userPassword = "troll";
|
||||
UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
|
||||
UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword);
|
||||
|
||||
// // Create asset
|
||||
// SceneObjectGroup object1;
|
||||
// SceneObjectPart part1;
|
||||
// {
|
||||
// string partName = "My Little Dog Object";
|
||||
// UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
|
||||
// PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
|
||||
// Vector3 groupPosition = new Vector3(10, 20, 30);
|
||||
// Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
|
||||
// Vector3 offsetPosition = new Vector3(5, 10, 15);
|
||||
// Create asset
|
||||
SceneObjectGroup object1;
|
||||
SceneObjectPart part1;
|
||||
{
|
||||
string partName = "My Little Dog Object";
|
||||
UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
|
||||
PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
|
||||
Vector3 groupPosition = new Vector3(10, 20, 30);
|
||||
Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
|
||||
Vector3 offsetPosition = new Vector3(5, 10, 15);
|
||||
|
||||
// part1
|
||||
// = new SceneObjectPart(
|
||||
// ownerId, shape, groupPosition, rotationOffset, offsetPosition);
|
||||
// part1.Name = partName;
|
||||
part1
|
||||
= new SceneObjectPart(
|
||||
ownerId, shape, groupPosition, rotationOffset, offsetPosition);
|
||||
part1.Name = partName;
|
||||
|
||||
// object1 = new SceneObjectGroup(part1);
|
||||
// scene.AddNewSceneObject(object1, false);
|
||||
// }
|
||||
object1 = new SceneObjectGroup(part1);
|
||||
scene.AddNewSceneObject(object1, false);
|
||||
}
|
||||
|
||||
// UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
|
||||
// AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
|
||||
// scene.AssetService.Store(asset1);
|
||||
UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
|
||||
AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
|
||||
scene.AssetService.Store(asset1);
|
||||
|
||||
// // Create item
|
||||
// UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
|
||||
// InventoryItemBase item1 = new InventoryItemBase();
|
||||
// item1.Name = "My Little Dog";
|
||||
// item1.AssetID = asset1.FullID;
|
||||
// item1.ID = item1Id;
|
||||
// InventoryFolderBase objsFolder
|
||||
// = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects");
|
||||
// item1.Folder = objsFolder.ID;
|
||||
// scene.AddInventoryItem(userId, item1);
|
||||
// Create item
|
||||
UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
|
||||
InventoryItemBase item1 = new InventoryItemBase();
|
||||
item1.Name = "My Little Dog";
|
||||
item1.AssetID = asset1.FullID;
|
||||
item1.ID = item1Id;
|
||||
InventoryFolderBase objsFolder
|
||||
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects");
|
||||
item1.Folder = objsFolder.ID;
|
||||
scene.AddInventoryItem(userId, item1);
|
||||
|
||||
// MemoryStream archiveWriteStream = new MemoryStream();
|
||||
// archiverModule.OnInventoryArchiveSaved += SaveCompleted;
|
||||
MemoryStream archiveWriteStream = new MemoryStream();
|
||||
archiverModule.OnInventoryArchiveSaved += SaveCompleted;
|
||||
|
||||
// mre.Reset();
|
||||
// archiverModule.ArchiveInventory(
|
||||
// Guid.NewGuid(), userFirstName, userLastName, "Objects", "troll", archiveWriteStream);
|
||||
// mre.WaitOne(60000, false);
|
||||
mre.Reset();
|
||||
archiverModule.ArchiveInventory(
|
||||
Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream);
|
||||
mre.WaitOne(60000, false);
|
||||
|
||||
// byte[] archive = archiveWriteStream.ToArray();
|
||||
// MemoryStream archiveReadStream = new MemoryStream(archive);
|
||||
// TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
|
||||
byte[] archive = archiveWriteStream.ToArray();
|
||||
MemoryStream archiveReadStream = new MemoryStream(archive);
|
||||
TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
|
||||
|
||||
// //bool gotControlFile = false;
|
||||
// bool gotObject1File = false;
|
||||
// //bool gotObject2File = false;
|
||||
// string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1);
|
||||
// string expectedObject1FilePath = string.Format(
|
||||
// "{0}{1}{2}",
|
||||
// ArchiveConstants.INVENTORY_PATH,
|
||||
// InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder),
|
||||
// expectedObject1FileName);
|
||||
//bool gotControlFile = false;
|
||||
bool gotObject1File = false;
|
||||
//bool gotObject2File = false;
|
||||
string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1);
|
||||
string expectedObject1FilePath = string.Format(
|
||||
"{0}{1}{2}",
|
||||
ArchiveConstants.INVENTORY_PATH,
|
||||
InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder),
|
||||
expectedObject1FileName);
|
||||
|
||||
// string filePath;
|
||||
// TarArchiveReader.TarEntryType tarEntryType;
|
||||
string filePath;
|
||||
TarArchiveReader.TarEntryType tarEntryType;
|
||||
|
||||
// Console.WriteLine("Reading archive");
|
||||
|
||||
// while (tar.ReadEntry(out filePath, out tarEntryType) != null)
|
||||
// {
|
||||
// Console.WriteLine("Got {0}", filePath);
|
||||
while (tar.ReadEntry(out filePath, out tarEntryType) != null)
|
||||
{
|
||||
Console.WriteLine("Got {0}", filePath);
|
||||
|
||||
//// if (ArchiveConstants.CONTROL_FILE_PATH == filePath)
|
||||
//// {
|
||||
//// gotControlFile = true;
|
||||
//// }
|
||||
|
||||
// if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml"))
|
||||
// if (ArchiveConstants.CONTROL_FILE_PATH == filePath)
|
||||
// {
|
||||
//// string fileName = filePath.Remove(0, "Objects/".Length);
|
||||
////
|
||||
//// if (fileName.StartsWith(part1.Name))
|
||||
//// {
|
||||
// Assert.That(expectedObject1FilePath, Is.EqualTo(filePath));
|
||||
// gotObject1File = true;
|
||||
//// }
|
||||
//// else if (fileName.StartsWith(part2.Name))
|
||||
//// {
|
||||
//// Assert.That(fileName, Is.EqualTo(expectedObject2FileName));
|
||||
//// gotObject2File = true;
|
||||
//// }
|
||||
// gotControlFile = true;
|
||||
// }
|
||||
// }
|
||||
|
||||
if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml"))
|
||||
{
|
||||
// string fileName = filePath.Remove(0, "Objects/".Length);
|
||||
//
|
||||
// if (fileName.StartsWith(part1.Name))
|
||||
// {
|
||||
Assert.That(expectedObject1FilePath, Is.EqualTo(filePath));
|
||||
gotObject1File = true;
|
||||
// }
|
||||
// else if (fileName.StartsWith(part2.Name))
|
||||
// {
|
||||
// Assert.That(fileName, Is.EqualTo(expectedObject2FileName));
|
||||
// gotObject2File = true;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
//// Assert.That(gotControlFile, Is.True, "No control file in archive");
|
||||
// Assert.That(gotObject1File, Is.True, "No item1 file in archive");
|
||||
//// Assert.That(gotObject2File, Is.True, "No object2 file in archive");
|
||||
// Assert.That(gotControlFile, Is.True, "No control file in archive");
|
||||
Assert.That(gotObject1File, Is.True, "No item1 file in archive");
|
||||
// Assert.That(gotObject2File, Is.True, "No object2 file in archive");
|
||||
|
||||
// // TODO: Test presence of more files and contents of files.
|
||||
// }
|
||||
// TODO: Test presence of more files and contents of files.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
|
||||
@@ -541,56 +533,41 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||
/// <summary>
|
||||
/// Test replication of an archive path to the user's inventory.
|
||||
/// </summary>
|
||||
//[Test]
|
||||
//public void TestReplicateArchivePathToUserInventory()
|
||||
//{
|
||||
// TestHelper.InMethod();
|
||||
[Test]
|
||||
public void TestReplicateArchivePathToUserInventory()
|
||||
{
|
||||
TestHelper.InMethod();
|
||||
//log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
Scene scene = SceneSetupHelpers.SetupScene("inventory");
|
||||
UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
|
||||
|
||||
Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>();
|
||||
List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>();
|
||||
|
||||
string folder1Name = "a";
|
||||
string folder2Name = "b";
|
||||
string itemName = "c.lsl";
|
||||
|
||||
string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random());
|
||||
string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
|
||||
string itemArchiveName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random());
|
||||
|
||||
string itemArchivePath
|
||||
= string.Format(
|
||||
"{0}{1}{2}{3}",
|
||||
ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName);
|
||||
|
||||
// //log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
// Scene scene = SceneSetupHelpers.SetupScene("inventory");
|
||||
// CommunicationsManager commsManager = scene.CommsManager;
|
||||
// CachedUserInfo userInfo;
|
||||
new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null)
|
||||
.ReplicateArchivePathToUserInventory(
|
||||
itemArchivePath, false, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
|
||||
foldersCreated, nodesLoaded);
|
||||
|
||||
// lock (this)
|
||||
// {
|
||||
// // !!! REFACTORING PROBLEM. This needs to be rewritten
|
||||
// userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, InventoryReceived);
|
||||
// Monitor.Wait(this, 60000);
|
||||
// }
|
||||
|
||||
// //Console.WriteLine("userInfo.RootFolder 1: {0}", userInfo.RootFolder);
|
||||
|
||||
// Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>();
|
||||
// List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>();
|
||||
|
||||
// string folder1Name = "a";
|
||||
// string folder2Name = "b";
|
||||
// string itemName = "c.lsl";
|
||||
|
||||
// string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random());
|
||||
// string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
|
||||
// string itemArchiveName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random());
|
||||
|
||||
// string itemArchivePath
|
||||
// = string.Format(
|
||||
// "{0}{1}{2}{3}",
|
||||
// ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName);
|
||||
|
||||
// //Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder);
|
||||
|
||||
// new InventoryArchiveReadRequest(scene, userInfo, null, (Stream)null)
|
||||
// .ReplicateArchivePathToUserInventory(
|
||||
// itemArchivePath, false, scene.InventoryService.GetRootFolder(userInfo.UserProfile.ID),
|
||||
// foldersCreated, nodesLoaded);
|
||||
|
||||
// //Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder);
|
||||
// //InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a");
|
||||
// InventoryFolderBase folder1
|
||||
// = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userInfo.UserProfile.ID, "a");
|
||||
// Assert.That(folder1, Is.Not.Null, "Could not find folder a");
|
||||
// InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b");
|
||||
// Assert.That(folder2, Is.Not.Null, "Could not find folder b");
|
||||
//}
|
||||
InventoryFolderBase folder1
|
||||
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, "a");
|
||||
Assert.That(folder1, Is.Not.Null, "Could not find folder a");
|
||||
InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b");
|
||||
Assert.That(folder2, Is.Not.Null, "Could not find folder b");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,9 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework.Serialization;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
@@ -60,5 +63,66 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
{
|
||||
return ArchiveConstants.CreateOarObjectPath(sog.Name, sog.UUID, sog.AbsolutePosition);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolve path to a working FileStream
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <returns></returns>
|
||||
public static Stream GetStream(string path)
|
||||
{
|
||||
if (File.Exists(path))
|
||||
{
|
||||
return new FileStream(path, FileMode.Open, FileAccess.Read);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
Uri uri = new Uri(path);
|
||||
if (uri.Scheme == "file")
|
||||
{
|
||||
return new FileStream(uri.AbsolutePath, FileMode.Open, FileAccess.Read);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (uri.Scheme != "http")
|
||||
throw new Exception(String.Format("Unsupported URI scheme ({0})", path));
|
||||
|
||||
// OK, now we know we have an HTTP URI to work with
|
||||
return URIFetch(uri);
|
||||
}
|
||||
}
|
||||
catch (UriFormatException)
|
||||
{
|
||||
// In many cases the user will put in a plain old filename that cannot be found so assume that
|
||||
// this is the problem rather than confusing the issue with a UriFormatException
|
||||
throw new Exception(String.Format("Cannot find file {0}", path));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Stream URIFetch(Uri uri)
|
||||
{
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
|
||||
|
||||
// request.Credentials = credentials;
|
||||
|
||||
request.ContentLength = 0;
|
||||
request.KeepAlive = false;
|
||||
|
||||
WebResponse response = request.GetResponse();
|
||||
Stream file = response.GetResponseStream();
|
||||
|
||||
// justincc: gonna ignore the content type for now and just try anything
|
||||
//if (response.ContentType != "application/x-oar")
|
||||
// throw new Exception(String.Format("{0} does not identify an OAR file", uri.ToString()));
|
||||
|
||||
if (response.ContentLength == 0)
|
||||
throw new Exception(String.Format("{0} returned an empty file", uri.ToString()));
|
||||
|
||||
// return new BufferedStream(file, (int) response.ContentLength);
|
||||
return new BufferedStream(file, 1000000);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
|
||||
try
|
||||
{
|
||||
m_loadStream = new GZipStream(GetStream(loadPath), CompressionMode.Decompress);
|
||||
m_loadStream = new GZipStream(ArchiveHelpers.GetStream(loadPath), CompressionMode.Decompress);
|
||||
}
|
||||
catch (EntryPointNotFoundException e)
|
||||
{
|
||||
@@ -472,68 +472,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolve path to a working FileStream
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <returns></returns>
|
||||
private Stream GetStream(string path)
|
||||
{
|
||||
if (File.Exists(path))
|
||||
{
|
||||
return new FileStream(path, FileMode.Open, FileAccess.Read);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
Uri uri = new Uri(path);
|
||||
if (uri.Scheme == "file")
|
||||
{
|
||||
return new FileStream(uri.AbsolutePath, FileMode.Open, FileAccess.Read);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (uri.Scheme != "http")
|
||||
throw new Exception(String.Format("Unsupported URI scheme ({0})", path));
|
||||
|
||||
// OK, now we know we have an HTTP URI to work with
|
||||
|
||||
return URIFetch(uri);
|
||||
}
|
||||
}
|
||||
catch (UriFormatException)
|
||||
{
|
||||
// In many cases the user will put in a plain old filename that cannot be found so assume that
|
||||
// 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)
|
||||
{
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
|
||||
|
||||
// request.Credentials = credentials;
|
||||
|
||||
request.ContentLength = 0;
|
||||
request.KeepAlive = false;
|
||||
|
||||
WebResponse response = request.GetResponse();
|
||||
Stream file = response.GetResponseStream();
|
||||
|
||||
// justincc: gonna ignore the content type for now and just try anything
|
||||
//if (response.ContentType != "application/x-oar")
|
||||
// throw new Exception(String.Format("{0} does not identify an OAR file", uri.ToString()));
|
||||
|
||||
if (response.ContentLength == 0)
|
||||
throw new Exception(String.Format("{0} returned an empty file", uri.ToString()));
|
||||
|
||||
// return new BufferedStream(file, (int) response.ContentLength);
|
||||
return new BufferedStream(file, 1000000);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load oar control file
|
||||
/// </summary>
|
||||
|
||||
@@ -1014,7 +1014,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||
|
||||
int lastMapRefresh = 0;
|
||||
int twoDays = 172800;
|
||||
int RefreshSeconds = twoDays;
|
||||
// int RefreshSeconds = twoDays;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user