From dc95e38e42dbc2d1386375a2ff70341f4a92be94 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sun, 22 May 2011 14:59:18 -0400 Subject: Add stubs for unimplemented lsl functions --- .../Shared/Api/Implementation/LSL_Api.cs | 85 +++++++++++++++++----- 1 file changed, 67 insertions(+), 18 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 1cf03b8..e3d0dac 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3316,12 +3316,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return m_ScriptEngine.GetStartParameter(m_itemID); } - public void llGodLikeRezObject(string inventory, LSL_Vector pos) - { - m_host.AddScriptLPS(1); - NotImplemented("llGodLikeRezObject"); - } - public void llRequestPermissions(string agent, int perm) { UUID agentID = new UUID(); @@ -4189,12 +4183,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.CollisionSoundVolume = (float)impact_volume; } - public void llCollisionSprite(string impact_sprite) - { - m_host.AddScriptLPS(1); - NotImplemented("llCollisionSprite"); - } - public LSL_String llGetAnimation(string id) { // This should only return a value if the avatar is in the same region @@ -5526,12 +5514,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ScriptSleep(100); } - public void llSetSoundQueueing(int queue) - { - m_host.AddScriptLPS(1); - NotImplemented("llSetSoundQueueing"); - } - public void llSetSoundRadius(double radius) { m_host.AddScriptLPS(1); @@ -10312,6 +10294,73 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return rq.ToString(); } + + #region Not Implemented + // + // Listing the unimplemented lsl functions here, please move + // them from this region as they are completed + // + public void llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options) + { + m_host.AddScriptLPS(1); + NotImplemented("llCastRay"); + + } + + public void llGetEnv(LSL_String name) + { + m_host.AddScriptLPS(1); + NotImplemented("llGetEnv"); + + } + + public void llGetSPMaxMemory() + { + m_host.AddScriptLPS(1); + NotImplemented("llGetSPMaxMemory"); + + } + + public void llGetUsedMemory() + { + m_host.AddScriptLPS(1); + NotImplemented("llGetUsedMemory"); + + } + + public void llRegionSayTo( LSL_Key target, LSL_Integer channel, LSL_String msg ) + { + m_host.AddScriptLPS(1); + NotImplemented("llRegionSayTo"); + + } + + public void llScriptProfiler( LSL_Integer flags ) + { + m_host.AddScriptLPS(1); + NotImplemented("llScriptProfiler"); + + } + + public void llSetSoundQueueing(int queue) + { + m_host.AddScriptLPS(1); + NotImplemented("llSetSoundQueueing"); + } + + public void llCollisionSprite(string impact_sprite) + { + m_host.AddScriptLPS(1); + NotImplemented("llCollisionSprite"); + } + + public void llGodLikeRezObject(string inventory, LSL_Vector pos) + { + m_host.AddScriptLPS(1); + NotImplemented("llGodLikeRezObject"); + } + + #endregion } public class NotecardCache -- cgit v1.1 From 24c00acedc1575bf11fb5801bebdc5d45a93c277 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 23 May 2011 02:52:28 +0100 Subject: Fix Mantis #4429: Allow llGiveInventory to work across sim borders. --- .../Shared/Api/Implementation/LSL_Api.cs | 32 ++++++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index e3d0dac..ce7d97c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3864,9 +3864,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); } - // check if destination is an avatar - if (World.GetScenePresence(destId) != null) + // check if destination is an object + if (World.GetSceneObjectPart(destId) != null) { + // destination is an object + World.MoveTaskInventoryItem(destId, m_host, objId); + } + else + { + ScenePresence presence = World.GetScenePresence(destId); + + if (presence == null) + { + UserAccount account = + World.UserAccountService.GetUserAccount( + World.RegionInfo.ScopeID, + destId); + + if (account == null) + { + llSay(0, "Can't find destination "+destId.ToString()); + return; + } + } // destination is an avatar InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); @@ -3887,16 +3907,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AbsolutePosition.ToString(), agentItem.ID, true, m_host.AbsolutePosition, bucket); - if (m_TransferModule != null) m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); + ScriptSleep(3000); } - else - { - // destination is an object - World.MoveTaskInventoryItem(destId, m_host, objId); - } - ScriptSleep(3000); } public void llRemoveInventory(string name) -- cgit v1.1 From 178d541dcaa2d8258e3820b39818d8fd69def72e Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 24 May 2011 00:53:28 +0200 Subject: Add an event for an orderly region shutdown that fires once per region before the SceneGraph is torn down. --- OpenSim/Region/Framework/Scenes/EventManager.cs | 25 +++++++++++++++++++++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 2 ++ 2 files changed, 27 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index fd62535..e04317b 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -111,6 +111,10 @@ namespace OpenSim.Region.Framework.Scenes public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest; + public delegate void SceneShuttingDownDelegate(Scene scene); + + public event SceneShuttingDownDelegate OnSceneShuttingDown; + /// /// Fired when an object is touched/grabbed. /// @@ -2193,5 +2197,26 @@ namespace OpenSim.Region.Framework.Scenes } } } + + public void TriggerSceneShuttingDown(Scene s) + { + SceneShuttingDownDelegate handler = OnSceneShuttingDown; + if (handler != null) + { + foreach (SceneShuttingDownDelegate d in handler.GetInvocationList()) + { + try + { + d(s); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[EVENT MANAGER]: Delegate for TriggerSceneShuttingDown failed - continuing. {0} {1}", + e.Message, e.StackTrace); + } + } + } + } } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index b9690fe..eabc9a6 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1064,6 +1064,8 @@ namespace OpenSim.Region.Framework.Scenes shuttingdown = true; m_log.Debug("[SCENE]: Persisting changed objects"); + EventManager.TriggerSceneShuttingDown(this); + EntityBase[] entities = GetEntities(); foreach (EntityBase entity in entities) { -- cgit v1.1 From 61d4291da56e18c7777adebbcfce2c092a2d9a69 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 24 May 2011 03:17:12 +0100 Subject: Create a method to force the script engine to save state from outside --- OpenSim/Region/Framework/Interfaces/IScriptModule.cs | 2 ++ OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs index fecdd1b..d9752e6 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs @@ -50,5 +50,7 @@ namespace OpenSim.Region.Framework.Interfaces void ResumeScript(UUID itemID); ArrayList GetScriptErrors(UUID itemID); + + void SaveAllState(); } } diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 97ab411..d253c6a 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -393,11 +393,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine return 0; } - public object DoMaintenance(object p) + public void SaveAllState() { - object[] parms = (object[])p; - int sleepTime = (int)parms[0]; - foreach (IScriptInstance inst in m_Scripts.Values) { if (inst.EventTime() > m_EventLimit) @@ -407,6 +404,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine inst.Start(); } } + } + + public object DoMaintenance(object p) + { + object[] parms = (object[])p; + int sleepTime = (int)parms[0]; + + SaveAllState(); System.Threading.Thread.Sleep(sleepTime); -- cgit v1.1 From 28c25d8477ff3cfd5751da1454fcd4cc33815a5e Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 24 May 2011 03:37:25 +0200 Subject: Allow disabling the legacy backup mechanism to avoid the object clone if backup is not used. --- OpenSim/Region/Framework/Scenes/Scene.cs | 9 +++++++++ OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index eabc9a6..4aae13c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -204,6 +204,7 @@ namespace OpenSim.Region.Framework.Scenes private Timer m_mapGenerationTimer = new Timer(); private bool m_generateMaptiles; + private bool m_useBackup = true; // private Dictionary m_UserNamesCache = new Dictionary(); @@ -459,6 +460,11 @@ namespace OpenSim.Region.Framework.Scenes get { return m_sceneGraph; } } + public bool UseBackup + { + get { return m_useBackup; } + } + // an instance to the physics plugin's Scene object. public PhysicsScene PhysicsScene { @@ -647,6 +653,9 @@ namespace OpenSim.Region.Framework.Scenes IConfig startupConfig = m_config.Configs["Startup"]; m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); + m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); + if (!m_useBackup) + m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); //Animation states m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 19a9506..9b9374b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1335,7 +1335,7 @@ namespace OpenSim.Region.Framework.Scenes } } - if (HasGroupChanged) + if (m_scene.UseBackup && HasGroupChanged) { // don't backup while it's selected or you're asking for changes mid stream. if (isTimeToPersist() || forcedBackup) -- cgit v1.1 From a8913141c081202eb1f988901a4ac0988bbd72a2 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Tue, 24 May 2011 16:03:01 -0400 Subject: Make client event handlers for money only work on root agents --- .../World/MoneyModule/SampleMoneyModule.cs | 36 ++++++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs index b84a34d..952e797 100644 --- a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs +++ b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs @@ -177,9 +177,37 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule scene.EventManager.OnClientClosed += ClientLoggedOut; scene.EventManager.OnValidateLandBuy += ValidateLandBuy; scene.EventManager.OnLandBuy += processLandBuy; + scene.EventManager.OnMakeRootAgent += OnMakeRootAgent; } } + void OnMakeRootAgent(ScenePresence presence) + { + // Do this only for root agents + // Some implementations register $$ for + // child agents, then that never goes away + // We will send a zero balance when they are + // made root. + // + // Modules overriding this should only deal with + // root agents as well. + // + IClientAPI client = presence.ControllingClient; + + client.OnEconomyDataRequest += EconomyDataRequestHandler; + client.OnMoneyBalanceRequest += SendMoneyBalance; + client.OnRequestPayPrice += requestPayPrice; + client.OnObjectBuy += ObjectBuy; + client.OnLogout += ClientClosed; + + client.SendMoneyBalance (UUID.Random(), true, new byte[0], 0); + } + + void HandleSceneEventManagerOnMakeRootAgent (ScenePresence presence) + { + + } + public void RemoveRegion(Scene scene) { } @@ -277,13 +305,9 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule private void OnNewClient(IClientAPI client) { GetClientFunds(client); + // Moved the event registrations to fire them when + // the agent becomes root - // Subscribe to Money messages - client.OnEconomyDataRequest += EconomyDataRequestHandler; - client.OnMoneyBalanceRequest += SendMoneyBalance; - client.OnRequestPayPrice += requestPayPrice; - client.OnObjectBuy += ObjectBuy; - client.OnLogout += ClientClosed; } /// -- cgit v1.1 From ef3f6b4e63a49430bebbc929cb61d018a0a0d37c Mon Sep 17 00:00:00 2001 From: BlueWall Date: Tue, 24 May 2011 16:33:51 -0400 Subject: Revert "Make client event handlers for money only work on root agents" This reverts commit a8913141c081202eb1f988901a4ac0988bbd72a2. Pulling this back until some testing under various money modules can be done. Need to be able to make purchases as a child agent. --- .../World/MoneyModule/SampleMoneyModule.cs | 36 ++++------------------ 1 file changed, 6 insertions(+), 30 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs index 952e797..b84a34d 100644 --- a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs +++ b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs @@ -177,37 +177,9 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule scene.EventManager.OnClientClosed += ClientLoggedOut; scene.EventManager.OnValidateLandBuy += ValidateLandBuy; scene.EventManager.OnLandBuy += processLandBuy; - scene.EventManager.OnMakeRootAgent += OnMakeRootAgent; } } - void OnMakeRootAgent(ScenePresence presence) - { - // Do this only for root agents - // Some implementations register $$ for - // child agents, then that never goes away - // We will send a zero balance when they are - // made root. - // - // Modules overriding this should only deal with - // root agents as well. - // - IClientAPI client = presence.ControllingClient; - - client.OnEconomyDataRequest += EconomyDataRequestHandler; - client.OnMoneyBalanceRequest += SendMoneyBalance; - client.OnRequestPayPrice += requestPayPrice; - client.OnObjectBuy += ObjectBuy; - client.OnLogout += ClientClosed; - - client.SendMoneyBalance (UUID.Random(), true, new byte[0], 0); - } - - void HandleSceneEventManagerOnMakeRootAgent (ScenePresence presence) - { - - } - public void RemoveRegion(Scene scene) { } @@ -305,9 +277,13 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule private void OnNewClient(IClientAPI client) { GetClientFunds(client); - // Moved the event registrations to fire them when - // the agent becomes root + // Subscribe to Money messages + client.OnEconomyDataRequest += EconomyDataRequestHandler; + client.OnMoneyBalanceRequest += SendMoneyBalance; + client.OnRequestPayPrice += requestPayPrice; + client.OnObjectBuy += ObjectBuy; + client.OnLogout += ClientClosed; } /// -- cgit v1.1 From e398c33648dabca1b7243214e3faa1e36f8cf024 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 25 May 2011 12:17:46 +0100 Subject: Add PayPrice to serialization format Xml2 --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 9 +++--- .../Scenes/Serialization/SceneObjectSerializer.cs | 37 +++++++++++++++++++++- 2 files changed, 40 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 8a8a699..331abb2 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -144,11 +144,10 @@ namespace OpenSim.Region.Framework.Scenes public Vector3 StatusSandboxPos; - // TODO: This needs to be persisted in next XML version update! - - public readonly int[] PayPrice = {-2,-2,-2,-2,-2}; - - + [XmlIgnore] + public int[] PayPrice = {-2,-2,-2,-2,-2}; + + [XmlIgnore] public PhysicsActor PhysActor { get { return m_physActor; } diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index bb8a83a..872816c 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -341,6 +341,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization m_SOPXmlProcessors.Add("MediaUrl", ProcessMediaUrl); m_SOPXmlProcessors.Add("TextureAnimation", ProcessTextureAnimation); m_SOPXmlProcessors.Add("ParticleSystem", ProcessParticleSystem); + m_SOPXmlProcessors.Add("PayPrice0", ProcessPayPrice0); + m_SOPXmlProcessors.Add("PayPrice1", ProcessPayPrice1); + m_SOPXmlProcessors.Add("PayPrice2", ProcessPayPrice2); + m_SOPXmlProcessors.Add("PayPrice3", ProcessPayPrice3); + m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4); #endregion #region TaskInventoryXmlProcessors initialization @@ -698,6 +703,32 @@ namespace OpenSim.Region.Framework.Scenes.Serialization { obj.ParticleSystem = Convert.FromBase64String(reader.ReadElementContentAsString("ParticleSystem", String.Empty)); } + + private static void ProcessPayPrice0(SceneObjectPart obj, XmlTextReader reader) + { + obj.PayPrice[0] = (int)reader.ReadElementContentAsInt("PayPrice0", String.Empty); + } + + private static void ProcessPayPrice1(SceneObjectPart obj, XmlTextReader reader) + { + obj.PayPrice[1] = (int)reader.ReadElementContentAsInt("PayPrice1", String.Empty); + } + + private static void ProcessPayPrice2(SceneObjectPart obj, XmlTextReader reader) + { + obj.PayPrice[2] = (int)reader.ReadElementContentAsInt("PayPrice2", String.Empty); + } + + private static void ProcessPayPrice3(SceneObjectPart obj, XmlTextReader reader) + { + obj.PayPrice[3] = (int)reader.ReadElementContentAsInt("PayPrice3", String.Empty); + } + + private static void ProcessPayPrice4(SceneObjectPart obj, XmlTextReader reader) + { + obj.PayPrice[4] = (int)reader.ReadElementContentAsInt("PayPrice4", String.Empty); + } + #endregion #region TaskInventoryXmlProcessors @@ -1069,7 +1100,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization shp.Media = PrimitiveBaseShape.MediaList.FromXml(value); } - #endregion ////////// Write ///////// @@ -1175,6 +1205,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("MediaUrl", sop.MediaUrl.ToString()); WriteBytes(writer, "TextureAnimation", sop.TextureAnimation); WriteBytes(writer, "ParticleSystem", sop.ParticleSystem); + writer.WriteElementString("PayPrice0", sop.PayPrice[0].ToString()); + writer.WriteElementString("PayPrice1", sop.PayPrice[1].ToString()); + writer.WriteElementString("PayPrice2", sop.PayPrice[2].ToString()); + writer.WriteElementString("PayPrice3", sop.PayPrice[3].ToString()); + writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString()); writer.WriteEndElement(); } -- cgit v1.1 From 6f4d079fc5b28ef6657fe2baf6ef305a54e674d2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 26 May 2011 01:27:01 +0100 Subject: Add a --noassets option to "save oar". This switch stops any assets being saved in the oar. This can be useful if you're using OAR to backup regions and you know you'll always have the original asset database available. --- OpenSim/Region/Application/OpenSim.cs | 9 ++- .../Archiver/ArchiveWriteRequestPreparation.cs | 81 +++++++++++-------- .../CoreModules/World/Archiver/ArchiverModule.cs | 8 +- .../World/Archiver/Tests/ArchiverTests.cs | 91 +++++++++++++++++++++- .../Framework/Interfaces/IRegionArchiverModule.cs | 25 ++++-- 5 files changed, 167 insertions(+), 47 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 39004d4..8add2af 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -267,12 +267,13 @@ namespace OpenSim m_console.Commands.AddCommand("region", false, "save oar", //"save oar [-v|--version=] [-p|--profile=] []", - "save oar [-p|--profile=] []", + "save oar [-p|--profile=] [--noassets] []", "Save a region's data to an OAR archive.", // "-v|--version= generates scene objects as per older versions of the serialization (e.g. -v=0)" + Environment.NewLine - "-p|--profile= adds the url of the profile service to the saved user information" + Environment.NewLine - + "The OAR path must be a filesystem path." - + " If this is not given then the oar is saved to region.oar in the current directory.", + "-p|--profile= adds the url of the profile service to the saved user information." + Environment.NewLine + + " The OAR path must be a filesystem path." + + " If this is not given then the oar is saved to region.oar in the current directory." + Environment.NewLine + + "--noassets stops assets being saved to the OAR.", SaveOar); m_console.Commands.AddCommand("region", false, "edit scale", diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs index 597b780..6a86dfe 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs @@ -58,7 +58,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// /// The maximum major version of OAR that we can write. /// - public static int MAX_MAJOR_VERSION = 0; + public static int MAX_MAJOR_VERSION = 0; + + /// + /// Determine whether this oar will save assets. Default is true. + /// + public bool SaveAssets { get; set; } protected Scene m_scene; protected Stream m_saveStream; @@ -73,10 +78,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// /// If there was a problem opening a stream for the file specified by the savePath /// - public ArchiveWriteRequestPreparation(Scene scene, string savePath, Guid requestId) + public ArchiveWriteRequestPreparation(Scene scene, string savePath, Guid requestId) : this(scene, requestId) { - m_scene = scene; - try { m_saveStream = new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress); @@ -86,10 +89,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_log.ErrorFormat( "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); - m_log.Error(e); + m_log.ErrorFormat("{0} {1}", e.Message, e.StackTrace); } - - m_requestId = requestId; } /// @@ -98,11 +99,17 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// /// The stream to which to save data. /// The id associated with this request - public ArchiveWriteRequestPreparation(Scene scene, Stream saveStream, Guid requestId) + public ArchiveWriteRequestPreparation(Scene scene, Stream saveStream, Guid requestId) : this(scene, requestId) { - m_scene = scene; m_saveStream = saveStream; + } + + protected ArchiveWriteRequestPreparation(Scene scene, Guid requestId) + { + m_scene = scene; m_requestId = requestId; + + SaveAssets = true; } /// @@ -111,22 +118,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// if there was an io problem with creating the file public void ArchiveRegion(Dictionary options) { + if (options.ContainsKey("noassets") && (bool)options["noassets"]) + SaveAssets = false; + try { Dictionary assetUuids = new Dictionary(); EntityBase[] entities = m_scene.GetEntities(); List sceneObjects = new List(); - - /* - foreach (ILandObject lo in m_scene.LandChannel.AllParcels()) - { - if (name == lo.LandData.Name) - { - // This is the parcel we want - } - } - */ // Filter entities so that we only have scene objects. // FIXME: Would be nicer to have this as a proper list in SceneGraph, since lots of methods @@ -141,17 +141,24 @@ namespace OpenSim.Region.CoreModules.World.Archiver sceneObjects.Add((SceneObjectGroup)entity); } } - - UuidGatherer assetGatherer = new UuidGatherer(m_scene.AssetService); - - foreach (SceneObjectGroup sceneObject in sceneObjects) + + if (SaveAssets) { - assetGatherer.GatherAssetUuids(sceneObject, assetUuids); + UuidGatherer assetGatherer = new UuidGatherer(m_scene.AssetService); + + foreach (SceneObjectGroup sceneObject in sceneObjects) + { + assetGatherer.GatherAssetUuids(sceneObject, assetUuids); + } + + m_log.DebugFormat( + "[ARCHIVER]: {0} scene objects to serialize requiring save of {1} assets", + sceneObjects.Count, assetUuids.Count); + } + else + { + m_log.DebugFormat("[ARCHIVER]: Not saving assets since --noassets was specified"); } - - m_log.DebugFormat( - "[ARCHIVER]: {0} scene objects to serialize requiring save of {1} assets", - sceneObjects.Count, assetUuids.Count); // Make sure that we also request terrain texture assets RegionSettings regionSettings = m_scene.RegionInfo.RegionSettings; @@ -187,11 +194,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver // XXX: I know this is a weak way of doing it since external non-OAR aware tar executables will not do this archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, CreateControlFile(options)); m_log.InfoFormat("[ARCHIVER]: Added control file to archive."); - - new AssetsRequest( - new AssetsArchiver(archiveWriter), assetUuids, - m_scene.AssetService, m_scene.UserAccountService, - m_scene.RegionInfo.ScopeID, options, awre.ReceivedAllAssets).Execute(); + + if (SaveAssets) + new AssetsRequest( + new AssetsArchiver(archiveWriter), assetUuids, + m_scene.AssetService, m_scene.UserAccountService, + m_scene.RegionInfo.ScopeID, options, awre.ReceivedAllAssets).Execute(); + else + awre.ReceivedAllAssets(new List(), new List()); } catch (Exception) { @@ -204,7 +214,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// Create the control file for the most up to date archive /// /// - public static string CreateControlFile(Dictionary options) + public string CreateControlFile(Dictionary options) { int majorVersion = MAX_MAJOR_VERSION, minorVersion = 6; // @@ -258,6 +268,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver xtw.WriteElementString("datetime", ((int)t.TotalSeconds).ToString()); xtw.WriteElementString("id", UUID.Random().ToString()); xtw.WriteEndElement(); + + xtw.WriteElementString("assets_included", SaveAssets.ToString()); + xtw.WriteEndElement(); xtw.Flush(); diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs index 9277c59..08eb80c 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs @@ -127,6 +127,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver OptionSet ops = new OptionSet(); // ops.Add("v|version=", delegate(string v) { options["version"] = v; }); ops.Add("p|profile=", delegate(string v) { options["profile"] = v; }); + ops.Add("noassets", delegate(string v) { options["noassets"] = v != null; }); List mainParams = ops.Parse(cmdparams); @@ -160,7 +161,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver public void ArchiveRegion(Stream saveStream, Guid requestId) { - new ArchiveWriteRequestPreparation(m_scene, saveStream, requestId).ArchiveRegion(new Dictionary()); + ArchiveRegion(saveStream, requestId, new Dictionary()); + } + + public void ArchiveRegion(Stream saveStream, Guid requestId, Dictionary options) + { + new ArchiveWriteRequestPreparation(m_scene, saveStream, requestId).ArchiveRegion(options); } public void DearchiveRegion(string loadPath) diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index 2eb2861..34e2e23 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs @@ -212,6 +212,89 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests } /// + /// Test saving an OpenSim Region Archive with the no assets option + /// + [Test] + public void TestSaveOarNoAssets() + { + TestHelper.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + SceneObjectPart part1 = CreateSceneObjectPart1(); + SceneObjectGroup sog1 = new SceneObjectGroup(part1); + m_scene.AddNewSceneObject(sog1, false); + + SceneObjectPart part2 = CreateSceneObjectPart2(); + + AssetNotecard nc = new AssetNotecard(); + nc.BodyText = "Hello World!"; + nc.Encode(); + UUID ncAssetUuid = new UUID("00000000-0000-0000-1000-000000000000"); + UUID ncItemUuid = new UUID("00000000-0000-0000-1100-000000000000"); + AssetBase ncAsset + = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero); + m_scene.AssetService.Store(ncAsset); + SceneObjectGroup sog2 = new SceneObjectGroup(part2); + TaskInventoryItem ncItem + = new TaskInventoryItem { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid }; + part2.Inventory.AddInventoryItem(ncItem, true); + + m_scene.AddNewSceneObject(sog2, false); + + MemoryStream archiveWriteStream = new MemoryStream(); + + Guid requestId = new Guid("00000000-0000-0000-0000-808080808080"); + + Dictionary options = new Dictionary(); + options.Add("noassets", true); + m_archiverModule.ArchiveRegion(archiveWriteStream, requestId, options); + //AssetServerBase assetServer = (AssetServerBase)scene.CommsManager.AssetCache.AssetServer; + //while (assetServer.HasWaitingRequests()) + // assetServer.ProcessNextRequest(); + + // Don't wait for completion - with --noassets save oar happens synchronously +// Monitor.Wait(this, 60000); + + Assert.That(m_lastRequestId, Is.EqualTo(requestId)); + + byte[] archive = archiveWriteStream.ToArray(); + MemoryStream archiveReadStream = new MemoryStream(archive); + TarArchiveReader tar = new TarArchiveReader(archiveReadStream); + + List foundPaths = new List(); + List expectedPaths = new List(); + expectedPaths.Add(ArchiveHelpers.CreateObjectPath(sog1)); + expectedPaths.Add(ArchiveHelpers.CreateObjectPath(sog2)); + + string filePath; + TarArchiveReader.TarEntryType tarEntryType; + + byte[] data = tar.ReadEntry(out filePath, out tarEntryType); + Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH)); + + ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, false, false, Guid.Empty); + arr.LoadControlFile(filePath, data); + + Assert.That(arr.ControlFileLoaded, Is.True); + + while (tar.ReadEntry(out filePath, out tarEntryType) != null) + { + if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) + { + Assert.Fail("Asset was found in saved oar of TestSaveOarNoAssets()"); + } + else if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH)) + { + foundPaths.Add(filePath); + } + } + + Assert.That(foundPaths, Is.EquivalentTo(expectedPaths)); + + // TODO: Test presence of more files and contents of files. + } + + /// /// Test loading an OpenSim Region Archive. /// [Test] @@ -230,7 +313,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests // upset load tar.WriteDir(ArchiveConstants.TERRAINS_PATH); - tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.CreateControlFile(new Dictionary())); + tar.WriteFile( + ArchiveConstants.CONTROL_FILE_PATH, + new ArchiveWriteRequestPreparation(null, (Stream)null, Guid.Empty).CreateControlFile(new Dictionary())); SceneObjectPart part1 = CreateSceneObjectPart1(); SceneObjectGroup object1 = new SceneObjectGroup(part1); @@ -331,7 +416,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); tar.WriteDir(ArchiveConstants.TERRAINS_PATH); - tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.CreateControlFile(new Dictionary())); + tar.WriteFile( + ArchiveConstants.CONTROL_FILE_PATH, + new ArchiveWriteRequestPreparation(null, (Stream)null, Guid.Empty).CreateControlFile(new Dictionary())); RegionSettings rs = new RegionSettings(); rs.AgentLimit = 17; diff --git a/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs index d8229de..3fafc47 100644 --- a/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs @@ -52,31 +52,44 @@ namespace OpenSim.Region.Framework.Interfaces /// /// Archive the region to the given path /// - /// + /// /// This method occurs asynchronously. If you want notification of when it has completed then subscribe to /// the EventManager.OnOarFileSaved event. - /// + /// /// /// If supplied, this request Id is later returned in the saved event + /// Options for the save void ArchiveRegion(string savePath, Guid requestId, Dictionary options); /// /// Archive the region to a stream. /// - /// + /// /// This method occurs asynchronously. If you want notification of when it has completed then subscribe to /// the EventManager.OnOarFileSaved event. - /// + /// /// /// If supplied, this request Id is later returned in the saved event void ArchiveRegion(Stream saveStream, Guid requestId); /// + /// Archive the region to a stream. + /// + /// + /// This method occurs asynchronously. If you want notification of when it has completed then subscribe to + /// the EventManager.OnOarFileSaved event. + /// + /// + /// If supplied, this request Id is later returned in the saved event + /// Options for the save + void ArchiveRegion(Stream saveStream, Guid requestId, Dictionary options); + + /// /// Dearchive the given region archive. This replaces the existing scene. /// - /// + /// /// If you want notification of when it has completed then subscribe to the EventManager.OnOarFileLoaded event. - /// + /// /// void DearchiveRegion(string loadPath); -- cgit v1.1 From c7e46e8a51de7d137182956f1ec033250edc0da5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 26 May 2011 01:37:15 +0100 Subject: Bump OAR file format version up to 0.7 for this development cycle. This adds a true|false element to the oar control file, though this is not used on reloading at this time. This addition is backward compatible with previous opensim releases --- .../CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs index 6a86dfe..3d073bf 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs @@ -49,7 +49,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver public class ArchiveWriteRequestPreparation { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - + /// /// The minimum major version of OAR that we can write. /// @@ -216,7 +216,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// public string CreateControlFile(Dictionary options) { - int majorVersion = MAX_MAJOR_VERSION, minorVersion = 6; + int majorVersion = MAX_MAJOR_VERSION, minorVersion = 7; // // if (options.ContainsKey("version")) // { -- cgit v1.1 From 3270f4353e0a2bded9361a72526ba673e6266cc1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 26 May 2011 02:22:52 +0100 Subject: Add --noassets option for "save iar" Like "save oar", this saves an iar without assets This can be useful for backup when you know the required assets will still be present (e.g. you're backing up the assets db separately). This also bumps the iar format version to 0.3 and 1.2 respectively. 0.3 is backward compatible with previous opensim versions 1.2 is used if the --profile switch is specified. It is only compatible with 0.7.1 presently. --- .../Archiver/InventoryArchiveWriteRequest.cs | 45 +++++++-- .../Inventory/Archiver/InventoryArchiverModule.cs | 14 +-- .../Archiver/Tests/InventoryArchiverTests.cs | 104 ++++++++++++++++++++- .../Archiver/ArchiveWriteRequestPreparation.cs | 2 +- 4 files changed, 146 insertions(+), 19 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index c039b5a..b5272ad 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -46,6 +46,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + /// + /// Determine whether this archive will save assets. Default is true. + /// + public bool SaveAssets { get; set; } + /// /// Used to select all inventory nodes in a folder but not the folder itself /// @@ -112,6 +117,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_invPath = invPath; m_saveStream = saveStream; m_assetGatherer = new UuidGatherer(m_scene.AssetService); + + SaveAssets = true; } protected void ReceivedAllAssets(ICollection assetsFoundUuids, ICollection assetsNotFoundUuids) @@ -150,7 +157,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver string serialization = UserInventoryItemSerializer.Serialize(inventoryItem, options, userAccountService); m_archiveWriter.WriteFile(filename, serialization); - m_assetGatherer.GatherAssetUuids(inventoryItem.AssetID, (AssetType)inventoryItem.AssetType, m_assetUuids); + if (SaveAssets) + m_assetGatherer.GatherAssetUuids(inventoryItem.AssetID, (AssetType)inventoryItem.AssetType, m_assetUuids); } /// @@ -195,6 +203,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// public void Execute(Dictionary options, IUserAccountService userAccountService) { + if (options.ContainsKey("noassets") && (bool)options["noassets"]) + SaveAssets = false; + try { InventoryFolderBase inventoryFolder = null; @@ -285,12 +296,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // Don't put all this profile information into the archive right now. //SaveUsers(); - - new AssetsRequest( - new AssetsArchiver(m_archiveWriter), - m_assetUuids, m_scene.AssetService, - m_scene.UserAccountService, m_scene.RegionInfo.ScopeID, - options, ReceivedAllAssets).Execute(); + + if (SaveAssets) + { + m_log.DebugFormat("[INVENTORY ARCHIVER]: Saving {0} assets for items", m_assetUuids.Count); + + new AssetsRequest( + new AssetsArchiver(m_archiveWriter), + m_assetUuids, m_scene.AssetService, + m_scene.UserAccountService, m_scene.RegionInfo.ScopeID, + options, ReceivedAllAssets).Execute(); + } + else + { + m_log.DebugFormat("[INVENTORY ARCHIVER]: Not saving assets since --noassets was specified"); + + ReceivedAllAssets(new List(), new List()); + } } catch (Exception) { @@ -387,19 +409,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// /// /// - public static string CreateControlFile(Dictionary options) + public string CreateControlFile(Dictionary options) { int majorVersion, minorVersion; if (options.ContainsKey("profile")) { majorVersion = 1; - minorVersion = 1; + minorVersion = 2; } else { majorVersion = 0; - minorVersion = 2; + minorVersion = 3; } m_log.InfoFormat("[INVENTORY ARCHIVER]: Creating version {0}.{1} IAR", majorVersion, minorVersion); @@ -411,6 +433,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver xtw.WriteStartElement("archive"); xtw.WriteAttributeString("major_version", majorVersion.ToString()); xtw.WriteAttributeString("minor_version", minorVersion.ToString()); + + xtw.WriteElementString("assets_included", SaveAssets.ToString()); + xtw.WriteEndElement(); xtw.Flush(); diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 576a154..e0b02aa 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -122,7 +122,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver scene.AddCommand( this, "save iar", - "save iar [--p|-profile=] [] [--v|-verbose]", + "save iar [--p|-profile=] [--noassets] [] [--v|-verbose]", "Save user inventory archive (IAR).", " is the user's first name." + Environment.NewLine + " is the user's last name." + Environment.NewLine @@ -130,6 +130,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver + "-p|--profile= adds the url of the profile service to the saved user information." + Environment.NewLine + "-c|--creators preserves information about foreign creators." + Environment.NewLine + "-v|--verbose extra debug messages." + Environment.NewLine + + "--noassets stops assets being saved to the IAR." + " 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); @@ -398,6 +399,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver ops.Add("p|profile=", delegate(string v) { options["profile"] = v; }); ops.Add("v|verbose", delegate(string v) { options["verbose"] = v; }); ops.Add("c|creators", delegate(string v) { options["creators"] = v; }); + ops.Add("noassets", delegate(string v) { options["noassets"] = v != null; }); List mainParams = ops.Parse(cmdparams); @@ -406,7 +408,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver if (mainParams.Count < 6) { m_log.Error( - "[INVENTORY ARCHIVER]: usage is save iar [--p|-profile=] []"); + "[INVENTORY ARCHIVER]: usage is save iar [--p|-profile=] [--noassets] []"); return; } @@ -423,16 +425,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_log.InfoFormat( "[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}", savePath, invPath, firstName, lastName); - + + lock (m_pendingConsoleSaves) + m_pendingConsoleSaves.Add(id); + ArchiveInventory(id, firstName, lastName, invPath, pass, savePath, options); } catch (InventoryArchiverException e) { m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", e.Message); } - - lock (m_pendingConsoleSaves) - m_pendingConsoleSaves.Add(id); } private void SaveInvConsoleCommandCompleted( diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index d97311a..ae3ab21 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -123,11 +123,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests } /// - /// Test saving a single inventory item to a V0.1 OpenSim Inventory Archive + /// Test saving a single inventory item to an IAR /// (subject to change since there is no fixed format yet). /// [Test] - public void TestSaveItemToIarV0_1() + public void TestSaveItemToIar() { TestHelper.InMethod(); // log4net.Config.XmlConfigurator.Configure(); @@ -217,6 +217,106 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests // TODO: Test presence of more files and contents of files. } + + /// + /// Test saving a single inventory item to an IAR without its asset + /// + [Test] + public void TestSaveItemToIarNoAssets() + { + TestHelper.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + // Create user + string userFirstName = "Jock"; + string userLastName = "Stirrup"; + string userPassword = "troll"; + UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); + UserAccountHelpers.CreateUserWithInventory(m_scene, userFirstName, userLastName, userId, userPassword); + + // Create asset + UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); + SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, ownerId, "My Little Dog Object", 0x50); + + UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); + AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); + m_scene.AssetService.Store(asset1); + + // Create item + UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); + string item1Name = "My Little Dog"; + InventoryItemBase item1 = new InventoryItemBase(); + item1.Name = item1Name; + item1.AssetID = asset1.FullID; + item1.ID = item1Id; + InventoryFolderBase objsFolder + = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, userId, "Objects")[0]; + item1.Folder = objsFolder.ID; + m_scene.AddInventoryItem(item1); + + MemoryStream archiveWriteStream = new MemoryStream(); + + Dictionary options = new Dictionary(); + options.Add("noassets", true); + + // When we're not saving assets, archiving is being done synchronously. + m_archiverModule.ArchiveInventory( + Guid.NewGuid(), userFirstName, userLastName, "Objects/" + item1Name, userPassword, archiveWriteStream, options); + + 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}", + ArchiveConstants.INVENTORY_PATH, + expectedObject1FileName); + + string filePath; + TarArchiveReader.TarEntryType tarEntryType; + +// Console.WriteLine("Reading archive"); + + 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")) + { +// 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; +// } + } + else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) + { + Assert.Fail("Found asset path in TestSaveItemToIarNoAssets()"); + } + } + +// 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. + } /// /// Test case where a creator account exists for the creator UUID embedded in item metadata and serialized diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs index 3d073bf..10a83ee 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs @@ -61,7 +61,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver public static int MAX_MAJOR_VERSION = 0; /// - /// Determine whether this oar will save assets. Default is true. + /// Determine whether this archive will save assets. Default is true. /// public bool SaveAssets { get; set; } -- cgit v1.1 From 91ec1a572ab82b67a3e3090bb9d90009c294ef99 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 26 May 2011 02:48:47 +0100 Subject: improve help information for "appearance show" at the moment, this just performs a baked avatar check for everybody in the region. If the check returns 'corrupt' then a baked texture is missing and other avatars will continue to see the gas ball. --- .../Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs index 8589901..7304145 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs @@ -95,8 +95,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance scene.AddCommand( this, "appearance show", "appearance show", - "Show appearance information for each avatar in the simulator. At the moment, ", - ShowAppearanceInfo); + "Show appearance information for each avatar in the simulator.", + "At the moment this actually just checks that we have all the required baked textures. If not, then appearance is 'corrupt' and other avatars will continue to see a cloud.", + ShowAppearanceInfo); } protected void ShowAppearanceInfo(string module, string[] cmd) -- cgit v1.1