From 304c78bbbbc9a176d70d2967a3f703f2e545565c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sun, 6 Sep 2009 19:30:03 +0100 Subject: Temporarily re-enable save iar test by manually insert the item into the old cache during the test --- .../Inventory/Archiver/InventoryArchiveWriteRequest.cs | 7 +++++++ .../Inventory/Archiver/Tests/InventoryArchiverTests.cs | 15 ++++++++++----- 2 files changed, 17 insertions(+), 5 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 18728c6..6653516 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -207,6 +207,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver InventoryFolderImpl inventoryFolder = null; InventoryItemBase inventoryItem = null; + // XXX: Very temporarily, drop and refetch inventory to make sure we have any newly created items in cache + // This will disappear very soon once we stop using the old cached inventory. + /* + m_userInfo.DropInventory(); + m_userInfo.FetchInventory(); + */ + if (!m_userInfo.HasReceivedInventory) { // If the region server has access to the user admin service (by which users are created), diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index a151c9d..2ad6f1a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -77,7 +77,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests /// // Commenting for now! The mock inventory service needs more beef, at least for // GetFolderForType - //[Test] + [Test] public void TestSaveIarV0_1() { TestHelper.InMethod(); @@ -93,11 +93,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests string userFirstName = "Jock"; string userLastName = "Stirrup"; UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); - // CachedUserInfo userInfo; + CachedUserInfo userInfo; lock (this) { - UserProfileTestUtils.CreateUserWithInventory( + userInfo = UserProfileTestUtils.CreateUserWithInventory( cm, userFirstName, userLastName, userId, InventoryReceived); Monitor.Wait(this, 60000); } @@ -136,18 +136,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests item1.Name = "My Little Dog"; item1.AssetID = asset1.FullID; item1.ID = item1Id; - //userInfo.RootFolder.FindFolderByPath("Objects").ID; + InventoryFolderImpl objsFolder = userInfo.RootFolder.FindFolderByPath("Objects"); //InventoryFolderBase objsFolder = scene.InventoryService.GetFolderForType(userId, AssetType.Object); Console.WriteLine("here2"); + /* IInventoryService inventoryService = scene.InventoryService; InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId); InventoryCollection rootContents = inventoryService.GetFolderContent(userId, rootFolder.ID); + */ + /* InventoryFolderBase objsFolder = null; foreach (InventoryFolderBase folder in rootContents.Folders) if (folder.Name == "Objects") objsFolder = folder; + */ item1.Folder = objsFolder.ID; scene.AddInventoryItem(userId, item1); + userInfo.AddItem(item1); MemoryStream archiveWriteStream = new MemoryStream(); archiverModule.OnInventoryArchiveSaved += SaveCompleted; @@ -155,7 +160,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests mre.Reset(); archiverModule.ArchiveInventory( Guid.NewGuid(), userFirstName, userLastName, "Objects", archiveWriteStream); - mre.WaitOne(); + mre.WaitOne(60000, false); byte[] archive = archiveWriteStream.ToArray(); MemoryStream archiveReadStream = new MemoryStream(archive); -- cgit v1.1 From 8616230fcffbc5c8a919e4ee721be7f871d9f698 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sun, 6 Sep 2009 20:04:18 +0100 Subject: refactor: replace some uses of iar module reference with scene instead --- .../Archiver/InventoryArchiveWriteRequest.cs | 22 ++++++++++++++++------ .../Inventory/Archiver/InventoryArchiverModule.cs | 4 ++-- 2 files changed, 18 insertions(+), 8 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 6653516..da54469 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -39,6 +39,7 @@ using OpenSim.Framework.Serialization.External; using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Osp; +using OpenSim.Region.Framework.Scenes; using OpenSim.Region.CoreModules.World.Archiver; using OpenSim.Region.Framework.Scenes; @@ -60,6 +61,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver protected UuidGatherer m_assetGatherer; /// + /// We only use this to request modules + /// + protected Scene m_scene; + + /// /// ID of this request /// protected Guid m_id; @@ -83,10 +89,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// Constructor /// public InventoryArchiveWriteRequest( - Guid id, InventoryArchiverModule module, CachedUserInfo userInfo, string invPath, string savePath) + Guid id, InventoryArchiverModule module, Scene scene, + CachedUserInfo userInfo, string invPath, string savePath) : this( id, module, + scene, userInfo, invPath, new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress)) @@ -97,10 +105,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// Constructor /// public InventoryArchiveWriteRequest( - Guid id, InventoryArchiverModule module, CachedUserInfo userInfo, string invPath, Stream saveStream) + Guid id, InventoryArchiverModule module, Scene scene, + CachedUserInfo userInfo, string invPath, Stream saveStream) { m_id = id; m_module = module; + m_scene = scene; m_userInfo = userInfo; m_invPath = invPath; m_saveStream = saveStream; @@ -135,7 +145,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_userUuids[inventoryItem.CreatorIdAsUuid] = 1; InventoryItemBase saveItem = (InventoryItemBase)inventoryItem.Clone(); - saveItem.CreatorId = OspResolver.MakeOspa(saveItem.CreatorIdAsUuid, m_module.CommsManager); + saveItem.CreatorId = OspResolver.MakeOspa(saveItem.CreatorIdAsUuid, m_scene.CommsManager); string serialization = UserInventoryItemSerializer.Serialize(saveItem); m_archiveWriter.WriteFile(filename, serialization); @@ -222,7 +232,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // // FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might // use a remote inventory service, though this is vanishingly rare at the moment. - if (null == m_module.CommsManager.UserAdminService) + if (null == m_scene.CommsManager.UserAdminService) { m_log.ErrorFormat( "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1}", @@ -313,7 +323,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver SaveUsers(); new AssetsRequest( new AssetsArchiver(m_archiveWriter), m_assetUuids.Keys, - m_module.AssetService, ReceivedAllAssets).Execute(); + m_scene.AssetService, ReceivedAllAssets).Execute(); } /// @@ -327,7 +337,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { // Record the creator of this item CachedUserInfo creator - = m_module.CommsManager.UserProfileCacheService.GetUserDetails(creatorId); + = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(creatorId); if (creator != null) { diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 55d7997..36e17b4 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -126,7 +126,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver CachedUserInfo userInfo = GetUserInfo(firstName, lastName); if (userInfo != null) - new InventoryArchiveWriteRequest(id, this, userInfo, invPath, saveStream).Execute(); + new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute(); } } @@ -137,7 +137,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver CachedUserInfo userInfo = GetUserInfo(firstName, lastName); if (userInfo != null) - new InventoryArchiveWriteRequest(id, this, userInfo, invPath, savePath).Execute(); + new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute(); } } -- cgit v1.1 From 79c22651d7673b61a0c62786eb16f8b6433d6928 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sun, 6 Sep 2009 20:16:56 +0100 Subject: refactor: use direct scene reference in inventory archive read request --- .../Archiver/InventoryArchiveReadRequest.cs | 26 ++++++++++++---------- .../Archiver/InventoryArchiveWriteRequest.cs | 3 +-- .../Inventory/Archiver/InventoryArchiverModule.cs | 20 +++++------------ .../Archiver/Tests/InventoryArchiverTests.cs | 2 +- 4 files changed, 21 insertions(+), 30 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 38bd149..bb40450 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -42,6 +42,7 @@ using OpenSim.Framework.Communications.Osp; using OpenSim.Framework.Serialization; using OpenSim.Framework.Serialization.External; using OpenSim.Region.CoreModules.World.Archiver; +using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver @@ -56,31 +57,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver private string m_invPath; /// + /// We only use this to request modules + /// + protected Scene m_scene; + + /// /// The stream from which the inventory archive will be loaded. /// private Stream m_loadStream; - protected CommunicationsManager m_commsManager; - protected IAssetService m_assetService; - public InventoryArchiveReadRequest( - CachedUserInfo userInfo, string invPath, string loadPath, CommunicationsManager commsManager, IAssetService assetService) + Scene scene, CachedUserInfo userInfo, string invPath, string loadPath) : this( + scene, userInfo, invPath, - new GZipStream(new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress), - commsManager, assetService) + new GZipStream(new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress)) { } public InventoryArchiveReadRequest( - CachedUserInfo userInfo, string invPath, Stream loadStream, CommunicationsManager commsManager, IAssetService assetService) + Scene scene, CachedUserInfo userInfo, string invPath, Stream loadStream) { + m_scene = scene; m_userInfo = userInfo; m_invPath = invPath; m_loadStream = loadStream; - m_commsManager = commsManager; - m_assetService = assetService; } /// @@ -106,7 +108,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // // FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might // use a remote inventory service, though this is vanishingly rare at the moment. - if (null == m_commsManager.UserAdminService) + if (null == m_scene.CommsManager.UserAdminService) { m_log.ErrorFormat( "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1}", @@ -167,7 +169,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // Don't use the item ID that's in the file item.ID = UUID.Random(); - UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_commsManager); + UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.CommsManager); if (UUID.Zero != ospResolvedId) item.CreatorIdAsUuid = ospResolvedId; @@ -371,7 +373,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver asset.Type = assetType; asset.Data = data; - m_assetService.Store(asset); + m_scene.AssetService.Store(asset); return true; } diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index da54469..badabe0 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -39,7 +39,6 @@ using OpenSim.Framework.Serialization.External; using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Osp; -using OpenSim.Region.Framework.Scenes; using OpenSim.Region.CoreModules.World.Archiver; using OpenSim.Region.Framework.Scenes; @@ -114,7 +113,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_userInfo = userInfo; m_invPath = invPath; m_saveStream = saveStream; - m_assetGatherer = new UuidGatherer(m_module.AssetService); + m_assetGatherer = new UuidGatherer(m_scene.AssetService); } protected void ReceivedAllAssets(ICollection assetsFoundUuids, ICollection assetsNotFoundUuids) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 36e17b4..2c36270 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -69,19 +69,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// private Dictionary m_scenes = new Dictionary(); private Scene m_aScene; - - /// - /// The comms manager we will use for all comms requests - /// - protected internal CommunicationsManager CommsManager; - protected internal IAssetService AssetService; public void Initialise(Scene scene, IConfigSource source) { if (m_scenes.Count == 0) { scene.RegisterModuleInterface(this); - CommsManager = scene.CommsManager; OnInventoryArchiveSaved += SaveInvConsoleCommandCompleted; scene.AddCommand( @@ -99,11 +92,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_scenes[scene.RegionInfo.RegionID] = scene; } - - public void PostInitialise() - { - AssetService = m_aScene.AssetService; - } + + public void PostInitialise() {} public void Close() {} @@ -150,7 +140,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver if (userInfo != null) { InventoryArchiveReadRequest request = - new InventoryArchiveReadRequest(userInfo, invPath, loadStream, CommsManager, AssetService); + new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream); UpdateClientWithLoadedNodes(userInfo, request.Execute()); } } @@ -165,7 +155,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver if (userInfo != null) { InventoryArchiveReadRequest request = - new InventoryArchiveReadRequest(userInfo, invPath, loadPath, CommsManager, AssetService); + new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath); UpdateClientWithLoadedNodes(userInfo, request.Execute()); } } @@ -261,7 +251,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// protected CachedUserInfo GetUserInfo(string firstName, string lastName) { - CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); + CachedUserInfo userInfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); if (null == userInfo) { m_log.ErrorFormat( diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 2ad6f1a..cf9fcaa 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -412,7 +412,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder); - new InventoryArchiveReadRequest(userInfo, null, (Stream)null, null, null) + new InventoryArchiveReadRequest(scene, userInfo, null, (Stream)null) .ReplicateArchivePathToUserInventory( itemArchivePath, false, userInfo.RootFolder, foldersCreated, nodesLoaded); -- cgit v1.1 From 766d7756258aa1507751f2d735fcf55655b4acce Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sun, 6 Sep 2009 20:17:30 +0100 Subject: remove warning --- OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 225126d..04f7862 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -260,7 +260,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance Path.GetFileNameWithoutExtension(assembly), "SecondLife.Script"); - ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); + //ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); + RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); // lease.Register(this); } catch (Exception) -- cgit v1.1 From 881051c8ccef7b49031d0f9a087390336ecc53b5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sun, 6 Sep 2009 21:14:42 +0100 Subject: Convert iar write request to use inventory service requests rather than cache --- .../Inventory/Archiver/InventoryArchiveUtils.cs | 146 +++++++++++++++++++++ .../Archiver/InventoryArchiveWriteRequest.cs | 30 +++-- 2 files changed, 164 insertions(+), 12 deletions(-) create mode 100644 OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs new file mode 100644 index 0000000..6d598d1 --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs @@ -0,0 +1,146 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using OpenSim.Framework; +using OpenSim.Services.Interfaces; + +namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver +{ + /// + /// Utility methods for inventory archiving + /// + public static class InventoryArchiveUtils + { + public static readonly string PATH_DELIMITER = "/"; + + /// + /// Find a folder given a PATH_DELIMITER delimited path starting from this folder + /// + /// + /// This method does not handle paths that contain multiple delimitors + /// + /// FIXME: We do not yet handle situations where folders have the same name. We could handle this by some + /// XPath like expression + /// + /// FIXME: Delimitors which occur in names themselves are not currently escapable. + /// + /// + /// Inventory service to query + /// + /// + /// The folder from which the path starts + /// + /// + /// The path to the required folder. + /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned. + /// + /// null if the folder is not found + public static InventoryFolderBase FindFolderByPath( + IInventoryService inventoryService, InventoryFolderBase startFolder, string path) + { + if (path == string.Empty) + return startFolder; + + path = path.Trim(); + + if (path == PATH_DELIMITER) + return startFolder; + + InventoryFolderBase foundFolder = null; + + string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); + InventoryCollection contents = inventoryService.GetFolderContent(startFolder.Owner, startFolder.ID); + + foreach (InventoryFolderBase folder in contents.Folders) + { + if (folder.Name == components[0]) + { + if (components.Length > 1) + return FindFolderByPath(inventoryService, foundFolder, components[1]); + else + return folder; + } + } + + // We didn't find a folder with the right name + return null; + } + + /// + /// Find an item given a PATH_DELIMITOR delimited path starting from this folder. + /// + /// This method does not handle paths that contain multiple delimitors + /// + /// FIXME: We do not yet handle situations where folders or items have the same name. We could handle this by some + /// XPath like expression + /// + /// FIXME: Delimitors which occur in names themselves are not currently escapable. + /// + /// + /// + /// Inventory service to query + /// + /// + /// The folder from which the path starts + /// + /// + /// + /// The path to the required item. + /// + /// null if the item is not found + public static InventoryItemBase FindItemByPath( + IInventoryService inventoryService, InventoryFolderBase startFolder, string path) + { + string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); + + if (components.Length == 1) + { + List items = inventoryService.GetFolderItems(startFolder.Owner, startFolder.ID); + foreach (InventoryItemBase item in items) + { + if (item.Name == components[0]) + return item; + } + } + else + { + InventoryCollection contents = inventoryService.GetFolderContent(startFolder.Owner, startFolder.ID); + + foreach (InventoryFolderBase folder in contents.Folders) + { + if (folder.Name == components[0]) + return FindItemByPath(inventoryService, folder, components[1]); + } + } + + // We didn't find an item or intermediate folder with the given name + return null; + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index badabe0..dee4a5d 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -158,7 +158,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// The inventory folder to save /// The path to which the folder should be saved /// If true, save this folder itself. If false, only saves contents - protected void SaveInvFolder(InventoryFolderImpl inventoryFolder, string path, bool saveThisFolderItself) + protected void SaveInvFolder(InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself) { if (saveThisFolderItself) { @@ -173,15 +173,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_archiveWriter.WriteDir(path); } - List childFolders = inventoryFolder.RequestListOfFolderImpls(); - List items = inventoryFolder.RequestListOfItems(); + InventoryCollection contents + = m_scene.InventoryService.GetFolderContent(inventoryFolder.Owner, inventoryFolder.ID); + //List childFolders = inventoryFolder.RequestListOfFolderImpls(); + //List items = inventoryFolder.RequestListOfItems(); /* Dictionary identicalFolderNames = new Dictionary(); foreach (InventoryFolderImpl folder in inventories) { - if (!identicalFolderNames.ContainsKey(folder.Name)) identicalFolderNames[folder.Name] = 0; else @@ -197,12 +198,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } */ - foreach (InventoryFolderImpl childFolder in childFolders) + foreach (InventoryFolderBase childFolder in contents.Folders) { SaveInvFolder(childFolder, path, true); } - foreach (InventoryItemBase item in items) + foreach (InventoryItemBase item in contents.Items) { SaveInvItem(item, path); } @@ -213,8 +214,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// public void Execute() { - InventoryFolderImpl inventoryFolder = null; + InventoryFolderBase inventoryFolder = null; InventoryItemBase inventoryItem = null; + InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(m_userInfo.UserProfile.ID); // XXX: Very temporarily, drop and refetch inventory to make sure we have any newly created items in cache // This will disappear very soon once we stop using the old cached inventory. @@ -223,6 +225,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_userInfo.FetchInventory(); */ + /* if (!m_userInfo.HasReceivedInventory) { // If the region server has access to the user admin service (by which users are created), @@ -244,11 +247,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_userInfo.FetchInventory(); } } + */ bool foundStar = false; - // Eliminate double slashes and any leading / on the path. This might be better done within InventoryFolderImpl - // itself (possibly at a small loss in efficiency). + // Eliminate double slashes and any leading / on the path. string[] components = m_invPath.Split( new string[] { InventoryFolderImpl.PATH_DELIMITER }, StringSplitOptions.RemoveEmptyEntries); @@ -273,18 +276,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // Therefore if we still start with a / after the split, then we need the root folder if (m_invPath.Length == 0) { - inventoryFolder = m_userInfo.RootFolder; + inventoryFolder = rootFolder; } else { m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER)); - inventoryFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath); + 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 = m_userInfo.RootFolder.FindItemByPath(m_invPath); + inventoryItem = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, rootFolder, m_invPath); + //inventoryItem = m_userInfo.RootFolder.FindItemByPath(m_invPath); } m_archiveWriter = new TarArchiveWriter(m_saveStream); -- cgit v1.1 From 1cc0c94f792c2fe5ad3f847ef7bccbcda13c7df7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sun, 6 Sep 2009 21:15:18 +0100 Subject: remove warning --- OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs index 838cafb..917ca44 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs @@ -112,7 +112,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase if (!inits.ContainsKey(api)) return; - ILease lease = (ILease)RemotingServices.GetLifetimeService(data as MarshalByRefObject); + //ILease lease = (ILease)RemotingServices.GetLifetimeService(data as MarshalByRefObject); + RemotingServices.GetLifetimeService(data as MarshalByRefObject); // lease.Register(m_sponser); MethodInfo mi = inits[api]; -- cgit v1.1 From d8316810a1699ebe912e96f85a85c1e879540ecf Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sun, 6 Sep 2009 21:20:41 +0100 Subject: remove now unnecessary parts of save iar test --- .../Archiver/Tests/InventoryArchiverTests.cs | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index cf9fcaa..5eca4e4 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -93,11 +93,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests string userFirstName = "Jock"; string userLastName = "Stirrup"; UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); - CachedUserInfo userInfo; lock (this) { - userInfo = UserProfileTestUtils.CreateUserWithInventory( + UserProfileTestUtils.CreateUserWithInventory( cm, userFirstName, userLastName, userId, InventoryReceived); Monitor.Wait(this, 60000); } @@ -136,23 +135,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests item1.Name = "My Little Dog"; item1.AssetID = asset1.FullID; item1.ID = item1Id; - InventoryFolderImpl objsFolder = userInfo.RootFolder.FindFolderByPath("Objects"); - //InventoryFolderBase objsFolder = scene.InventoryService.GetFolderForType(userId, AssetType.Object); - Console.WriteLine("here2"); - /* - IInventoryService inventoryService = scene.InventoryService; - InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId); - InventoryCollection rootContents = inventoryService.GetFolderContent(userId, rootFolder.ID); - */ - /* - InventoryFolderBase objsFolder = null; - foreach (InventoryFolderBase folder in rootContents.Folders) - if (folder.Name == "Objects") - objsFolder = folder; - */ + InventoryFolderBase objsFolder + = InventoryArchiveUtils.FindFolderByPath( + scene.InventoryService, scene.InventoryService.GetRootFolder(userId), "Objects"); item1.Folder = objsFolder.ID; scene.AddInventoryItem(userId, item1); - userInfo.AddItem(item1); MemoryStream archiveWriteStream = new MemoryStream(); archiverModule.OnInventoryArchiveSaved += SaveCompleted; -- cgit v1.1 From a92afe8dcafd55a394c113d67a5b75bac82a6730 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sun, 6 Sep 2009 21:26:27 +0100 Subject: change load iar test to use non-cache find item by path function --- .../Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 5eca4e4..bdc2802 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -267,7 +267,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests CachedUserInfo userInfo = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); - InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName); + //InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName); + InventoryItemBase foundItem + = InventoryArchiveUtils.FindItemByPath( + scene.InventoryService, scene.InventoryService.GetRootFolder(userInfo.UserProfile.ID), itemName); Assert.That(foundItem, Is.Not.Null, "Didn't find loaded item"); Assert.That( foundItem.CreatorId, Is.EqualTo(item1.CreatorId), -- cgit v1.1 From 5640cac8e09531437e1769f884d880ee49c19f02 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sun, 6 Sep 2009 21:34:20 +0100 Subject: Add convenience functions to InventoryArchiveUtils for locating folders by assuming we're starting from the root Change test methods to use convenience functions --- .../Inventory/Archiver/InventoryArchiveUtils.cs | 66 ++++++++++++++++++++++ .../Archiver/Tests/InventoryArchiverTests.cs | 8 +-- 2 files changed, 69 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs index 6d598d1..2eeb637 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; +using OpenMetaverse; using OpenSim.Framework; using OpenSim.Services.Interfaces; @@ -38,6 +39,39 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver public static class InventoryArchiveUtils { public static readonly string PATH_DELIMITER = "/"; + + /// + /// Find a folder given a PATH_DELIMITER delimited path starting from a user's root folder + /// + /// + /// This method does not handle paths that contain multiple delimitors + /// + /// FIXME: We do not yet handle situations where folders have the same name. We could handle this by some + /// XPath like expression + /// + /// FIXME: Delimitors which occur in names themselves are not currently escapable. + /// + /// + /// Inventory service to query + /// + /// + /// User id to search + /// + /// + /// The path to the required folder. + /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned. + /// + /// null if the folder is not found + public static InventoryFolderBase FindFolderByPath( + IInventoryService inventoryService, UUID userId, string path) + { + InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId); + + if (null == rootFolder) + return null; + + return FindFolderByPath(inventoryService, rootFolder, path); + } /// /// Find a folder given a PATH_DELIMITER delimited path starting from this folder @@ -91,6 +125,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // We didn't find a folder with the right name return null; } + + /// + /// Find an item given a PATH_DELIMITOR delimited path starting from the user's root folder. + /// + /// This method does not handle paths that contain multiple delimitors + /// + /// FIXME: We do not yet handle situations where folders or items have the same name. We could handle this by some + /// XPath like expression + /// + /// FIXME: Delimitors which occur in names themselves are not currently escapable. + /// + /// + /// + /// Inventory service to query + /// + /// + /// The user to search + /// + /// + /// The path to the required item. + /// + /// null if the item is not found + public static InventoryItemBase FindItemByPath( + IInventoryService inventoryService, UUID userId, string path) + { + InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId); + + if (null == rootFolder) + return null; + + return FindItemByPath(inventoryService, rootFolder, path); + } /// /// Find an item given a PATH_DELIMITOR delimited path starting from this folder. diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index bdc2802..50fd2b0 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -136,8 +136,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests item1.AssetID = asset1.FullID; item1.ID = item1Id; InventoryFolderBase objsFolder - = InventoryArchiveUtils.FindFolderByPath( - scene.InventoryService, scene.InventoryService.GetRootFolder(userId), "Objects"); + = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects"); item1.Folder = objsFolder.ID; scene.AddInventoryItem(userId, item1); @@ -267,10 +266,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests CachedUserInfo userInfo = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); - //InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName); InventoryItemBase foundItem - = InventoryArchiveUtils.FindItemByPath( - scene.InventoryService, scene.InventoryService.GetRootFolder(userInfo.UserProfile.ID), itemName); + = InventoryArchiveUtils.FindItemByPath( scene.InventoryService, userInfo.UserProfile.ID, itemName); + Assert.That(foundItem, Is.Not.Null, "Didn't find loaded item"); Assert.That( foundItem.CreatorId, Is.EqualTo(item1.CreatorId), -- cgit v1.1 From 61c286f5d66c4bf44d04c4aac991ba350deb62ea Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sun, 6 Sep 2009 22:07:35 +0100 Subject: change iar load to make discrete inventory service requests rather than the cache --- .../Archiver/InventoryArchiveReadRequest.cs | 65 +++++++++++++--------- .../Archiver/Tests/InventoryArchiverTests.cs | 21 ++++--- 2 files changed, 52 insertions(+), 34 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index bb40450..ff583e5 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -100,6 +100,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver int successfulItemRestores = 0; List nodesLoaded = new List(); + /* if (!m_userInfo.HasReceivedInventory) { // If the region server has access to the user admin service (by which users are created), @@ -127,8 +128,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } } } - - InventoryFolderImpl rootDestinationFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath); + */ + + //InventoryFolderImpl rootDestinationFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath); + InventoryFolderBase rootDestinationFolder + = InventoryArchiveUtils.FindFolderByPath( + m_scene.InventoryService, m_userInfo.UserProfile.ID, m_invPath); if (null == rootDestinationFolder) { @@ -142,7 +147,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // In order to load identically named folders, we need to keep track of the folders that we have already // created - Dictionary foldersCreated = new Dictionary(); + Dictionary foldersCreated = new Dictionary(); byte[] data; TarArchiveReader.TarEntryType entryType; @@ -157,7 +162,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) { - InventoryFolderImpl foundFolder + InventoryFolderBase foundFolder = ReplicateArchivePathToUserInventory( filePath, TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType, rootDestinationFolder, foldersCreated, nodesLoaded); @@ -178,7 +183,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // Reset folder ID to the one in which we want to load it item.Folder = foundFolder.ID; - m_userInfo.AddItem(item); + //m_userInfo.AddItem(item); + m_scene.InventoryService.AddItem(item); successfulItemRestores++; // If we're loading an item directly into the given destination folder then we need to record @@ -211,11 +217,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// chain, only the root node needs to be recorded /// /// The last user inventory folder created or found for the archive path - public InventoryFolderImpl ReplicateArchivePathToUserInventory( + public InventoryFolderBase ReplicateArchivePathToUserInventory( string fsPath, bool isDir, - InventoryFolderImpl rootDestinationFolder, - Dictionary foldersCreated, + InventoryFolderBase rootDestFolder, + Dictionary foldersCreated, List nodesLoaded) { fsPath = fsPath.Substring(ArchiveConstants.INVENTORY_PATH.Length); @@ -228,17 +234,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_log.DebugFormat("[INVENTORY ARCHIVER]: Loading to folder {0}", fsPath); - InventoryFolderImpl foundFolder = null; + InventoryFolderBase destFolder = null; // XXX: Nasty way of dealing with a path that has no directory component if (fsPath.Length > 0) { - while (null == foundFolder && fsPath.Length > 0) + while (null == destFolder && fsPath.Length > 0) { if (foldersCreated.ContainsKey(fsPath)) { m_log.DebugFormat("[INVENTORY ARCHIVER]: Found previously created fs path {0}", fsPath); - foundFolder = foldersCreated[fsPath]; + destFolder = foldersCreated[fsPath]; } else { @@ -255,14 +261,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver "[INVENTORY ARCHIVER]: Found no previously created fs path for {0}", originalFsPath); fsPath = string.Empty; - foundFolder = rootDestinationFolder; + destFolder = rootDestFolder; } } } } else { - foundFolder = rootDestinationFolder; + destFolder = rootDestFolder; } string fsPathSectionToCreate = originalFsPath.Substring(fsPath.Length); @@ -277,30 +283,39 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver int identicalNameIdentifierIndex = rawDirsToCreate[i].LastIndexOf( ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR); - string folderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex); + string newFolderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex); UUID newFolderId = UUID.Random(); - m_userInfo.CreateFolder( - folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID); - - m_log.DebugFormat("[INVENTORY ARCHIVER]: Retrieving newly created folder {0}", folderName); - foundFolder = foundFolder.GetChildFolder(newFolderId); - m_log.DebugFormat( - "[INVENTORY ARCHIVER]: Retrieved newly created folder {0} with ID {1}", - foundFolder.Name, foundFolder.ID); + + destFolder + = new InventoryFolderBase( + newFolderId, newFolderName, m_userInfo.UserProfile.ID, + (short)AssetType.Folder, destFolder.ID, 0); + m_scene.InventoryService.AddFolder(destFolder); + +// UUID newFolderId = UUID.Random(); +// m_scene.InventoryService.AddFolder( +// m_userInfo.CreateFolder( +// folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID); + +// m_log.DebugFormat("[INVENTORY ARCHIVER]: Retrieving newly created folder {0}", folderName); +// foundFolder = foundFolder.GetChildFolder(newFolderId); +// m_log.DebugFormat( +// "[INVENTORY ARCHIVER]: Retrieved newly created folder {0} with ID {1}", +// foundFolder.Name, foundFolder.ID); // Record that we have now created this folder fsPath += rawDirsToCreate[i] + "/"; m_log.DebugFormat("[INVENTORY ARCHIVER]: Recording creation of fs path {0}", fsPath); - foldersCreated[fsPath] = foundFolder; + foldersCreated[fsPath] = destFolder; if (0 == i) - nodesLoaded.Add(foundFolder); + nodesLoaded.Add(destFolder); i++; } - return foundFolder; + return destFolder; /* string[] rawFolders = filePath.Split(new char[] { '/' }); diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 50fd2b0..c21adef 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -267,7 +267,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); InventoryItemBase foundItem - = InventoryArchiveUtils.FindItemByPath( scene.InventoryService, userInfo.UserProfile.ID, itemName); + = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, itemName); Assert.That(foundItem, Is.Not.Null, "Didn't find loaded item"); Assert.That( @@ -378,9 +378,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests Monitor.Wait(this, 60000); } - Console.WriteLine("userInfo.RootFolder 1: {0}", userInfo.RootFolder); + //Console.WriteLine("userInfo.RootFolder 1: {0}", userInfo.RootFolder); - Dictionary foldersCreated = new Dictionary(); + Dictionary foldersCreated = new Dictionary(); List nodesLoaded = new List(); string folder1Name = "a"; @@ -398,17 +398,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests "{0}{1}/{2}/{3}", ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemName); - Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder); + //Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder); new InventoryArchiveReadRequest(scene, userInfo, null, (Stream)null) .ReplicateArchivePathToUserInventory( - itemArchivePath, false, userInfo.RootFolder, foldersCreated, nodesLoaded); + itemArchivePath, false, scene.InventoryService.GetRootFolder(userInfo.UserProfile.ID), + foldersCreated, nodesLoaded); - Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder); - InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a"); + //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"); - InventoryFolderImpl folder2 = folder1.FindFolderByPath("b"); + InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b"); Assert.That(folder2, Is.Not.Null, "Could not find folder b"); } } -} +} \ No newline at end of file -- cgit v1.1 From 10b075a33da1105ae440a57d5488baa9c161e444 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 7 Sep 2009 18:42:53 +0100 Subject: change default iar filename --- .../CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 2c36270..3869de2 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -57,7 +57,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// /// The file to load and save inventory if no filename has been specified /// - protected const string DEFAULT_INV_BACKUP_FILENAME = "user-inventory_iar.tar.gz"; + protected const string DEFAULT_INV_BACKUP_FILENAME = "user-inventory.iar"; /// /// Pending save completions initiated from the console -- cgit v1.1 From 71f1628578b864ca7db94ffcf500432314007165 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 7 Sep 2009 19:11:16 +0100 Subject: make oar module logging a little less noisy --- OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs index f9b0225..5c58b69 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs @@ -58,14 +58,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver public void Initialise(IConfigSource source) { - m_log.Info("[ARCHIVER] Initialising"); + //m_log.Debug("[ARCHIVER] Initialising"); } public void AddRegion(Scene scene) { m_scene = scene; m_scene.RegisterModuleInterface(this); - m_log.InfoFormat("[ARCHIVER]: Enabled for region {0}", scene.RegionInfo.RegionName); + //m_log.DebugFormat("[ARCHIVER]: Enabled for region {0}", scene.RegionInfo.RegionName); } public void RegionLoaded(Scene scene) -- cgit v1.1 From fa1d79533e22266f8ee7f1aa4d93a3f7fba0e230 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 7 Sep 2009 19:57:44 +0100 Subject: Only allow iar load/save if user is logged in to the region simulator --- .../Inventory/Archiver/InventoryArchiverModule.cs | 128 +++++++++++++++++---- .../Archiver/Tests/InventoryArchiverTests.cs | 10 +- .../Interfaces/IInventoryArchiverModule.cs | 10 +- 3 files changed, 116 insertions(+), 32 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 3869de2..2340fad 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -51,6 +51,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver public string Name { get { return "Inventory Archiver Module"; } } public bool IsSharedModule { get { return true; } } + + /// + /// Enable or disable checking whether the iar user is actually logged in + /// + public bool DisablePresenceChecks { get; set; } public event InventoryArchiveSaved OnInventoryArchiveSaved; @@ -70,6 +75,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver private Dictionary m_scenes = new Dictionary(); private Scene m_aScene; + public InventoryArchiverModule() {} + + public InventoryArchiverModule(bool disablePresenceChecks) + { + DisablePresenceChecks = disablePresenceChecks; + } + public void Initialise(Scene scene, IConfigSource source) { if (m_scenes.Count == 0) @@ -109,29 +121,57 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException); } - public void ArchiveInventory(Guid id, string firstName, string lastName, string invPath, Stream saveStream) + public bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, Stream saveStream) { if (m_scenes.Count > 0) { CachedUserInfo userInfo = GetUserInfo(firstName, lastName); if (userInfo != null) - new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute(); - } + { + if (CheckPresence(userInfo.UserProfile.ID)) + { + new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute(); + return true; + } + else + { + m_log.ErrorFormat( + "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator", + userInfo.UserProfile.Name, userInfo.UserProfile.ID); + } + } + } + + return false; } - public void ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string savePath) + public bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string savePath) { if (m_scenes.Count > 0) { CachedUserInfo userInfo = GetUserInfo(firstName, lastName); if (userInfo != null) - new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute(); - } + { + if (CheckPresence(userInfo.UserProfile.ID)) + { + new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute(); + return true; + } + else + { + m_log.ErrorFormat( + "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator", + userInfo.UserProfile.Name, userInfo.UserProfile.ID); + } + } + } + + return false; } - public void DearchiveInventory(string firstName, string lastName, string invPath, Stream loadStream) + public bool DearchiveInventory(string firstName, string lastName, string invPath, Stream loadStream) { if (m_scenes.Count > 0) { @@ -139,14 +179,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver if (userInfo != null) { - InventoryArchiveReadRequest request = - new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream); - UpdateClientWithLoadedNodes(userInfo, request.Execute()); + if (CheckPresence(userInfo.UserProfile.ID)) + { + InventoryArchiveReadRequest request = + new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream); + UpdateClientWithLoadedNodes(userInfo, request.Execute()); + + return true; + } + else + { + m_log.ErrorFormat( + "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator", + userInfo.UserProfile.Name, userInfo.UserProfile.ID); + } } - } + } + + return false; } - public void DearchiveInventory(string firstName, string lastName, string invPath, string loadPath) + public bool DearchiveInventory(string firstName, string lastName, string invPath, string loadPath) { if (m_scenes.Count > 0) { @@ -154,11 +207,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver if (userInfo != null) { - InventoryArchiveReadRequest request = - new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath); - UpdateClientWithLoadedNodes(userInfo, request.Execute()); - } - } + if (CheckPresence(userInfo.UserProfile.ID)) + { + InventoryArchiveReadRequest request = + new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath); + UpdateClientWithLoadedNodes(userInfo, request.Execute()); + + return true; + } + else + { + m_log.ErrorFormat( + "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator", + userInfo.UserProfile.Name, userInfo.UserProfile.ID); + } + } + } + + return false; } /// @@ -183,11 +249,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver "[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}", loadPath, invPath, firstName, lastName); - DearchiveInventory(firstName, lastName, invPath, loadPath); - - m_log.InfoFormat( - "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}", - loadPath, firstName, lastName); + if (DearchiveInventory(firstName, lastName, invPath, loadPath)) + m_log.InfoFormat( + "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}", + loadPath, firstName, lastName); } /// @@ -291,5 +356,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } } } + + /// + /// Check if the given user is present in any of the scenes. + /// + /// The user to check + /// true if the user is in any of the scenes, false otherwise + protected bool CheckPresence(UUID userId) + { + if (DisablePresenceChecks) + return true; + + foreach (Scene scene in m_scenes.Values) + { + if (scene.GetScenePresence(userId) != null) + return true; + } + + return false; + } } } diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index c21adef..d579a81 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -83,7 +83,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests TestHelper.InMethod(); log4net.Config.XmlConfigurator.Configure(); - InventoryArchiverModule archiverModule = new InventoryArchiverModule(); + InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); Scene scene = SceneSetupHelpers.SetupScene("Inventory"); SceneSetupHelpers.SetupSceneModules(scene, archiverModule); @@ -100,9 +100,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests cm, userFirstName, userLastName, userId, InventoryReceived); Monitor.Wait(this, 60000); } - - Console.WriteLine("here"); - + // Create asset SceneObjectGroup object1; SceneObjectPart part1; @@ -248,7 +246,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); SerialiserModule serialiserModule = new SerialiserModule(); - InventoryArchiverModule archiverModule = new InventoryArchiverModule(); + 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"); @@ -318,7 +316,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); SerialiserModule serialiserModule = new SerialiserModule(); - InventoryArchiverModule archiverModule = new InventoryArchiverModule(); + 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(); diff --git a/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs b/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs index 457b5b8..ca7abf8 100644 --- a/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs @@ -56,8 +56,9 @@ namespace OpenSim.Region.Framework.Interfaces /// /// /// The inventory path in which to place the loaded folders and items - /// The stream from which the inventory archive will be loaded - void DearchiveInventory(string firstName, string lastName, string invPath, Stream loadStream); + /// The stream from which the inventory archive will be loaded + /// true if the first stage of the operation succeeded, false otherwise + bool DearchiveInventory(string firstName, string lastName, string invPath, Stream loadStream); /// /// Archive a user's inventory folder to the given stream @@ -67,6 +68,7 @@ namespace OpenSim.Region.Framework.Interfaces /// /// The inventory path from which the inventory should be saved. /// The stream to which the inventory archive will be saved - void ArchiveInventory(Guid id, string firstName, string lastName, string invPath, Stream saveStream); + /// true if the first stage of the operation succeeded, false otherwise + bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, Stream saveStream); } -} +} \ No newline at end of file -- cgit v1.1 From 7a67b726d5be8b7eb7d04eabdb98dc4e3beb9d71 Mon Sep 17 00:00:00 2001 From: dahlia Date: Mon, 7 Sep 2009 17:12:17 -0700 Subject: random drive-by maths optimization in llRot2Euler() and llEuler2Rot() --- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 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 16dd834..077315e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -497,9 +497,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api NormalizeAngle(Math.Atan2(n, Math.Sqrt(p))), NormalizeAngle(Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s)))); else if (n > 0) - return new LSL_Vector(0.0, Math.PI / 2, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z))); + return new LSL_Vector(0.0, Math.PI * 0.5, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z))); else - return new LSL_Vector(0.0, -Math.PI / 2, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z))); + return new LSL_Vector(0.0, -Math.PI * 0.5, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z))); } /* From wiki: @@ -553,12 +553,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api double x,y,z,s; - double c1 = Math.Cos(v.x/2.0); - double c2 = Math.Cos(v.y/2.0); - double c3 = Math.Cos(v.z/2.0); - double s1 = Math.Sin(v.x/2.0); - double s2 = Math.Sin(v.y/2.0); - double s3 = Math.Sin(v.z/2.0); + double c1 = Math.Cos(v.x * 0.5); + double c2 = Math.Cos(v.y * 0.5); + double c3 = Math.Cos(v.z * 0.5); + double s1 = Math.Sin(v.x * 0.5); + double s2 = Math.Sin(v.y * 0.5); + double s3 = Math.Sin(v.z * 0.5); x = s1*c2*c3+c1*s2*s3; y = c1*s2*c3-s1*c2*s3; -- cgit v1.1 From 665cf0194afff36f7f4ceae80af83aa253ec61a2 Mon Sep 17 00:00:00 2001 From: dahlia Date: Mon, 7 Sep 2009 18:02:02 -0700 Subject: llRot2Euler() now returns angles -PI < angle < PI --- .../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 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 077315e..f261c16 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -476,9 +476,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // normalize an angle between -PI and PI (-180 to +180 degrees) protected double NormalizeAngle(double angle) { - angle = angle % (Math.PI * 2); - // if (angle < 0) angle = angle + Math.PI * 2; - return angle; + if (angle > -Math.PI && angle < Math.PI) + return angle; + + int numPis = (int)(Math.PI / angle); + double remainder = angle - Math.PI * numPis; + if (numPis % 2 == 1) + return Math.PI - angle; + return remainder; } // Old implementation of llRot2Euler, now normalized -- cgit v1.1