本文整理汇总了C#中OpenSim.Framework.Serialization.TarArchiveWriter.Close方法的典型用法代码示例。如果您正苦于以下问题:C# TarArchiveWriter.Close方法的具体用法?C# TarArchiveWriter.Close怎么用?C# TarArchiveWriter.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenSim.Framework.Serialization.TarArchiveWriter
的用法示例。
在下文中一共展示了TarArchiveWriter.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveRegionBackup
public void SaveRegionBackup(TarArchiveWriter writer, IScene scene)
{
writer.WriteDir("assets"); //Used by many, create it by default
IAuroraBackupModule[] modules = scene.RequestModuleInterfaces<IAuroraBackupModule>();
foreach (IAuroraBackupModule module in modules)
module.SaveModuleToArchive(writer, scene);
foreach (IAuroraBackupModule module in modules)
{
while (module.IsArchiving) //Wait until all are done
Thread.Sleep(100);
}
writer.Close();
GC.Collect();
MainConsole.Instance.Info("[Archive]: Finished saving of archive.");
}
示例2: TestLoadOarRegionSettings
public void TestLoadOarRegionSettings()
{
TestHelpers.InMethod();
//log4net.Config.XmlConfigurator.Configure();
MemoryStream archiveWriteStream = new MemoryStream();
TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
tar.WriteFile(
ArchiveConstants.CONTROL_FILE_PATH,
new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty).CreateControlFile(new ArchiveScenesGroup()));
RegionSettings rs = new RegionSettings();
rs.AgentLimit = 17;
rs.AllowDamage = true;
rs.AllowLandJoinDivide = true;
rs.AllowLandResell = true;
rs.BlockFly = true;
rs.BlockShowInSearch = true;
rs.BlockTerraform = true;
rs.DisableCollisions = true;
rs.DisablePhysics = true;
rs.DisableScripts = true;
rs.Elevation1NW = 15.9;
rs.Elevation1NE = 45.3;
rs.Elevation1SE = 49;
rs.Elevation1SW = 1.9;
rs.Elevation2NW = 4.5;
rs.Elevation2NE = 19.2;
rs.Elevation2SE = 9.2;
rs.Elevation2SW = 2.1;
rs.FixedSun = true;
rs.SunPosition = 12.0;
rs.ObjectBonus = 1.4;
rs.RestrictPushing = true;
rs.TerrainLowerLimit = 0.4;
rs.TerrainRaiseLimit = 17.9;
rs.TerrainTexture1 = UUID.Parse("00000000-0000-0000-0000-000000000020");
rs.TerrainTexture2 = UUID.Parse("00000000-0000-0000-0000-000000000040");
rs.TerrainTexture3 = UUID.Parse("00000000-0000-0000-0000-000000000060");
rs.TerrainTexture4 = UUID.Parse("00000000-0000-0000-0000-000000000080");
rs.UseEstateSun = true;
rs.WaterHeight = 23;
rs.TelehubObject = UUID.Parse("00000000-0000-0000-0000-111111111111");
rs.AddSpawnPoint(SpawnPoint.Parse("1,-2,0.33"));
tar.WriteFile(ArchiveConstants.SETTINGS_PATH + "region1.xml", RegionSettingsSerializer.Serialize(rs));
tar.Close();
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
lock (this)
{
m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
m_archiverModule.DearchiveRegion(archiveReadStream);
}
Assert.That(m_lastErrorMessage, Is.Null);
RegionSettings loadedRs = m_scene.RegionInfo.RegionSettings;
Assert.That(loadedRs.AgentLimit, Is.EqualTo(17));
Assert.That(loadedRs.AllowDamage, Is.True);
Assert.That(loadedRs.AllowLandJoinDivide, Is.True);
Assert.That(loadedRs.AllowLandResell, Is.True);
Assert.That(loadedRs.BlockFly, Is.True);
Assert.That(loadedRs.BlockShowInSearch, Is.True);
Assert.That(loadedRs.BlockTerraform, Is.True);
Assert.That(loadedRs.DisableCollisions, Is.True);
Assert.That(loadedRs.DisablePhysics, Is.True);
Assert.That(loadedRs.DisableScripts, Is.True);
Assert.That(loadedRs.Elevation1NW, Is.EqualTo(15.9));
Assert.That(loadedRs.Elevation1NE, Is.EqualTo(45.3));
Assert.That(loadedRs.Elevation1SE, Is.EqualTo(49));
Assert.That(loadedRs.Elevation1SW, Is.EqualTo(1.9));
Assert.That(loadedRs.Elevation2NW, Is.EqualTo(4.5));
Assert.That(loadedRs.Elevation2NE, Is.EqualTo(19.2));
Assert.That(loadedRs.Elevation2SE, Is.EqualTo(9.2));
Assert.That(loadedRs.Elevation2SW, Is.EqualTo(2.1));
Assert.That(loadedRs.FixedSun, Is.True);
Assert.AreEqual(12.0, loadedRs.SunPosition);
Assert.That(loadedRs.ObjectBonus, Is.EqualTo(1.4));
Assert.That(loadedRs.RestrictPushing, Is.True);
Assert.That(loadedRs.TerrainLowerLimit, Is.EqualTo(0.4));
Assert.That(loadedRs.TerrainRaiseLimit, Is.EqualTo(17.9));
Assert.That(loadedRs.TerrainTexture1, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000020")));
Assert.That(loadedRs.TerrainTexture2, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000040")));
Assert.That(loadedRs.TerrainTexture3, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000060")));
Assert.That(loadedRs.TerrainTexture4, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000080")));
Assert.That(loadedRs.UseEstateSun, Is.True);
Assert.That(loadedRs.WaterHeight, Is.EqualTo(23));
Assert.AreEqual(UUID.Zero, loadedRs.TelehubObject); // because no object was found with the original UUID
Assert.AreEqual(0, loadedRs.SpawnPoints().Count);
}
示例3: TestLoadOarDeededLand
public void TestLoadOarDeededLand()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
UUID landID = TestHelpers.ParseTail(0x10);
MockGroupsServicesConnector groupsService = new MockGroupsServicesConnector();
IConfigSource configSource = new IniConfigSource();
IConfig config = configSource.AddConfig("Groups");
config.Set("Enabled", true);
config.Set("Module", "GroupsModule");
config.Set("DebugEnabled", true);
SceneHelpers.SetupSceneModules(
m_scene, configSource, new object[] { new GroupsModule(), groupsService, new LandManagementModule() });
// Create group in scene for loading
// FIXME: For now we'll put up with the issue that we'll get a group ID that varies across tests.
UUID groupID
= groupsService.CreateGroup(UUID.Zero, "group1", "", true, UUID.Zero, 3, true, true, true, UUID.Zero);
// Construct OAR
MemoryStream oarStream = new MemoryStream();
TarArchiveWriter tar = new TarArchiveWriter(oarStream);
tar.WriteDir(ArchiveConstants.LANDDATA_PATH);
tar.WriteFile(
ArchiveConstants.CONTROL_FILE_PATH,
new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty).CreateControlFile(new ArchiveScenesGroup()));
LandObject lo = new LandObject(groupID, true, m_scene);
lo.SetLandBitmap(lo.BasicFullRegionLandBitmap());
LandData ld = lo.LandData;
ld.GlobalID = landID;
string ldPath = ArchiveConstants.CreateOarLandDataPath(ld);
Dictionary<string, object> options = new Dictionary<string, object>();
tar.WriteFile(ldPath, LandDataSerializer.Serialize(ld, options));
tar.Close();
oarStream = new MemoryStream(oarStream.ToArray());
// Load OAR
lock (this)
{
m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
m_archiverModule.DearchiveRegion(oarStream);
}
ILandObject rLo = m_scene.LandChannel.GetLandObject(16, 16);
LandData rLd = rLo.LandData;
Assert.That(rLd.GlobalID, Is.EqualTo(landID));
Assert.That(rLd.OwnerID, Is.EqualTo(groupID));
Assert.That(rLd.GroupID, Is.EqualTo(groupID));
Assert.That(rLd.IsGroupOwned, Is.EqualTo(true));
}
示例4: TestLoadOarUnorderedParts
public void TestLoadOarUnorderedParts()
{
TestHelpers.InMethod();
UUID ownerId = TestHelpers.ParseTail(0xaaaa);
MemoryStream archiveWriteStream = new MemoryStream();
TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
tar.WriteFile(
ArchiveConstants.CONTROL_FILE_PATH,
new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty).CreateControlFile(new ArchiveScenesGroup()));
SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, ownerId, "obj1-", 0x11);
SceneObjectPart sop2
= SceneHelpers.CreateSceneObjectPart("obj1-Part2", TestHelpers.ParseTail(0x12), ownerId);
SceneObjectPart sop3
= SceneHelpers.CreateSceneObjectPart("obj1-Part3", TestHelpers.ParseTail(0x13), ownerId);
// Add the parts so they will be written out in reverse order to the oar
sog1.AddPart(sop3);
sop3.LinkNum = 3;
sog1.AddPart(sop2);
sop2.LinkNum = 2;
tar.WriteFile(
ArchiveConstants.CreateOarObjectPath(sog1.Name, sog1.UUID, sog1.AbsolutePosition),
SceneObjectSerializer.ToXml2Format(sog1));
tar.Close();
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
lock (this)
{
m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
m_archiverModule.DearchiveRegion(archiveReadStream);
}
Assert.That(m_lastErrorMessage, Is.Null);
SceneObjectPart part2 = m_scene.GetSceneObjectPart("obj1-Part2");
Assert.That(part2.LinkNum, Is.EqualTo(2));
SceneObjectPart part3 = m_scene.GetSceneObjectPart("obj1-Part3");
Assert.That(part3.LinkNum, Is.EqualTo(3));
}
示例5: TestLoadOar
public void TestLoadOar()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
MemoryStream archiveWriteStream = new MemoryStream();
TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
// Put in a random blank directory to check that this doesn't upset the load process
tar.WriteDir("ignoreme");
// Also check that direct entries which will also have a file entry containing that directory doesn't
// upset load
tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
tar.WriteFile(
ArchiveConstants.CONTROL_FILE_PATH,
new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty).CreateControlFile(new ArchiveScenesGroup()));
SceneObjectPart part1 = CreateSceneObjectPart1();
part1.SitTargetOrientation = new Quaternion(0.2f, 0.3f, 0.4f, 0.5f);
part1.SitTargetPosition = new Vector3(1, 2, 3);
SceneObjectGroup object1 = new SceneObjectGroup(part1);
// Let's put some inventory items into our object
string soundItemName = "sound-item1";
UUID soundItemUuid = UUID.Parse("00000000-0000-0000-0000-000000000002");
Type type = GetType();
Assembly assembly = type.Assembly;
string soundDataResourceName = null;
string[] names = assembly.GetManifestResourceNames();
foreach (string name in names)
{
if (name.EndsWith(".Resources.test-sound.wav"))
soundDataResourceName = name;
}
Assert.That(soundDataResourceName, Is.Not.Null);
byte[] soundData;
UUID soundUuid;
CreateSoundAsset(tar, assembly, soundDataResourceName, out soundData, out soundUuid);
TaskInventoryItem item1
= new TaskInventoryItem { AssetID = soundUuid, ItemID = soundItemUuid, Name = soundItemName };
part1.Inventory.AddInventoryItem(item1, true);
m_scene.AddNewSceneObject(object1, false);
string object1FileName = string.Format(
"{0}_{1:000}-{2:000}-{3:000}__{4}.xml",
part1.Name,
Math.Round(part1.GroupPosition.X), Math.Round(part1.GroupPosition.Y), Math.Round(part1.GroupPosition.Z),
part1.UUID);
tar.WriteFile(ArchiveConstants.OBJECTS_PATH + object1FileName, SceneObjectSerializer.ToXml2Format(object1));
tar.Close();
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
lock (this)
{
m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
m_archiverModule.DearchiveRegion(archiveReadStream);
}
Assert.That(m_lastErrorMessage, Is.Null);
TestLoadedRegion(part1, soundItemName, soundData);
}
示例6: TestLoadOarV0_2
public void TestLoadOarV0_2()
{
TestHelper.InMethod();
//log4net.Config.XmlConfigurator.Configure();
MemoryStream archiveWriteStream = new MemoryStream();
TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
// Put in a random blank directory to check that this doesn't upset the load process
tar.WriteDir("ignoreme");
// Also check that direct entries which will also have a file entry containing that directory doesn't
// upset load
tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile());
SceneObjectPart part1 = CreateSceneObjectPart1();
SceneObjectGroup object1 = new SceneObjectGroup(part1);
// Let's put some inventory items into our object
string soundItemName = "sound-item1";
UUID soundItemUuid = UUID.Parse("00000000-0000-0000-0000-000000000002");
Type type = GetType();
Assembly assembly = type.Assembly;
string soundDataResourceName = null;
string[] names = assembly.GetManifestResourceNames();
foreach (string name in names)
{
if (name.EndsWith(".Resources.test-sound.wav"))
soundDataResourceName = name;
}
Assert.That(soundDataResourceName, Is.Not.Null);
byte[] soundData;
Console.WriteLine("Loading " + soundDataResourceName);
using (Stream resource = assembly.GetManifestResourceStream(soundDataResourceName))
{
using (BinaryReader br = new BinaryReader(resource))
{
// FIXME: Use the inspector insteadthere are so many forums and lists already, though admittedly none of them are suitable for cross virtual-enivornemnt discussion
soundData = br.ReadBytes(99999999);
UUID soundUuid = UUID.Parse("00000000-0000-0000-0000-000000000001");
string soundAssetFileName
= ArchiveConstants.ASSETS_PATH + soundUuid
+ ArchiveConstants.ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SoundWAV];
tar.WriteFile(soundAssetFileName, soundData);
/*
AssetBase soundAsset = AssetHelpers.CreateAsset(soundUuid, soundData);
scene.AssetService.Store(soundAsset);
asset1FileName = ArchiveConstants.ASSETS_PATH + soundUuid + ".wav";
*/
TaskInventoryItem item1
= new TaskInventoryItem { AssetID = soundUuid, ItemID = soundItemUuid, Name = soundItemName };
part1.Inventory.AddInventoryItem(item1, true);
}
}
m_scene.AddNewSceneObject(object1, false);
string object1FileName = string.Format(
"{0}_{1:000}-{2:000}-{3:000}__{4}.xml",
part1.Name,
Math.Round(part1.GroupPosition.X), Math.Round(part1.GroupPosition.Y), Math.Round(part1.GroupPosition.Z),
part1.UUID);
tar.WriteFile(ArchiveConstants.OBJECTS_PATH + object1FileName, SceneObjectSerializer.ToXml2Format(object1));
tar.Close();
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
lock (this)
{
m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
m_archiverModule.DearchiveRegion(archiveReadStream);
}
Assert.That(m_lastErrorMessage, Is.Null);
SceneObjectPart object1PartLoaded = m_scene.GetSceneObjectPart(part1.Name);
Assert.That(object1PartLoaded, Is.Not.Null, "object1 was not loaded");
Assert.That(object1PartLoaded.Name, Is.EqualTo(part1.Name), "object1 names not identical");
Assert.That(object1PartLoaded.GroupPosition, Is.EqualTo(part1.GroupPosition), "object1 group position not equal");
Assert.That(
object1PartLoaded.RotationOffset, Is.EqualTo(part1.RotationOffset), "object1 rotation offset not equal");
Assert.That(
object1PartLoaded.OffsetPosition, Is.EqualTo(part1.OffsetPosition), "object1 offset position not equal");
TaskInventoryItem loadedSoundItem = object1PartLoaded.Inventory.GetInventoryItems(soundItemName)[0];
Assert.That(loadedSoundItem, Is.Not.Null, "loaded sound item was null");
AssetBase loadedSoundAsset = m_scene.AssetService.Get(loadedSoundItem.AssetID.ToString());
Assert.That(loadedSoundAsset, Is.Not.Null, "loaded sound asset was null");
Assert.That(loadedSoundAsset.Data, Is.EqualTo(soundData), "saved and loaded sound data do not match");
// Temporary
Console.WriteLine("Successfully completed {0}", MethodBase.GetCurrentMethod());
}
示例7: TestLoadIarV0p1ExistingUsers
public void TestLoadIarV0p1ExistingUsers()
{
Assert.Ignore();
TestHelper.InMethod();
Console.WriteLine("Started {0}", MethodBase.GetCurrentMethod());
//log4net.Config.XmlConfigurator.Configure();
string userFirstName = "Mr";
string userLastName = "Tiddles";
UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000555");
string user2FirstName = "Lord";
string user2LastName = "Lucan";
UUID user2Uuid = UUID.Parse("00000000-0000-0000-0000-000000000666");
string itemName = "b.lsl";
string archiveItemName
= string.Format("{0}{1}{2}", itemName, "_", UUID.Random());
MemoryStream archiveWriteStream = new MemoryStream();
TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
InventoryItemBase item1 = new InventoryItemBase();
item1.Name = itemName;
item1.AssetID = UUID.Random();
item1.GroupID = UUID.Random();
item1.CreatorId = OspResolver.MakeOspa(user2FirstName, user2LastName);
//item1.CreatorId = userUuid.ToString();
//item1.CreatorId = "00000000-0000-0000-0000-000000000444";
item1.Owner = UUID.Zero;
string item1FileName
= string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1));
tar.Close();
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
SerialiserModule serialiserModule = new SerialiserModule();
InventoryArchiverModule archiverModule = new InventoryArchiverModule();
// Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
Scene scene = SceneSetupHelpers.SetupScene();
IUserAdminService userAdminService = scene.CommsManager.UserAdminService;
SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
userAdminService.AddUser(
userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid);
userAdminService.AddUser(
user2FirstName, user2LastName, "hampshire", String.Empty, 1000, 1000, user2Uuid);
archiverModule.DearchiveInventory(userFirstName, userLastName, "/", archiveReadStream);
CachedUserInfo userInfo
= scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName);
InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName);
Assert.That(foundItem.CreatorId, Is.EqualTo(item1.CreatorId));
Assert.That(foundItem.CreatorIdAsUuid, Is.EqualTo(user2Uuid));
Assert.That(foundItem.Owner, Is.EqualTo(userUuid));
Console.WriteLine("Successfully completed {0}", MethodBase.GetCurrentMethod());
}
示例8: TestLoadIarV0_1AbsentUsers
public void TestLoadIarV0_1AbsentUsers()
{
TestHelper.InMethod();
//log4net.Config.XmlConfigurator.Configure();
string userFirstName = "Charlie";
string userLastName = "Chan";
UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000999");
string userItemCreatorFirstName = "Bat";
string userItemCreatorLastName = "Man";
//UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000008888");
string itemName = "b.lsl";
string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random());
MemoryStream archiveWriteStream = new MemoryStream();
TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
InventoryItemBase item1 = new InventoryItemBase();
item1.Name = itemName;
item1.AssetID = UUID.Random();
item1.GroupID = UUID.Random();
item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName);
//item1.CreatorId = userUuid.ToString();
//item1.CreatorId = "00000000-0000-0000-0000-000000000444";
item1.Owner = UUID.Zero;
string item1FileName
= string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1));
tar.Close();
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
SerialiserModule serialiserModule = new SerialiserModule();
InventoryArchiverModule archiverModule = new InventoryArchiverModule(true);
// Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
Scene scene = SceneSetupHelpers.SetupScene("inventory");
SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userUuid, "meowfood");
archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "meowfood", archiveReadStream);
InventoryItemBase foundItem1
= InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userUuid, itemName);
Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
// Assert.That(
// foundItem1.CreatorId, Is.EqualTo(userUuid),
// "Loaded item non-uuid creator doesn't match that of the loading user");
Assert.That(
foundItem1.CreatorIdAsUuid, Is.EqualTo(userUuid),
"Loaded item uuid creator doesn't match that of the loading user");
}
示例9: TestLoadIarV0_1ExistingUsers
public void TestLoadIarV0_1ExistingUsers()
{
TestHelper.InMethod();
//log4net.Config.XmlConfigurator.Configure();
string userFirstName = "Mr";
string userLastName = "Tiddles";
UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000555");
string userItemCreatorFirstName = "Lord";
string userItemCreatorLastName = "Lucan";
UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000000666");
string item1Name = "b.lsl";
string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1Name, UUID.Random());
MemoryStream archiveWriteStream = new MemoryStream();
TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
InventoryItemBase item1 = new InventoryItemBase();
item1.Name = item1Name;
item1.AssetID = UUID.Random();
item1.GroupID = UUID.Random();
item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName);
//item1.CreatorId = userUuid.ToString();
//item1.CreatorId = "00000000-0000-0000-0000-000000000444";
item1.Owner = UUID.Zero;
string item1FileName
= string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1));
tar.Close();
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
SerialiserModule serialiserModule = new SerialiserModule();
InventoryArchiverModule archiverModule = new InventoryArchiverModule(true);
// Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
Scene scene = SceneSetupHelpers.SetupScene("inventory");
IUserAdminService userAdminService = scene.CommsManager.UserAdminService;
SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
userAdminService.AddUser(
userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid);
userAdminService.AddUser(
userItemCreatorFirstName, userItemCreatorLastName, "hampshire",
String.Empty, 1000, 1000, userItemCreatorUuid);
archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "meowfood", archiveReadStream);
CachedUserInfo userInfo
= scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName);
InventoryItemBase foundItem1
= InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, item1Name);
Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
// We have to disable this check since loaded items that did find users via OSPA resolution are now only storing the
// UUID, not the OSPA itself.
// Assert.That(
// foundItem1.CreatorId, Is.EqualTo(item1.CreatorId),
// "Loaded item non-uuid creator doesn't match original");
Assert.That(
foundItem1.CreatorId, Is.EqualTo(userItemCreatorUuid.ToString()),
"Loaded item non-uuid creator doesn't match original");
Assert.That(
foundItem1.CreatorIdAsUuid, Is.EqualTo(userItemCreatorUuid),
"Loaded item uuid creator doesn't match original");
Assert.That(foundItem1.Owner, Is.EqualTo(userUuid),
"Loaded item owner doesn't match inventory reciever");
// Now try loading to a root child folder
UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userInfo.UserProfile.ID, "xA");
archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
archiverModule.DearchiveInventory(userFirstName, userLastName, "xA", "meowfood", archiveReadStream);
InventoryItemBase foundItem2
= InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xA/" + item1Name);
Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2");
// Now try loading to a more deeply nested folder
UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC");
archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
archiverModule.DearchiveInventory(userFirstName, userLastName, "xB/xC", "meowfood", archiveReadStream);
InventoryItemBase foundItem3
= InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC/" + item1Name);
Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3");
}
示例10: Execute
/// <summary>
/// Execute the inventory write request
/// </summary>
public void Execute()
{
InventoryFolderBase inventoryFolder = null;
InventoryItemBase inventoryItem = null;
InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(m_userInfo.UserProfile.ID);
bool foundStar = false;
// Eliminate double slashes and any leading / on the path.
string[] components
= m_invPath.Split(
new string[] { InventoryFolderImpl.PATH_DELIMITER }, StringSplitOptions.RemoveEmptyEntries);
int maxComponentIndex = components.Length - 1;
// If the path terminates with a STAR then later on we want to archive all nodes in the folder but not the
// folder itself. This may get more sophisicated later on
if (maxComponentIndex >= 0 && components[maxComponentIndex] == STAR_WILDCARD)
{
foundStar = true;
maxComponentIndex--;
}
m_invPath = String.Empty;
for (int i = 0; i <= maxComponentIndex; i++)
{
m_invPath += components[i] + InventoryFolderImpl.PATH_DELIMITER;
}
// Annoyingly Split actually returns the original string if the input string consists only of delimiters
// Therefore if we still start with a / after the split, then we need the root folder
if (m_invPath.Length == 0)
{
inventoryFolder = rootFolder;
}
else
{
m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER));
inventoryFolder
= InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, rootFolder, m_invPath);
//inventoryFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath);
}
// The path may point to an item instead
if (inventoryFolder == null)
{
inventoryItem = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, rootFolder, m_invPath);
//inventoryItem = m_userInfo.RootFolder.FindItemByPath(m_invPath);
}
if (null == inventoryFolder && null == inventoryItem)
{
// We couldn't find the path indicated
string errorMessage = string.Format("Aborted save. Could not find inventory path {0}", m_invPath);
m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", errorMessage);
m_module.TriggerInventoryArchiveSaved(
m_id, false, m_userInfo, m_invPath, m_saveStream,
new Exception(errorMessage));
return;
}
m_archiveWriter = new TarArchiveWriter(m_saveStream);
try
{
if (inventoryFolder != null)
{
m_log.DebugFormat(
"[INVENTORY ARCHIVER]: Found folder {0} {1} at {2}",
inventoryFolder.Name, inventoryFolder.ID, m_invPath);
//recurse through all dirs getting dirs and files
SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !foundStar);
}
else if (inventoryItem != null)
{
m_log.DebugFormat(
"[INVENTORY ARCHIVER]: Found item {0} {1} at {2}",
inventoryItem.Name, inventoryItem.ID, m_invPath);
SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH);
}
// Don't put all this profile information into the archive right now.
//SaveUsers();
}
catch (Exception)
{
m_archiveWriter.Close();
throw;
}
new AssetsRequest(
new AssetsArchiver(m_archiveWriter), m_assetUuids.Keys,
m_scene.AssetService, ReceivedAllAssets).Execute();
}
示例11: SaveBackup
//.........这里部分代码省略.........
m_log.WarnFormat ("[Backup]: Exception caught: {0}", ex.ToString ());
}
if (entitiesToSave.Count > 0)
{
m_log.Fatal (entitiesToSave.Count + " PRIMS WERE NOT GOING TO BE SAVED! FORCE SAVING NOW! ");
foreach (ISceneEntity entity in saveentities)
{
if (entitiesToSave.Contains(entity.UUID))
{
if (entity.IsAttachment || ((entity.RootChild.Flags & PrimFlags.Temporary) == PrimFlags.Temporary)
|| ((entity.RootChild.Flags & PrimFlags.TemporaryOnRez) == PrimFlags.TemporaryOnRez))
continue;
//Write all entities
byte[] xml = ((ISceneObject)entity).ToBinaryXml2 ();
writer.WriteFile ("entities/" + entity.UUID.ToString (), xml);
xml = null;
}
}
}
if(saveAssets)
{
foreach(UUID assetID in new List<UUID>(assets.Keys))
{
try
{
AssetBase asset = m_scene.AssetService.GetCached(assetID.ToString());
if(asset == null)
asset = m_scene.AssetService.Get(assetID.ToString());
WriteAsset(assetID.ToString(), asset, writer);
}
catch(Exception ex)
{
m_log.WarnFormat("[Backup]: Exception caught: {0}", ex.ToString());
}
}
}
writer.Close ();
m_loadStream.Close ();
m_saveStream.Close ();
GC.Collect ();
if (m_keepOldSave && !m_oldSaveHasBeenSaved)
{
//Havn't moved it yet, so make sure the directory exists, then move it
m_oldSaveHasBeenSaved = true;
if (!Directory.Exists (m_oldSaveDirectory))
Directory.CreateDirectory (m_oldSaveDirectory);
File.Copy(fileName + ".tmp", Path.Combine(m_oldSaveDirectory, m_scene.RegionInfo.RegionName + SerializeDateTime() + m_saveAppenedFileName + ".abackup"));
}
//Just remove the file
File.Delete (fileName);
}
else
{
//Add the .temp since we might need to make a backup and so that if something goes wrong, we don't corrupt the main backup
GZipStream m_saveStream = new GZipStream (new FileStream (fileName + ".tmp", FileMode.Create), CompressionMode.Compress);
TarArchiveWriter writer = new TarArchiveWriter (m_saveStream);
IAuroraBackupArchiver archiver = m_scene.RequestModuleInterface<IAuroraBackupArchiver> ();
//Turn off prompting so that we don't ask the user questions every time we need to save the backup
archiver.AllowPrompting = false;
archiver.SaveRegionBackup (writer, m_scene);
archiver.AllowPrompting = true;
//If we got this far, we assume that everything went well, so now we move the stuff around
if (File.Exists (fileName))
{
//If keepOldSave is enabled, the user wants us to move the first backup that we originally loaded from into the oldSaveDirectory
if(m_keepOldSave && !m_oldSaveHasBeenSaved)
{
//Havn't moved it yet, so make sure the directory exists, then move it
m_oldSaveHasBeenSaved = true;
if(!Directory.Exists(m_oldSaveDirectory))
Directory.CreateDirectory(m_oldSaveDirectory);
File.Copy(fileName + ".tmp", Path.Combine(m_oldSaveDirectory, m_scene.RegionInfo.RegionName + SerializeDateTime() + m_saveAppenedFileName + ".abackup"));
}
//Just remove the file
File.Delete(fileName);
}
}
ISceneEntity[] entities = m_scene.Entities.GetEntities ();
try
{
foreach (ISceneEntity entity in entities)
{
if (entity.HasGroupChanged)
entity.HasGroupChanged = false;
}
}
catch (Exception ex)
{
m_log.WarnFormat ("[Backup]: Exception caught: {0}", ex.ToString ());
}
//Now make it the full file again
File.Move (fileName + ".tmp", fileName);
m_log.Info ("[FileBasedSimulationData]: Saved Backup for region " + m_scene.RegionInfo.RegionName);
}
示例12: TestLoadOarV0_2RegionSettings
public void TestLoadOarV0_2RegionSettings()
{
TestHelper.InMethod();
//log4net.Config.XmlConfigurator.Configure();
MemoryStream archiveWriteStream = new MemoryStream();
TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.Create0p2ControlFile(new Dictionary<string, Object>()));
RegionSettings rs = new RegionSettings();
rs.AgentLimit = 17;
rs.AllowDamage = true;
rs.AllowLandJoinDivide = true;
rs.AllowLandResell = true;
rs.BlockFly = true;
rs.BlockShowInSearch = true;
rs.BlockTerraform = true;
rs.DisableCollisions = true;
rs.DisablePhysics = true;
rs.DisableScripts = true;
rs.Elevation1NW = 15.9;
rs.Elevation1NE = 45.3;
rs.Elevation1SE = 49;
rs.Elevation1SW = 1.9;
rs.Elevation2NW = 4.5;
rs.Elevation2NE = 19.2;
rs.Elevation2SE = 9.2;
rs.Elevation2SW = 2.1;
rs.FixedSun = true;
rs.ObjectBonus = 1.4;
rs.RestrictPushing = true;
rs.TerrainLowerLimit = 0.4;
rs.TerrainRaiseLimit = 17.9;
rs.TerrainTexture1 = UUID.Parse("00000000-0000-0000-0000-000000000020");
rs.TerrainTexture2 = UUID.Parse("00000000-0000-0000-0000-000000000040");
rs.TerrainTexture3 = UUID.Parse("00000000-0000-0000-0000-000000000060");
rs.TerrainTexture4 = UUID.Parse("00000000-0000-0000-0000-000000000080");
rs.UseEstateSun = true;
rs.WaterHeight = 23;
tar.WriteFile(ArchiveConstants.SETTINGS_PATH + "region1.xml", RegionSettingsSerializer.Serialize(rs));
tar.Close();
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
lock (this)
{
m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
m_archiverModule.DearchiveRegion(archiveReadStream);
}
Assert.That(m_lastErrorMessage, Is.Null);
RegionSettings loadedRs = m_scene.RegionInfo.RegionSettings;
Assert.That(loadedRs.AgentLimit, Is.EqualTo(17));
Assert.That(loadedRs.AllowDamage, Is.True);
Assert.That(loadedRs.AllowLandJoinDivide, Is.True);
Assert.That(loadedRs.AllowLandResell, Is.True);
Assert.That(loadedRs.BlockFly, Is.True);
Assert.That(loadedRs.BlockShowInSearch, Is.True);
Assert.That(loadedRs.BlockTerraform, Is.True);
Assert.That(loadedRs.DisableCollisions, Is.True);
Assert.That(loadedRs.DisablePhysics, Is.True);
Assert.That(loadedRs.DisableScripts, Is.True);
Assert.That(loadedRs.Elevation1NW, Is.EqualTo(15.9));
Assert.That(loadedRs.Elevation1NE, Is.EqualTo(45.3));
Assert.That(loadedRs.Elevation1SE, Is.EqualTo(49));
Assert.That(loadedRs.Elevation1SW, Is.EqualTo(1.9));
Assert.That(loadedRs.Elevation2NW, Is.EqualTo(4.5));
Assert.That(loadedRs.Elevation2NE, Is.EqualTo(19.2));
Assert.That(loadedRs.Elevation2SE, Is.EqualTo(9.2));
Assert.That(loadedRs.Elevation2SW, Is.EqualTo(2.1));
Assert.That(loadedRs.FixedSun, Is.True);
Assert.That(loadedRs.ObjectBonus, Is.EqualTo(1.4));
Assert.That(loadedRs.RestrictPushing, Is.True);
Assert.That(loadedRs.TerrainLowerLimit, Is.EqualTo(0.4));
Assert.That(loadedRs.TerrainRaiseLimit, Is.EqualTo(17.9));
Assert.That(loadedRs.TerrainTexture1, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000020")));
Assert.That(loadedRs.TerrainTexture2, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000040")));
Assert.That(loadedRs.TerrainTexture3, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000060")));
Assert.That(loadedRs.TerrainTexture4, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000080")));
Assert.That(loadedRs.UseEstateSun, Is.True);
Assert.That(loadedRs.WaterHeight, Is.EqualTo(23));
}
示例13: TestLoadIarV0_1ExistingUsers
/// <summary>
/// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
/// an account exists with the creator name.
/// </summary>
//[Test]
public void TestLoadIarV0_1ExistingUsers()
{
TestHelper.InMethod();
log4net.Config.XmlConfigurator.Configure();
string userFirstName = "Mr";
string userLastName = "Tiddles";
UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000555");
string userItemCreatorFirstName = "Lord";
string userItemCreatorLastName = "Lucan";
UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000000666");
string itemName = "b.lsl";
string archiveItemName
= string.Format("{0}{1}{2}", itemName, "_", UUID.Random());
MemoryStream archiveWriteStream = new MemoryStream();
TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
InventoryItemBase item1 = new InventoryItemBase();
item1.Name = itemName;
item1.AssetID = UUID.Random();
item1.GroupID = UUID.Random();
item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName);
//item1.CreatorId = userUuid.ToString();
//item1.CreatorId = "00000000-0000-0000-0000-000000000444";
item1.Owner = UUID.Zero;
string item1FileName
= string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1));
tar.Close();
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
SerialiserModule serialiserModule = new SerialiserModule();
InventoryArchiverModule archiverModule = new InventoryArchiverModule();
// Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
Scene scene = SceneSetupHelpers.SetupScene();
IUserAdminService userAdminService = scene.CommsManager.UserAdminService;
SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
userAdminService.AddUser(
userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid);
userAdminService.AddUser(
userItemCreatorFirstName, userItemCreatorLastName, "hampshire",
String.Empty, 1000, 1000, userItemCreatorUuid);
archiverModule.DearchiveInventory(userFirstName, userLastName, "/", archiveReadStream);
CachedUserInfo userInfo
= scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName);
//userInfo.FetchInventory();
/*
for (int i = 0 ; i < 50 ; i++)
{
if (userInfo.HasReceivedInventory == true)
break;
Thread.Sleep(200);
}
Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
*/
InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName);
Assert.That(foundItem, Is.Not.Null, "Didn't find loaded item");
Assert.That(
foundItem.CreatorId, Is.EqualTo(item1.CreatorId),
"Loaded item non-uuid creator doesn't match original");
Assert.That(
foundItem.CreatorIdAsUuid, Is.EqualTo(userItemCreatorUuid),
"Loaded item uuid creator doesn't match original");
Assert.That(foundItem.Owner, Is.EqualTo(userUuid),
"Loaded item owner doesn't match inventory reciever");
}
示例14: SaveRegionBackup
public void SaveRegionBackup(TarArchiveWriter writer, IScene scene)
{
writer.WriteDir("assets"); //Used by many, create it by default
IAuroraBackupModule[] modules = scene.RequestModuleInterfaces<IAuroraBackupModule>();
foreach (IAuroraBackupModule module in modules)
module.SaveModuleToArchive(writer, scene);
foreach (IAuroraBackupModule module in modules)
{
while (module.IsArchiving) //Wait until all are done
System.Threading.Thread.Sleep(100);
}
writer.Close();
}
示例15: Execute
//.........这里部分代码省略.........
= m_invPath.Split(
new[] {InventoryFolderImpl.PATH_DELIMITER}, StringSplitOptions.RemoveEmptyEntries);
int maxComponentIndex = components.Length - 1;
// If the path terminates with a STAR then later on we want to archive all nodes in the folder but not the
// folder itself. This may get more sophisicated later on
if (maxComponentIndex >= 0 && components[maxComponentIndex] == STAR_WILDCARD)
{
saveFolderContentsOnly = true;
maxComponentIndex--;
}
m_invPath = String.Empty;
for (int i = 0; i <= maxComponentIndex; i++)
{
m_invPath += components[i] + InventoryFolderImpl.PATH_DELIMITER;
}
// Annoyingly Split actually returns the original string if the input string consists only of delimiters
// Therefore if we still start with a / after the split, then we need the root folder
if (m_invPath.Length == 0)
{
inventoryFolder = rootFolder;
}
else
{
m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER));
List<InventoryFolderBase> candidateFolders
= InventoryArchiveUtils.FindFolderByPath(
m_registry.RequestModuleInterface<IInventoryService>(), rootFolder, m_invPath);
if (candidateFolders.Count > 0)
inventoryFolder = candidateFolders[0];
}
// The path may point to an item instead
if (inventoryFolder == null)
{
inventoryItem =
InventoryArchiveUtils.FindItemByPath(m_registry.RequestModuleInterface<IInventoryService>(),
rootFolder, m_invPath);
//inventoryItem = m_userInfo.RootFolder.FindItemByPath(m_invPath);
}
if (null == inventoryFolder && null == inventoryItem)
{
// We couldn't find the path indicated
string errorMessage = string.Format("Aborted save. Could not find inventory path {0}", m_invPath);
Exception e = new InventoryArchiverException(errorMessage);
if (m_module != null)
m_module.TriggerInventoryArchiveSaved(m_id, false, m_userInfo, m_invPath, m_saveStream, e);
throw e;
}
m_archiveWriter = new TarArchiveWriter(m_saveStream);
if (inventoryFolder != null)
{
MainConsole.Instance.DebugFormat(
"[INVENTORY ARCHIVER]: Found folder {0} {1} at {2}",
inventoryFolder.Name,
inventoryFolder.ID,
m_invPath == String.Empty ? InventoryFolderImpl.PATH_DELIMITER : m_invPath);
//recurse through all dirs getting dirs and files
SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !saveFolderContentsOnly);
}
else if (inventoryItem != null)
{
MainConsole.Instance.DebugFormat(
"[INVENTORY ARCHIVER]: Found item {0} {1} at {2}",
inventoryItem.Name, inventoryItem.ID, m_invPath);
SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH);
}
// Don't put all this profile information into the archive right now.
//SaveUsers();
}
catch (Exception)
{
m_saveStream.Close();
throw;
}
if (m_saveAssets)
{
foreach (AssetBase asset in m_assetsToAdd)
{
m_assetUuids[asset.ID] = (AssetType) asset.Type;
}
new AssetsRequest(
new AssetsArchiver(m_archiveWriter), m_assetUuids,
m_registry.RequestModuleInterface<IAssetService>(), ReceivedAllAssets).Execute();
}
else
{
MainConsole.Instance.Debug("[INVENTORY ARCHIVER]: Save Complete");
m_archiveWriter.Close();
}
}