diff options
author | Teravus Ovares (Dan Olivares) | 2009-09-08 04:43:17 -0400 |
---|---|---|
committer | Teravus Ovares (Dan Olivares) | 2009-09-08 04:43:17 -0400 |
commit | f0e2fd426b074ceb992124cf5eb2ebe8db5c04dd (patch) | |
tree | bea9234644b05887b4c7cc063d457b91610ed9dc /OpenSim | |
parent | * Fixes a 'take object from mega region' and rez it in a regular region.. ... (diff) | |
parent | llRot2Euler() now returns angles -PI < angle < PI (diff) | |
download | opensim-SC_OLD-f0e2fd426b074ceb992124cf5eb2ebe8db5c04dd.zip opensim-SC_OLD-f0e2fd426b074ceb992124cf5eb2ebe8db5c04dd.tar.gz opensim-SC_OLD-f0e2fd426b074ceb992124cf5eb2ebe8db5c04dd.tar.bz2 opensim-SC_OLD-f0e2fd426b074ceb992124cf5eb2ebe8db5c04dd.tar.xz |
Merge branch 'master' of ssh://MyConnection/var/git/opensim
Diffstat (limited to 'OpenSim')
12 files changed, 489 insertions, 145 deletions
diff --git a/OpenSim/Data/Tests/BasicEstateTest.cs b/OpenSim/Data/Tests/BasicEstateTest.cs index 284d066..d8e1725 100644 --- a/OpenSim/Data/Tests/BasicEstateTest.cs +++ b/OpenSim/Data/Tests/BasicEstateTest.cs | |||
@@ -154,10 +154,10 @@ namespace OpenSim.Data.Tests | |||
154 | ); | 154 | ); |
155 | } | 155 | } |
156 | 156 | ||
157 | [Test] | 157 | //[Test] |
158 | private void T012_EstateSettingsRandomStorage() | 158 | // Currently fails occasionally |
159 | public void T012_EstateSettingsRandomStorage() | ||
159 | { | 160 | { |
160 | |||
161 | // Letting estate store generate rows to database for us | 161 | // Letting estate store generate rows to database for us |
162 | EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID); | 162 | EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID); |
163 | new PropertyScrambler<EstateSettings>().Scramble(originalSettings); | 163 | new PropertyScrambler<EstateSettings>().Scramble(originalSettings); |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 38bd149..ff583e5 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; | |||
42 | using OpenSim.Framework.Serialization; | 42 | using OpenSim.Framework.Serialization; |
43 | using OpenSim.Framework.Serialization.External; | 43 | using OpenSim.Framework.Serialization.External; |
44 | using OpenSim.Region.CoreModules.World.Archiver; | 44 | using OpenSim.Region.CoreModules.World.Archiver; |
45 | using OpenSim.Region.Framework.Scenes; | ||
45 | using OpenSim.Services.Interfaces; | 46 | using OpenSim.Services.Interfaces; |
46 | 47 | ||
47 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | 48 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver |
@@ -56,31 +57,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
56 | private string m_invPath; | 57 | private string m_invPath; |
57 | 58 | ||
58 | /// <value> | 59 | /// <value> |
60 | /// We only use this to request modules | ||
61 | /// </value> | ||
62 | protected Scene m_scene; | ||
63 | |||
64 | /// <value> | ||
59 | /// The stream from which the inventory archive will be loaded. | 65 | /// The stream from which the inventory archive will be loaded. |
60 | /// </value> | 66 | /// </value> |
61 | private Stream m_loadStream; | 67 | private Stream m_loadStream; |
62 | 68 | ||
63 | protected CommunicationsManager m_commsManager; | ||
64 | protected IAssetService m_assetService; | ||
65 | |||
66 | public InventoryArchiveReadRequest( | 69 | public InventoryArchiveReadRequest( |
67 | CachedUserInfo userInfo, string invPath, string loadPath, CommunicationsManager commsManager, IAssetService assetService) | 70 | Scene scene, CachedUserInfo userInfo, string invPath, string loadPath) |
68 | : this( | 71 | : this( |
72 | scene, | ||
69 | userInfo, | 73 | userInfo, |
70 | invPath, | 74 | invPath, |
71 | new GZipStream(new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress), | 75 | new GZipStream(new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress)) |
72 | commsManager, assetService) | ||
73 | { | 76 | { |
74 | } | 77 | } |
75 | 78 | ||
76 | public InventoryArchiveReadRequest( | 79 | public InventoryArchiveReadRequest( |
77 | CachedUserInfo userInfo, string invPath, Stream loadStream, CommunicationsManager commsManager, IAssetService assetService) | 80 | Scene scene, CachedUserInfo userInfo, string invPath, Stream loadStream) |
78 | { | 81 | { |
82 | m_scene = scene; | ||
79 | m_userInfo = userInfo; | 83 | m_userInfo = userInfo; |
80 | m_invPath = invPath; | 84 | m_invPath = invPath; |
81 | m_loadStream = loadStream; | 85 | m_loadStream = loadStream; |
82 | m_commsManager = commsManager; | ||
83 | m_assetService = assetService; | ||
84 | } | 86 | } |
85 | 87 | ||
86 | /// <summary> | 88 | /// <summary> |
@@ -98,6 +100,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
98 | int successfulItemRestores = 0; | 100 | int successfulItemRestores = 0; |
99 | List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>(); | 101 | List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>(); |
100 | 102 | ||
103 | /* | ||
101 | if (!m_userInfo.HasReceivedInventory) | 104 | if (!m_userInfo.HasReceivedInventory) |
102 | { | 105 | { |
103 | // If the region server has access to the user admin service (by which users are created), | 106 | // If the region server has access to the user admin service (by which users are created), |
@@ -106,7 +109,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
106 | // | 109 | // |
107 | // FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might | 110 | // FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might |
108 | // use a remote inventory service, though this is vanishingly rare at the moment. | 111 | // use a remote inventory service, though this is vanishingly rare at the moment. |
109 | if (null == m_commsManager.UserAdminService) | 112 | if (null == m_scene.CommsManager.UserAdminService) |
110 | { | 113 | { |
111 | m_log.ErrorFormat( | 114 | m_log.ErrorFormat( |
112 | "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1}", | 115 | "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1}", |
@@ -125,8 +128,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
125 | } | 128 | } |
126 | } | 129 | } |
127 | } | 130 | } |
128 | 131 | */ | |
129 | InventoryFolderImpl rootDestinationFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath); | 132 | |
133 | //InventoryFolderImpl rootDestinationFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath); | ||
134 | InventoryFolderBase rootDestinationFolder | ||
135 | = InventoryArchiveUtils.FindFolderByPath( | ||
136 | m_scene.InventoryService, m_userInfo.UserProfile.ID, m_invPath); | ||
130 | 137 | ||
131 | if (null == rootDestinationFolder) | 138 | if (null == rootDestinationFolder) |
132 | { | 139 | { |
@@ -140,7 +147,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
140 | 147 | ||
141 | // In order to load identically named folders, we need to keep track of the folders that we have already | 148 | // In order to load identically named folders, we need to keep track of the folders that we have already |
142 | // created | 149 | // created |
143 | Dictionary <string, InventoryFolderImpl> foldersCreated = new Dictionary<string, InventoryFolderImpl>(); | 150 | Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>(); |
144 | 151 | ||
145 | byte[] data; | 152 | byte[] data; |
146 | TarArchiveReader.TarEntryType entryType; | 153 | TarArchiveReader.TarEntryType entryType; |
@@ -155,7 +162,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
155 | } | 162 | } |
156 | else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) | 163 | else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) |
157 | { | 164 | { |
158 | InventoryFolderImpl foundFolder | 165 | InventoryFolderBase foundFolder |
159 | = ReplicateArchivePathToUserInventory( | 166 | = ReplicateArchivePathToUserInventory( |
160 | filePath, TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType, | 167 | filePath, TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType, |
161 | rootDestinationFolder, foldersCreated, nodesLoaded); | 168 | rootDestinationFolder, foldersCreated, nodesLoaded); |
@@ -167,7 +174,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
167 | // Don't use the item ID that's in the file | 174 | // Don't use the item ID that's in the file |
168 | item.ID = UUID.Random(); | 175 | item.ID = UUID.Random(); |
169 | 176 | ||
170 | UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_commsManager); | 177 | UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.CommsManager); |
171 | if (UUID.Zero != ospResolvedId) | 178 | if (UUID.Zero != ospResolvedId) |
172 | item.CreatorIdAsUuid = ospResolvedId; | 179 | item.CreatorIdAsUuid = ospResolvedId; |
173 | 180 | ||
@@ -176,7 +183,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
176 | // Reset folder ID to the one in which we want to load it | 183 | // Reset folder ID to the one in which we want to load it |
177 | item.Folder = foundFolder.ID; | 184 | item.Folder = foundFolder.ID; |
178 | 185 | ||
179 | m_userInfo.AddItem(item); | 186 | //m_userInfo.AddItem(item); |
187 | m_scene.InventoryService.AddItem(item); | ||
180 | successfulItemRestores++; | 188 | successfulItemRestores++; |
181 | 189 | ||
182 | // If we're loading an item directly into the given destination folder then we need to record | 190 | // If we're loading an item directly into the given destination folder then we need to record |
@@ -209,11 +217,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
209 | /// chain, only the root node needs to be recorded | 217 | /// chain, only the root node needs to be recorded |
210 | /// </param> | 218 | /// </param> |
211 | /// <returns>The last user inventory folder created or found for the archive path</returns> | 219 | /// <returns>The last user inventory folder created or found for the archive path</returns> |
212 | public InventoryFolderImpl ReplicateArchivePathToUserInventory( | 220 | public InventoryFolderBase ReplicateArchivePathToUserInventory( |
213 | string fsPath, | 221 | string fsPath, |
214 | bool isDir, | 222 | bool isDir, |
215 | InventoryFolderImpl rootDestinationFolder, | 223 | InventoryFolderBase rootDestFolder, |
216 | Dictionary <string, InventoryFolderImpl> foldersCreated, | 224 | Dictionary <string, InventoryFolderBase> foldersCreated, |
217 | List<InventoryNodeBase> nodesLoaded) | 225 | List<InventoryNodeBase> nodesLoaded) |
218 | { | 226 | { |
219 | fsPath = fsPath.Substring(ArchiveConstants.INVENTORY_PATH.Length); | 227 | fsPath = fsPath.Substring(ArchiveConstants.INVENTORY_PATH.Length); |
@@ -226,17 +234,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
226 | 234 | ||
227 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Loading to folder {0}", fsPath); | 235 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Loading to folder {0}", fsPath); |
228 | 236 | ||
229 | InventoryFolderImpl foundFolder = null; | 237 | InventoryFolderBase destFolder = null; |
230 | 238 | ||
231 | // XXX: Nasty way of dealing with a path that has no directory component | 239 | // XXX: Nasty way of dealing with a path that has no directory component |
232 | if (fsPath.Length > 0) | 240 | if (fsPath.Length > 0) |
233 | { | 241 | { |
234 | while (null == foundFolder && fsPath.Length > 0) | 242 | while (null == destFolder && fsPath.Length > 0) |
235 | { | 243 | { |
236 | if (foldersCreated.ContainsKey(fsPath)) | 244 | if (foldersCreated.ContainsKey(fsPath)) |
237 | { | 245 | { |
238 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Found previously created fs path {0}", fsPath); | 246 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Found previously created fs path {0}", fsPath); |
239 | foundFolder = foldersCreated[fsPath]; | 247 | destFolder = foldersCreated[fsPath]; |
240 | } | 248 | } |
241 | else | 249 | else |
242 | { | 250 | { |
@@ -253,14 +261,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
253 | "[INVENTORY ARCHIVER]: Found no previously created fs path for {0}", | 261 | "[INVENTORY ARCHIVER]: Found no previously created fs path for {0}", |
254 | originalFsPath); | 262 | originalFsPath); |
255 | fsPath = string.Empty; | 263 | fsPath = string.Empty; |
256 | foundFolder = rootDestinationFolder; | 264 | destFolder = rootDestFolder; |
257 | } | 265 | } |
258 | } | 266 | } |
259 | } | 267 | } |
260 | } | 268 | } |
261 | else | 269 | else |
262 | { | 270 | { |
263 | foundFolder = rootDestinationFolder; | 271 | destFolder = rootDestFolder; |
264 | } | 272 | } |
265 | 273 | ||
266 | string fsPathSectionToCreate = originalFsPath.Substring(fsPath.Length); | 274 | string fsPathSectionToCreate = originalFsPath.Substring(fsPath.Length); |
@@ -275,30 +283,39 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
275 | int identicalNameIdentifierIndex | 283 | int identicalNameIdentifierIndex |
276 | = rawDirsToCreate[i].LastIndexOf( | 284 | = rawDirsToCreate[i].LastIndexOf( |
277 | ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR); | 285 | ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR); |
278 | string folderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex); | ||
279 | 286 | ||
287 | string newFolderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex); | ||
280 | UUID newFolderId = UUID.Random(); | 288 | UUID newFolderId = UUID.Random(); |
281 | m_userInfo.CreateFolder( | 289 | |
282 | folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID); | 290 | destFolder |
283 | 291 | = new InventoryFolderBase( | |
284 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Retrieving newly created folder {0}", folderName); | 292 | newFolderId, newFolderName, m_userInfo.UserProfile.ID, |
285 | foundFolder = foundFolder.GetChildFolder(newFolderId); | 293 | (short)AssetType.Folder, destFolder.ID, 0); |
286 | m_log.DebugFormat( | 294 | m_scene.InventoryService.AddFolder(destFolder); |
287 | "[INVENTORY ARCHIVER]: Retrieved newly created folder {0} with ID {1}", | 295 | |
288 | foundFolder.Name, foundFolder.ID); | 296 | // UUID newFolderId = UUID.Random(); |
297 | // m_scene.InventoryService.AddFolder( | ||
298 | // m_userInfo.CreateFolder( | ||
299 | // folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID); | ||
300 | |||
301 | // m_log.DebugFormat("[INVENTORY ARCHIVER]: Retrieving newly created folder {0}", folderName); | ||
302 | // foundFolder = foundFolder.GetChildFolder(newFolderId); | ||
303 | // m_log.DebugFormat( | ||
304 | // "[INVENTORY ARCHIVER]: Retrieved newly created folder {0} with ID {1}", | ||
305 | // foundFolder.Name, foundFolder.ID); | ||
289 | 306 | ||
290 | // Record that we have now created this folder | 307 | // Record that we have now created this folder |
291 | fsPath += rawDirsToCreate[i] + "/"; | 308 | fsPath += rawDirsToCreate[i] + "/"; |
292 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Recording creation of fs path {0}", fsPath); | 309 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Recording creation of fs path {0}", fsPath); |
293 | foldersCreated[fsPath] = foundFolder; | 310 | foldersCreated[fsPath] = destFolder; |
294 | 311 | ||
295 | if (0 == i) | 312 | if (0 == i) |
296 | nodesLoaded.Add(foundFolder); | 313 | nodesLoaded.Add(destFolder); |
297 | 314 | ||
298 | i++; | 315 | i++; |
299 | } | 316 | } |
300 | 317 | ||
301 | return foundFolder; | 318 | return destFolder; |
302 | 319 | ||
303 | /* | 320 | /* |
304 | string[] rawFolders = filePath.Split(new char[] { '/' }); | 321 | string[] rawFolders = filePath.Split(new char[] { '/' }); |
@@ -371,7 +388,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
371 | asset.Type = assetType; | 388 | asset.Type = assetType; |
372 | asset.Data = data; | 389 | asset.Data = data; |
373 | 390 | ||
374 | m_assetService.Store(asset); | 391 | m_scene.AssetService.Store(asset); |
375 | 392 | ||
376 | return true; | 393 | return true; |
377 | } | 394 | } |
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..2eeb637 --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs | |||
@@ -0,0 +1,212 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Services.Interfaces; | ||
33 | |||
34 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | ||
35 | { | ||
36 | /// <summary> | ||
37 | /// Utility methods for inventory archiving | ||
38 | /// </summary> | ||
39 | public static class InventoryArchiveUtils | ||
40 | { | ||
41 | public static readonly string PATH_DELIMITER = "/"; | ||
42 | |||
43 | /// <summary> | ||
44 | /// Find a folder given a PATH_DELIMITER delimited path starting from a user's root folder | ||
45 | /// </summary> | ||
46 | /// | ||
47 | /// This method does not handle paths that contain multiple delimitors | ||
48 | /// | ||
49 | /// FIXME: We do not yet handle situations where folders have the same name. We could handle this by some | ||
50 | /// XPath like expression | ||
51 | /// | ||
52 | /// FIXME: Delimitors which occur in names themselves are not currently escapable. | ||
53 | /// | ||
54 | /// <param name="inventoryService"> | ||
55 | /// Inventory service to query | ||
56 | /// </param> | ||
57 | /// <param name="userId"> | ||
58 | /// User id to search | ||
59 | /// </param> | ||
60 | /// <param name="path"> | ||
61 | /// The path to the required folder. | ||
62 | /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned. | ||
63 | /// </param> | ||
64 | /// <returns>null if the folder is not found</returns> | ||
65 | public static InventoryFolderBase FindFolderByPath( | ||
66 | IInventoryService inventoryService, UUID userId, string path) | ||
67 | { | ||
68 | InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId); | ||
69 | |||
70 | if (null == rootFolder) | ||
71 | return null; | ||
72 | |||
73 | return FindFolderByPath(inventoryService, rootFolder, path); | ||
74 | } | ||
75 | |||
76 | /// <summary> | ||
77 | /// Find a folder given a PATH_DELIMITER delimited path starting from this folder | ||
78 | /// </summary> | ||
79 | /// | ||
80 | /// This method does not handle paths that contain multiple delimitors | ||
81 | /// | ||
82 | /// FIXME: We do not yet handle situations where folders have the same name. We could handle this by some | ||
83 | /// XPath like expression | ||
84 | /// | ||
85 | /// FIXME: Delimitors which occur in names themselves are not currently escapable. | ||
86 | /// | ||
87 | /// <param name="inventoryService"> | ||
88 | /// Inventory service to query | ||
89 | /// </param> | ||
90 | /// <param name="startFolder"> | ||
91 | /// The folder from which the path starts | ||
92 | /// </param> | ||
93 | /// <param name="path"> | ||
94 | /// The path to the required folder. | ||
95 | /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned. | ||
96 | /// </param> | ||
97 | /// <returns>null if the folder is not found</returns> | ||
98 | public static InventoryFolderBase FindFolderByPath( | ||
99 | IInventoryService inventoryService, InventoryFolderBase startFolder, string path) | ||
100 | { | ||
101 | if (path == string.Empty) | ||
102 | return startFolder; | ||
103 | |||
104 | path = path.Trim(); | ||
105 | |||
106 | if (path == PATH_DELIMITER) | ||
107 | return startFolder; | ||
108 | |||
109 | InventoryFolderBase foundFolder = null; | ||
110 | |||
111 | string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); | ||
112 | InventoryCollection contents = inventoryService.GetFolderContent(startFolder.Owner, startFolder.ID); | ||
113 | |||
114 | foreach (InventoryFolderBase folder in contents.Folders) | ||
115 | { | ||
116 | if (folder.Name == components[0]) | ||
117 | { | ||
118 | if (components.Length > 1) | ||
119 | return FindFolderByPath(inventoryService, foundFolder, components[1]); | ||
120 | else | ||
121 | return folder; | ||
122 | } | ||
123 | } | ||
124 | |||
125 | // We didn't find a folder with the right name | ||
126 | return null; | ||
127 | } | ||
128 | |||
129 | /// <summary> | ||
130 | /// Find an item given a PATH_DELIMITOR delimited path starting from the user's root folder. | ||
131 | /// | ||
132 | /// This method does not handle paths that contain multiple delimitors | ||
133 | /// | ||
134 | /// FIXME: We do not yet handle situations where folders or items have the same name. We could handle this by some | ||
135 | /// XPath like expression | ||
136 | /// | ||
137 | /// FIXME: Delimitors which occur in names themselves are not currently escapable. | ||
138 | /// </summary> | ||
139 | /// | ||
140 | /// <param name="inventoryService"> | ||
141 | /// Inventory service to query | ||
142 | /// </param> | ||
143 | /// <param name="userId"> | ||
144 | /// The user to search | ||
145 | /// </param> | ||
146 | /// <param name="path"> | ||
147 | /// The path to the required item. | ||
148 | /// </param> | ||
149 | /// <returns>null if the item is not found</returns> | ||
150 | public static InventoryItemBase FindItemByPath( | ||
151 | IInventoryService inventoryService, UUID userId, string path) | ||
152 | { | ||
153 | InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId); | ||
154 | |||
155 | if (null == rootFolder) | ||
156 | return null; | ||
157 | |||
158 | return FindItemByPath(inventoryService, rootFolder, path); | ||
159 | } | ||
160 | |||
161 | /// <summary> | ||
162 | /// Find an item given a PATH_DELIMITOR delimited path starting from this folder. | ||
163 | /// | ||
164 | /// This method does not handle paths that contain multiple delimitors | ||
165 | /// | ||
166 | /// FIXME: We do not yet handle situations where folders or items have the same name. We could handle this by some | ||
167 | /// XPath like expression | ||
168 | /// | ||
169 | /// FIXME: Delimitors which occur in names themselves are not currently escapable. | ||
170 | /// </summary> | ||
171 | /// | ||
172 | /// <param name="inventoryService"> | ||
173 | /// Inventory service to query | ||
174 | /// </param> | ||
175 | /// <param name="startFolder"> | ||
176 | /// The folder from which the path starts | ||
177 | /// </param> | ||
178 | /// <param name="path"> | ||
179 | /// <param name="path"> | ||
180 | /// The path to the required item. | ||
181 | /// </param> | ||
182 | /// <returns>null if the item is not found</returns> | ||
183 | public static InventoryItemBase FindItemByPath( | ||
184 | IInventoryService inventoryService, InventoryFolderBase startFolder, string path) | ||
185 | { | ||
186 | string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); | ||
187 | |||
188 | if (components.Length == 1) | ||
189 | { | ||
190 | List<InventoryItemBase> items = inventoryService.GetFolderItems(startFolder.Owner, startFolder.ID); | ||
191 | foreach (InventoryItemBase item in items) | ||
192 | { | ||
193 | if (item.Name == components[0]) | ||
194 | return item; | ||
195 | } | ||
196 | } | ||
197 | else | ||
198 | { | ||
199 | InventoryCollection contents = inventoryService.GetFolderContent(startFolder.Owner, startFolder.ID); | ||
200 | |||
201 | foreach (InventoryFolderBase folder in contents.Folders) | ||
202 | { | ||
203 | if (folder.Name == components[0]) | ||
204 | return FindItemByPath(inventoryService, folder, components[1]); | ||
205 | } | ||
206 | } | ||
207 | |||
208 | // We didn't find an item or intermediate folder with the given name | ||
209 | return null; | ||
210 | } | ||
211 | } | ||
212 | } \ 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 18728c6..dee4a5d 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | |||
@@ -60,6 +60,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
60 | protected UuidGatherer m_assetGatherer; | 60 | protected UuidGatherer m_assetGatherer; |
61 | 61 | ||
62 | /// <value> | 62 | /// <value> |
63 | /// We only use this to request modules | ||
64 | /// </value> | ||
65 | protected Scene m_scene; | ||
66 | |||
67 | /// <value> | ||
63 | /// ID of this request | 68 | /// ID of this request |
64 | /// </value> | 69 | /// </value> |
65 | protected Guid m_id; | 70 | protected Guid m_id; |
@@ -83,10 +88,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
83 | /// Constructor | 88 | /// Constructor |
84 | /// </summary> | 89 | /// </summary> |
85 | public InventoryArchiveWriteRequest( | 90 | public InventoryArchiveWriteRequest( |
86 | Guid id, InventoryArchiverModule module, CachedUserInfo userInfo, string invPath, string savePath) | 91 | Guid id, InventoryArchiverModule module, Scene scene, |
92 | CachedUserInfo userInfo, string invPath, string savePath) | ||
87 | : this( | 93 | : this( |
88 | id, | 94 | id, |
89 | module, | 95 | module, |
96 | scene, | ||
90 | userInfo, | 97 | userInfo, |
91 | invPath, | 98 | invPath, |
92 | new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress)) | 99 | new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress)) |
@@ -97,14 +104,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
97 | /// Constructor | 104 | /// Constructor |
98 | /// </summary> | 105 | /// </summary> |
99 | public InventoryArchiveWriteRequest( | 106 | public InventoryArchiveWriteRequest( |
100 | Guid id, InventoryArchiverModule module, CachedUserInfo userInfo, string invPath, Stream saveStream) | 107 | Guid id, InventoryArchiverModule module, Scene scene, |
108 | CachedUserInfo userInfo, string invPath, Stream saveStream) | ||
101 | { | 109 | { |
102 | m_id = id; | 110 | m_id = id; |
103 | m_module = module; | 111 | m_module = module; |
112 | m_scene = scene; | ||
104 | m_userInfo = userInfo; | 113 | m_userInfo = userInfo; |
105 | m_invPath = invPath; | 114 | m_invPath = invPath; |
106 | m_saveStream = saveStream; | 115 | m_saveStream = saveStream; |
107 | m_assetGatherer = new UuidGatherer(m_module.AssetService); | 116 | m_assetGatherer = new UuidGatherer(m_scene.AssetService); |
108 | } | 117 | } |
109 | 118 | ||
110 | protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids) | 119 | protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids) |
@@ -135,7 +144,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
135 | m_userUuids[inventoryItem.CreatorIdAsUuid] = 1; | 144 | m_userUuids[inventoryItem.CreatorIdAsUuid] = 1; |
136 | 145 | ||
137 | InventoryItemBase saveItem = (InventoryItemBase)inventoryItem.Clone(); | 146 | InventoryItemBase saveItem = (InventoryItemBase)inventoryItem.Clone(); |
138 | saveItem.CreatorId = OspResolver.MakeOspa(saveItem.CreatorIdAsUuid, m_module.CommsManager); | 147 | saveItem.CreatorId = OspResolver.MakeOspa(saveItem.CreatorIdAsUuid, m_scene.CommsManager); |
139 | 148 | ||
140 | string serialization = UserInventoryItemSerializer.Serialize(saveItem); | 149 | string serialization = UserInventoryItemSerializer.Serialize(saveItem); |
141 | m_archiveWriter.WriteFile(filename, serialization); | 150 | m_archiveWriter.WriteFile(filename, serialization); |
@@ -149,7 +158,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
149 | /// <param name="inventoryFolder">The inventory folder to save</param> | 158 | /// <param name="inventoryFolder">The inventory folder to save</param> |
150 | /// <param name="path">The path to which the folder should be saved</param> | 159 | /// <param name="path">The path to which the folder should be saved</param> |
151 | /// <param name="saveThisFolderItself">If true, save this folder itself. If false, only saves contents</param> | 160 | /// <param name="saveThisFolderItself">If true, save this folder itself. If false, only saves contents</param> |
152 | protected void SaveInvFolder(InventoryFolderImpl inventoryFolder, string path, bool saveThisFolderItself) | 161 | protected void SaveInvFolder(InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself) |
153 | { | 162 | { |
154 | if (saveThisFolderItself) | 163 | if (saveThisFolderItself) |
155 | { | 164 | { |
@@ -164,15 +173,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
164 | m_archiveWriter.WriteDir(path); | 173 | m_archiveWriter.WriteDir(path); |
165 | } | 174 | } |
166 | 175 | ||
167 | List<InventoryFolderImpl> childFolders = inventoryFolder.RequestListOfFolderImpls(); | 176 | InventoryCollection contents |
168 | List<InventoryItemBase> items = inventoryFolder.RequestListOfItems(); | 177 | = m_scene.InventoryService.GetFolderContent(inventoryFolder.Owner, inventoryFolder.ID); |
178 | //List<InventoryFolderImpl> childFolders = inventoryFolder.RequestListOfFolderImpls(); | ||
179 | //List<InventoryItemBase> items = inventoryFolder.RequestListOfItems(); | ||
169 | 180 | ||
170 | /* | 181 | /* |
171 | Dictionary identicalFolderNames = new Dictionary<string, int>(); | 182 | Dictionary identicalFolderNames = new Dictionary<string, int>(); |
172 | 183 | ||
173 | foreach (InventoryFolderImpl folder in inventories) | 184 | foreach (InventoryFolderImpl folder in inventories) |
174 | { | 185 | { |
175 | |||
176 | if (!identicalFolderNames.ContainsKey(folder.Name)) | 186 | if (!identicalFolderNames.ContainsKey(folder.Name)) |
177 | identicalFolderNames[folder.Name] = 0; | 187 | identicalFolderNames[folder.Name] = 0; |
178 | else | 188 | else |
@@ -188,12 +198,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
188 | } | 198 | } |
189 | */ | 199 | */ |
190 | 200 | ||
191 | foreach (InventoryFolderImpl childFolder in childFolders) | 201 | foreach (InventoryFolderBase childFolder in contents.Folders) |
192 | { | 202 | { |
193 | SaveInvFolder(childFolder, path, true); | 203 | SaveInvFolder(childFolder, path, true); |
194 | } | 204 | } |
195 | 205 | ||
196 | foreach (InventoryItemBase item in items) | 206 | foreach (InventoryItemBase item in contents.Items) |
197 | { | 207 | { |
198 | SaveInvItem(item, path); | 208 | SaveInvItem(item, path); |
199 | } | 209 | } |
@@ -204,9 +214,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
204 | /// </summary> | 214 | /// </summary> |
205 | public void Execute() | 215 | public void Execute() |
206 | { | 216 | { |
207 | InventoryFolderImpl inventoryFolder = null; | 217 | InventoryFolderBase inventoryFolder = null; |
208 | InventoryItemBase inventoryItem = null; | 218 | InventoryItemBase inventoryItem = null; |
219 | InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(m_userInfo.UserProfile.ID); | ||
209 | 220 | ||
221 | // XXX: Very temporarily, drop and refetch inventory to make sure we have any newly created items in cache | ||
222 | // This will disappear very soon once we stop using the old cached inventory. | ||
223 | /* | ||
224 | m_userInfo.DropInventory(); | ||
225 | m_userInfo.FetchInventory(); | ||
226 | */ | ||
227 | |||
228 | /* | ||
210 | if (!m_userInfo.HasReceivedInventory) | 229 | if (!m_userInfo.HasReceivedInventory) |
211 | { | 230 | { |
212 | // If the region server has access to the user admin service (by which users are created), | 231 | // If the region server has access to the user admin service (by which users are created), |
@@ -215,7 +234,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
215 | // | 234 | // |
216 | // FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might | 235 | // FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might |
217 | // use a remote inventory service, though this is vanishingly rare at the moment. | 236 | // use a remote inventory service, though this is vanishingly rare at the moment. |
218 | if (null == m_module.CommsManager.UserAdminService) | 237 | if (null == m_scene.CommsManager.UserAdminService) |
219 | { | 238 | { |
220 | m_log.ErrorFormat( | 239 | m_log.ErrorFormat( |
221 | "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1}", | 240 | "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1}", |
@@ -228,11 +247,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
228 | m_userInfo.FetchInventory(); | 247 | m_userInfo.FetchInventory(); |
229 | } | 248 | } |
230 | } | 249 | } |
250 | */ | ||
231 | 251 | ||
232 | bool foundStar = false; | 252 | bool foundStar = false; |
233 | 253 | ||
234 | // Eliminate double slashes and any leading / on the path. This might be better done within InventoryFolderImpl | 254 | // Eliminate double slashes and any leading / on the path. |
235 | // itself (possibly at a small loss in efficiency). | ||
236 | string[] components | 255 | string[] components |
237 | = m_invPath.Split( | 256 | = m_invPath.Split( |
238 | new string[] { InventoryFolderImpl.PATH_DELIMITER }, StringSplitOptions.RemoveEmptyEntries); | 257 | new string[] { InventoryFolderImpl.PATH_DELIMITER }, StringSplitOptions.RemoveEmptyEntries); |
@@ -257,18 +276,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
257 | // Therefore if we still start with a / after the split, then we need the root folder | 276 | // Therefore if we still start with a / after the split, then we need the root folder |
258 | if (m_invPath.Length == 0) | 277 | if (m_invPath.Length == 0) |
259 | { | 278 | { |
260 | inventoryFolder = m_userInfo.RootFolder; | 279 | inventoryFolder = rootFolder; |
261 | } | 280 | } |
262 | else | 281 | else |
263 | { | 282 | { |
264 | m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER)); | 283 | m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER)); |
265 | inventoryFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath); | 284 | inventoryFolder |
285 | = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, rootFolder, m_invPath); | ||
286 | //inventoryFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath); | ||
266 | } | 287 | } |
267 | 288 | ||
268 | // The path may point to an item instead | 289 | // The path may point to an item instead |
269 | if (inventoryFolder == null) | 290 | if (inventoryFolder == null) |
270 | { | 291 | { |
271 | inventoryItem = m_userInfo.RootFolder.FindItemByPath(m_invPath); | 292 | inventoryItem = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, rootFolder, m_invPath); |
293 | //inventoryItem = m_userInfo.RootFolder.FindItemByPath(m_invPath); | ||
272 | } | 294 | } |
273 | 295 | ||
274 | m_archiveWriter = new TarArchiveWriter(m_saveStream); | 296 | m_archiveWriter = new TarArchiveWriter(m_saveStream); |
@@ -306,7 +328,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
306 | SaveUsers(); | 328 | SaveUsers(); |
307 | new AssetsRequest( | 329 | new AssetsRequest( |
308 | new AssetsArchiver(m_archiveWriter), m_assetUuids.Keys, | 330 | new AssetsArchiver(m_archiveWriter), m_assetUuids.Keys, |
309 | m_module.AssetService, ReceivedAllAssets).Execute(); | 331 | m_scene.AssetService, ReceivedAllAssets).Execute(); |
310 | } | 332 | } |
311 | 333 | ||
312 | /// <summary> | 334 | /// <summary> |
@@ -320,7 +342,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
320 | { | 342 | { |
321 | // Record the creator of this item | 343 | // Record the creator of this item |
322 | CachedUserInfo creator | 344 | CachedUserInfo creator |
323 | = m_module.CommsManager.UserProfileCacheService.GetUserDetails(creatorId); | 345 | = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(creatorId); |
324 | 346 | ||
325 | if (creator != null) | 347 | if (creator != null) |
326 | { | 348 | { |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 55d7997..2340fad 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | |||
@@ -51,13 +51,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
51 | public string Name { get { return "Inventory Archiver Module"; } } | 51 | public string Name { get { return "Inventory Archiver Module"; } } |
52 | 52 | ||
53 | public bool IsSharedModule { get { return true; } } | 53 | public bool IsSharedModule { get { return true; } } |
54 | |||
55 | /// <value> | ||
56 | /// Enable or disable checking whether the iar user is actually logged in | ||
57 | /// </value> | ||
58 | public bool DisablePresenceChecks { get; set; } | ||
54 | 59 | ||
55 | public event InventoryArchiveSaved OnInventoryArchiveSaved; | 60 | public event InventoryArchiveSaved OnInventoryArchiveSaved; |
56 | 61 | ||
57 | /// <summary> | 62 | /// <summary> |
58 | /// The file to load and save inventory if no filename has been specified | 63 | /// The file to load and save inventory if no filename has been specified |
59 | /// </summary> | 64 | /// </summary> |
60 | protected const string DEFAULT_INV_BACKUP_FILENAME = "user-inventory_iar.tar.gz"; | 65 | protected const string DEFAULT_INV_BACKUP_FILENAME = "user-inventory.iar"; |
61 | 66 | ||
62 | /// <value> | 67 | /// <value> |
63 | /// Pending save completions initiated from the console | 68 | /// Pending save completions initiated from the console |
@@ -69,19 +74,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
69 | /// </value> | 74 | /// </value> |
70 | private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); | 75 | private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); |
71 | private Scene m_aScene; | 76 | private Scene m_aScene; |
72 | 77 | ||
73 | /// <value> | 78 | public InventoryArchiverModule() {} |
74 | /// The comms manager we will use for all comms requests | 79 | |
75 | /// </value> | 80 | public InventoryArchiverModule(bool disablePresenceChecks) |
76 | protected internal CommunicationsManager CommsManager; | 81 | { |
77 | protected internal IAssetService AssetService; | 82 | DisablePresenceChecks = disablePresenceChecks; |
83 | } | ||
78 | 84 | ||
79 | public void Initialise(Scene scene, IConfigSource source) | 85 | public void Initialise(Scene scene, IConfigSource source) |
80 | { | 86 | { |
81 | if (m_scenes.Count == 0) | 87 | if (m_scenes.Count == 0) |
82 | { | 88 | { |
83 | scene.RegisterModuleInterface<IInventoryArchiverModule>(this); | 89 | scene.RegisterModuleInterface<IInventoryArchiverModule>(this); |
84 | CommsManager = scene.CommsManager; | ||
85 | OnInventoryArchiveSaved += SaveInvConsoleCommandCompleted; | 90 | OnInventoryArchiveSaved += SaveInvConsoleCommandCompleted; |
86 | 91 | ||
87 | scene.AddCommand( | 92 | scene.AddCommand( |
@@ -99,11 +104,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
99 | 104 | ||
100 | m_scenes[scene.RegionInfo.RegionID] = scene; | 105 | m_scenes[scene.RegionInfo.RegionID] = scene; |
101 | } | 106 | } |
102 | 107 | ||
103 | public void PostInitialise() | 108 | public void PostInitialise() {} |
104 | { | ||
105 | AssetService = m_aScene.AssetService; | ||
106 | } | ||
107 | 109 | ||
108 | public void Close() {} | 110 | public void Close() {} |
109 | 111 | ||
@@ -119,29 +121,57 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
119 | handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException); | 121 | handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException); |
120 | } | 122 | } |
121 | 123 | ||
122 | public void ArchiveInventory(Guid id, string firstName, string lastName, string invPath, Stream saveStream) | 124 | public bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, Stream saveStream) |
123 | { | 125 | { |
124 | if (m_scenes.Count > 0) | 126 | if (m_scenes.Count > 0) |
125 | { | 127 | { |
126 | CachedUserInfo userInfo = GetUserInfo(firstName, lastName); | 128 | CachedUserInfo userInfo = GetUserInfo(firstName, lastName); |
127 | 129 | ||
128 | if (userInfo != null) | 130 | if (userInfo != null) |
129 | new InventoryArchiveWriteRequest(id, this, userInfo, invPath, saveStream).Execute(); | 131 | { |
130 | } | 132 | if (CheckPresence(userInfo.UserProfile.ID)) |
133 | { | ||
134 | new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute(); | ||
135 | return true; | ||
136 | } | ||
137 | else | ||
138 | { | ||
139 | m_log.ErrorFormat( | ||
140 | "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator", | ||
141 | userInfo.UserProfile.Name, userInfo.UserProfile.ID); | ||
142 | } | ||
143 | } | ||
144 | } | ||
145 | |||
146 | return false; | ||
131 | } | 147 | } |
132 | 148 | ||
133 | public void ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string savePath) | 149 | public bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string savePath) |
134 | { | 150 | { |
135 | if (m_scenes.Count > 0) | 151 | if (m_scenes.Count > 0) |
136 | { | 152 | { |
137 | CachedUserInfo userInfo = GetUserInfo(firstName, lastName); | 153 | CachedUserInfo userInfo = GetUserInfo(firstName, lastName); |
138 | 154 | ||
139 | if (userInfo != null) | 155 | if (userInfo != null) |
140 | new InventoryArchiveWriteRequest(id, this, userInfo, invPath, savePath).Execute(); | 156 | { |
141 | } | 157 | if (CheckPresence(userInfo.UserProfile.ID)) |
158 | { | ||
159 | new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute(); | ||
160 | return true; | ||
161 | } | ||
162 | else | ||
163 | { | ||
164 | m_log.ErrorFormat( | ||
165 | "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator", | ||
166 | userInfo.UserProfile.Name, userInfo.UserProfile.ID); | ||
167 | } | ||
168 | } | ||
169 | } | ||
170 | |||
171 | return false; | ||
142 | } | 172 | } |
143 | 173 | ||
144 | public void DearchiveInventory(string firstName, string lastName, string invPath, Stream loadStream) | 174 | public bool DearchiveInventory(string firstName, string lastName, string invPath, Stream loadStream) |
145 | { | 175 | { |
146 | if (m_scenes.Count > 0) | 176 | if (m_scenes.Count > 0) |
147 | { | 177 | { |
@@ -149,14 +179,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
149 | 179 | ||
150 | if (userInfo != null) | 180 | if (userInfo != null) |
151 | { | 181 | { |
152 | InventoryArchiveReadRequest request = | 182 | if (CheckPresence(userInfo.UserProfile.ID)) |
153 | new InventoryArchiveReadRequest(userInfo, invPath, loadStream, CommsManager, AssetService); | 183 | { |
154 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); | 184 | InventoryArchiveReadRequest request = |
185 | new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream); | ||
186 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); | ||
187 | |||
188 | return true; | ||
189 | } | ||
190 | else | ||
191 | { | ||
192 | m_log.ErrorFormat( | ||
193 | "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator", | ||
194 | userInfo.UserProfile.Name, userInfo.UserProfile.ID); | ||
195 | } | ||
155 | } | 196 | } |
156 | } | 197 | } |
198 | |||
199 | return false; | ||
157 | } | 200 | } |
158 | 201 | ||
159 | public void DearchiveInventory(string firstName, string lastName, string invPath, string loadPath) | 202 | public bool DearchiveInventory(string firstName, string lastName, string invPath, string loadPath) |
160 | { | 203 | { |
161 | if (m_scenes.Count > 0) | 204 | if (m_scenes.Count > 0) |
162 | { | 205 | { |
@@ -164,11 +207,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
164 | 207 | ||
165 | if (userInfo != null) | 208 | if (userInfo != null) |
166 | { | 209 | { |
167 | InventoryArchiveReadRequest request = | 210 | if (CheckPresence(userInfo.UserProfile.ID)) |
168 | new InventoryArchiveReadRequest(userInfo, invPath, loadPath, CommsManager, AssetService); | 211 | { |
169 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); | 212 | InventoryArchiveReadRequest request = |
170 | } | 213 | new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath); |
171 | } | 214 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); |
215 | |||
216 | return true; | ||
217 | } | ||
218 | else | ||
219 | { | ||
220 | m_log.ErrorFormat( | ||
221 | "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator", | ||
222 | userInfo.UserProfile.Name, userInfo.UserProfile.ID); | ||
223 | } | ||
224 | } | ||
225 | } | ||
226 | |||
227 | return false; | ||
172 | } | 228 | } |
173 | 229 | ||
174 | /// <summary> | 230 | /// <summary> |
@@ -193,11 +249,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
193 | "[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}", | 249 | "[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}", |
194 | loadPath, invPath, firstName, lastName); | 250 | loadPath, invPath, firstName, lastName); |
195 | 251 | ||
196 | DearchiveInventory(firstName, lastName, invPath, loadPath); | 252 | if (DearchiveInventory(firstName, lastName, invPath, loadPath)) |
197 | 253 | m_log.InfoFormat( | |
198 | m_log.InfoFormat( | 254 | "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}", |
199 | "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}", | 255 | loadPath, firstName, lastName); |
200 | loadPath, firstName, lastName); | ||
201 | } | 256 | } |
202 | 257 | ||
203 | /// <summary> | 258 | /// <summary> |
@@ -261,7 +316,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
261 | /// <returns></returns> | 316 | /// <returns></returns> |
262 | protected CachedUserInfo GetUserInfo(string firstName, string lastName) | 317 | protected CachedUserInfo GetUserInfo(string firstName, string lastName) |
263 | { | 318 | { |
264 | CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); | 319 | CachedUserInfo userInfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); |
265 | if (null == userInfo) | 320 | if (null == userInfo) |
266 | { | 321 | { |
267 | m_log.ErrorFormat( | 322 | m_log.ErrorFormat( |
@@ -301,5 +356,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
301 | } | 356 | } |
302 | } | 357 | } |
303 | } | 358 | } |
359 | |||
360 | /// <summary> | ||
361 | /// Check if the given user is present in any of the scenes. | ||
362 | /// </summary> | ||
363 | /// <param name="userId">The user to check</param> | ||
364 | /// <returns>true if the user is in any of the scenes, false otherwise</returns> | ||
365 | protected bool CheckPresence(UUID userId) | ||
366 | { | ||
367 | if (DisablePresenceChecks) | ||
368 | return true; | ||
369 | |||
370 | foreach (Scene scene in m_scenes.Values) | ||
371 | { | ||
372 | if (scene.GetScenePresence(userId) != null) | ||
373 | return true; | ||
374 | } | ||
375 | |||
376 | return false; | ||
377 | } | ||
304 | } | 378 | } |
305 | } | 379 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index a151c9d..d579a81 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -77,13 +77,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
77 | /// </summary> | 77 | /// </summary> |
78 | // Commenting for now! The mock inventory service needs more beef, at least for | 78 | // Commenting for now! The mock inventory service needs more beef, at least for |
79 | // GetFolderForType | 79 | // GetFolderForType |
80 | //[Test] | 80 | [Test] |
81 | public void TestSaveIarV0_1() | 81 | public void TestSaveIarV0_1() |
82 | { | 82 | { |
83 | TestHelper.InMethod(); | 83 | TestHelper.InMethod(); |
84 | log4net.Config.XmlConfigurator.Configure(); | 84 | log4net.Config.XmlConfigurator.Configure(); |
85 | 85 | ||
86 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | 86 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); |
87 | 87 | ||
88 | Scene scene = SceneSetupHelpers.SetupScene("Inventory"); | 88 | Scene scene = SceneSetupHelpers.SetupScene("Inventory"); |
89 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); | 89 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); |
@@ -93,7 +93,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
93 | string userFirstName = "Jock"; | 93 | string userFirstName = "Jock"; |
94 | string userLastName = "Stirrup"; | 94 | string userLastName = "Stirrup"; |
95 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); | 95 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); |
96 | // CachedUserInfo userInfo; | ||
97 | 96 | ||
98 | lock (this) | 97 | lock (this) |
99 | { | 98 | { |
@@ -101,9 +100,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
101 | cm, userFirstName, userLastName, userId, InventoryReceived); | 100 | cm, userFirstName, userLastName, userId, InventoryReceived); |
102 | Monitor.Wait(this, 60000); | 101 | Monitor.Wait(this, 60000); |
103 | } | 102 | } |
104 | 103 | ||
105 | Console.WriteLine("here"); | ||
106 | |||
107 | // Create asset | 104 | // Create asset |
108 | SceneObjectGroup object1; | 105 | SceneObjectGroup object1; |
109 | SceneObjectPart part1; | 106 | SceneObjectPart part1; |
@@ -136,16 +133,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
136 | item1.Name = "My Little Dog"; | 133 | item1.Name = "My Little Dog"; |
137 | item1.AssetID = asset1.FullID; | 134 | item1.AssetID = asset1.FullID; |
138 | item1.ID = item1Id; | 135 | item1.ID = item1Id; |
139 | //userInfo.RootFolder.FindFolderByPath("Objects").ID; | 136 | InventoryFolderBase objsFolder |
140 | //InventoryFolderBase objsFolder = scene.InventoryService.GetFolderForType(userId, AssetType.Object); | 137 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects"); |
141 | Console.WriteLine("here2"); | ||
142 | IInventoryService inventoryService = scene.InventoryService; | ||
143 | InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId); | ||
144 | InventoryCollection rootContents = inventoryService.GetFolderContent(userId, rootFolder.ID); | ||
145 | InventoryFolderBase objsFolder = null; | ||
146 | foreach (InventoryFolderBase folder in rootContents.Folders) | ||
147 | if (folder.Name == "Objects") | ||
148 | objsFolder = folder; | ||
149 | item1.Folder = objsFolder.ID; | 138 | item1.Folder = objsFolder.ID; |
150 | scene.AddInventoryItem(userId, item1); | 139 | scene.AddInventoryItem(userId, item1); |
151 | 140 | ||
@@ -155,7 +144,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
155 | mre.Reset(); | 144 | mre.Reset(); |
156 | archiverModule.ArchiveInventory( | 145 | archiverModule.ArchiveInventory( |
157 | Guid.NewGuid(), userFirstName, userLastName, "Objects", archiveWriteStream); | 146 | Guid.NewGuid(), userFirstName, userLastName, "Objects", archiveWriteStream); |
158 | mre.WaitOne(); | 147 | mre.WaitOne(60000, false); |
159 | 148 | ||
160 | byte[] archive = archiveWriteStream.ToArray(); | 149 | byte[] archive = archiveWriteStream.ToArray(); |
161 | MemoryStream archiveReadStream = new MemoryStream(archive); | 150 | MemoryStream archiveReadStream = new MemoryStream(archive); |
@@ -257,7 +246,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
257 | 246 | ||
258 | MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); | 247 | MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); |
259 | SerialiserModule serialiserModule = new SerialiserModule(); | 248 | SerialiserModule serialiserModule = new SerialiserModule(); |
260 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | 249 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); |
261 | 250 | ||
262 | // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene | 251 | // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene |
263 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | 252 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); |
@@ -275,7 +264,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
275 | CachedUserInfo userInfo | 264 | CachedUserInfo userInfo |
276 | = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); | 265 | = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); |
277 | 266 | ||
278 | InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName); | 267 | InventoryItemBase foundItem |
268 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, itemName); | ||
269 | |||
279 | Assert.That(foundItem, Is.Not.Null, "Didn't find loaded item"); | 270 | Assert.That(foundItem, Is.Not.Null, "Didn't find loaded item"); |
280 | Assert.That( | 271 | Assert.That( |
281 | foundItem.CreatorId, Is.EqualTo(item1.CreatorId), | 272 | foundItem.CreatorId, Is.EqualTo(item1.CreatorId), |
@@ -325,7 +316,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
325 | 316 | ||
326 | MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); | 317 | MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); |
327 | SerialiserModule serialiserModule = new SerialiserModule(); | 318 | SerialiserModule serialiserModule = new SerialiserModule(); |
328 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | 319 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); |
329 | 320 | ||
330 | // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene | 321 | // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene |
331 | Scene scene = SceneSetupHelpers.SetupScene(); | 322 | Scene scene = SceneSetupHelpers.SetupScene(); |
@@ -385,9 +376,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
385 | Monitor.Wait(this, 60000); | 376 | Monitor.Wait(this, 60000); |
386 | } | 377 | } |
387 | 378 | ||
388 | Console.WriteLine("userInfo.RootFolder 1: {0}", userInfo.RootFolder); | 379 | //Console.WriteLine("userInfo.RootFolder 1: {0}", userInfo.RootFolder); |
389 | 380 | ||
390 | Dictionary <string, InventoryFolderImpl> foldersCreated = new Dictionary<string, InventoryFolderImpl>(); | 381 | Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>(); |
391 | List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>(); | 382 | List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>(); |
392 | 383 | ||
393 | string folder1Name = "a"; | 384 | string folder1Name = "a"; |
@@ -405,17 +396,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
405 | "{0}{1}/{2}/{3}", | 396 | "{0}{1}/{2}/{3}", |
406 | ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemName); | 397 | ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemName); |
407 | 398 | ||
408 | Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder); | 399 | //Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder); |
409 | 400 | ||
410 | new InventoryArchiveReadRequest(userInfo, null, (Stream)null, null, null) | 401 | new InventoryArchiveReadRequest(scene, userInfo, null, (Stream)null) |
411 | .ReplicateArchivePathToUserInventory( | 402 | .ReplicateArchivePathToUserInventory( |
412 | itemArchivePath, false, userInfo.RootFolder, foldersCreated, nodesLoaded); | 403 | itemArchivePath, false, scene.InventoryService.GetRootFolder(userInfo.UserProfile.ID), |
404 | foldersCreated, nodesLoaded); | ||
413 | 405 | ||
414 | Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder); | 406 | //Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder); |
415 | InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a"); | 407 | //InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a"); |
408 | InventoryFolderBase folder1 | ||
409 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userInfo.UserProfile.ID, "a"); | ||
416 | Assert.That(folder1, Is.Not.Null, "Could not find folder a"); | 410 | Assert.That(folder1, Is.Not.Null, "Could not find folder a"); |
417 | InventoryFolderImpl folder2 = folder1.FindFolderByPath("b"); | 411 | InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b"); |
418 | Assert.That(folder2, Is.Not.Null, "Could not find folder b"); | 412 | Assert.That(folder2, Is.Not.Null, "Could not find folder b"); |
419 | } | 413 | } |
420 | } | 414 | } |
421 | } | 415 | } \ No newline at end of file |
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 | |||
58 | 58 | ||
59 | public void Initialise(IConfigSource source) | 59 | public void Initialise(IConfigSource source) |
60 | { | 60 | { |
61 | m_log.Info("[ARCHIVER] Initialising"); | 61 | //m_log.Debug("[ARCHIVER] Initialising"); |
62 | } | 62 | } |
63 | 63 | ||
64 | public void AddRegion(Scene scene) | 64 | public void AddRegion(Scene scene) |
65 | { | 65 | { |
66 | m_scene = scene; | 66 | m_scene = scene; |
67 | m_scene.RegisterModuleInterface<IRegionArchiverModule>(this); | 67 | m_scene.RegisterModuleInterface<IRegionArchiverModule>(this); |
68 | m_log.InfoFormat("[ARCHIVER]: Enabled for region {0}", scene.RegionInfo.RegionName); | 68 | //m_log.DebugFormat("[ARCHIVER]: Enabled for region {0}", scene.RegionInfo.RegionName); |
69 | } | 69 | } |
70 | 70 | ||
71 | public void RegionLoaded(Scene scene) | 71 | public void RegionLoaded(Scene scene) |
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 | |||
56 | /// <param name="firstName"></param> | 56 | /// <param name="firstName"></param> |
57 | /// <param name="lastName"></param> | 57 | /// <param name="lastName"></param> |
58 | /// <param name="invPath">The inventory path in which to place the loaded folders and items</param> | 58 | /// <param name="invPath">The inventory path in which to place the loaded folders and items</param> |
59 | /// <param name="loadStream">The stream from which the inventory archive will be loaded</param> | 59 | /// <param name="loadStream">The stream from which the inventory archive will be loaded</param> |
60 | void DearchiveInventory(string firstName, string lastName, string invPath, Stream loadStream); | 60 | /// <returns>true if the first stage of the operation succeeded, false otherwise</returns> |
61 | bool DearchiveInventory(string firstName, string lastName, string invPath, Stream loadStream); | ||
61 | 62 | ||
62 | /// <summary> | 63 | /// <summary> |
63 | /// Archive a user's inventory folder to the given stream | 64 | /// Archive a user's inventory folder to the given stream |
@@ -67,6 +68,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
67 | /// <param name="lastName"></param> | 68 | /// <param name="lastName"></param> |
68 | /// <param name="invPath">The inventory path from which the inventory should be saved.</param> | 69 | /// <param name="invPath">The inventory path from which the inventory should be saved.</param> |
69 | /// <param name="saveStream">The stream to which the inventory archive will be saved</param> | 70 | /// <param name="saveStream">The stream to which the inventory archive will be saved</param> |
70 | void ArchiveInventory(Guid id, string firstName, string lastName, string invPath, Stream saveStream); | 71 | /// <returns>true if the first stage of the operation succeeded, false otherwise</returns> |
72 | bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, Stream saveStream); | ||
71 | } | 73 | } |
72 | } | 74 | } \ No newline at end of file |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 16dd834..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 | |||
476 | // normalize an angle between -PI and PI (-180 to +180 degrees) | 476 | // normalize an angle between -PI and PI (-180 to +180 degrees) |
477 | protected double NormalizeAngle(double angle) | 477 | protected double NormalizeAngle(double angle) |
478 | { | 478 | { |
479 | angle = angle % (Math.PI * 2); | 479 | if (angle > -Math.PI && angle < Math.PI) |
480 | // if (angle < 0) angle = angle + Math.PI * 2; | 480 | return angle; |
481 | return angle; | 481 | |
482 | int numPis = (int)(Math.PI / angle); | ||
483 | double remainder = angle - Math.PI * numPis; | ||
484 | if (numPis % 2 == 1) | ||
485 | return Math.PI - angle; | ||
486 | return remainder; | ||
482 | } | 487 | } |
483 | 488 | ||
484 | // Old implementation of llRot2Euler, now normalized | 489 | // Old implementation of llRot2Euler, now normalized |
@@ -497,9 +502,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
497 | NormalizeAngle(Math.Atan2(n, Math.Sqrt(p))), | 502 | NormalizeAngle(Math.Atan2(n, Math.Sqrt(p))), |
498 | NormalizeAngle(Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s)))); | 503 | NormalizeAngle(Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s)))); |
499 | else if (n > 0) | 504 | else if (n > 0) |
500 | 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))); | 505 | 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))); |
501 | else | 506 | else |
502 | 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))); | 507 | 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))); |
503 | } | 508 | } |
504 | 509 | ||
505 | /* From wiki: | 510 | /* From wiki: |
@@ -553,12 +558,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
553 | 558 | ||
554 | double x,y,z,s; | 559 | double x,y,z,s; |
555 | 560 | ||
556 | double c1 = Math.Cos(v.x/2.0); | 561 | double c1 = Math.Cos(v.x * 0.5); |
557 | double c2 = Math.Cos(v.y/2.0); | 562 | double c2 = Math.Cos(v.y * 0.5); |
558 | double c3 = Math.Cos(v.z/2.0); | 563 | double c3 = Math.Cos(v.z * 0.5); |
559 | double s1 = Math.Sin(v.x/2.0); | 564 | double s1 = Math.Sin(v.x * 0.5); |
560 | double s2 = Math.Sin(v.y/2.0); | 565 | double s2 = Math.Sin(v.y * 0.5); |
561 | double s3 = Math.Sin(v.z/2.0); | 566 | double s3 = Math.Sin(v.z * 0.5); |
562 | 567 | ||
563 | x = s1*c2*c3+c1*s2*s3; | 568 | x = s1*c2*c3+c1*s2*s3; |
564 | y = c1*s2*c3-s1*c2*s3; | 569 | y = c1*s2*c3-s1*c2*s3; |
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 | |||
112 | if (!inits.ContainsKey(api)) | 112 | if (!inits.ContainsKey(api)) |
113 | return; | 113 | return; |
114 | 114 | ||
115 | ILease lease = (ILease)RemotingServices.GetLifetimeService(data as MarshalByRefObject); | 115 | //ILease lease = (ILease)RemotingServices.GetLifetimeService(data as MarshalByRefObject); |
116 | RemotingServices.GetLifetimeService(data as MarshalByRefObject); | ||
116 | // lease.Register(m_sponser); | 117 | // lease.Register(m_sponser); |
117 | 118 | ||
118 | MethodInfo mi = inits[api]; | 119 | MethodInfo mi = inits[api]; |
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 | |||
260 | Path.GetFileNameWithoutExtension(assembly), | 260 | Path.GetFileNameWithoutExtension(assembly), |
261 | "SecondLife.Script"); | 261 | "SecondLife.Script"); |
262 | 262 | ||
263 | ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); | 263 | //ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); |
264 | RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); | ||
264 | // lease.Register(this); | 265 | // lease.Register(this); |
265 | } | 266 | } |
266 | catch (Exception) | 267 | catch (Exception) |
diff --git a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs index ce116f2..daef38b 100644 --- a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs +++ b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs | |||
@@ -84,7 +84,17 @@ namespace OpenSim.Tests.Common.Mock | |||
84 | 84 | ||
85 | public List<InventoryItemBase> getInventoryInFolder(UUID folderID) | 85 | public List<InventoryItemBase> getInventoryInFolder(UUID folderID) |
86 | { | 86 | { |
87 | return new List<InventoryItemBase>(); | 87 | m_log.DebugFormat("[MOCK INV DB]: Getting items in folder {0}", folderID); |
88 | |||
89 | List<InventoryItemBase> items = new List<InventoryItemBase>(); | ||
90 | |||
91 | foreach (InventoryItemBase item in m_items.Values) | ||
92 | { | ||
93 | if (item.Folder == folderID) | ||
94 | items.Add(item); | ||
95 | } | ||
96 | |||
97 | return items; | ||
88 | } | 98 | } |
89 | 99 | ||
90 | public List<InventoryFolderBase> getUserRootFolders(UUID user) { return null; } | 100 | public List<InventoryFolderBase> getUserRootFolders(UUID user) { return null; } |
@@ -154,7 +164,13 @@ namespace OpenSim.Tests.Common.Mock | |||
154 | m_folders.Remove(folderId); | 164 | m_folders.Remove(folderId); |
155 | } | 165 | } |
156 | 166 | ||
157 | public void addInventoryItem(InventoryItemBase item) { m_items[item.ID] = item; } | 167 | public void addInventoryItem(InventoryItemBase item) |
168 | { | ||
169 | m_log.DebugFormat( | ||
170 | "[MOCK INV DB]: Adding inventory item {0} {1} in {2}", item.Name, item.ID, item.Folder); | ||
171 | |||
172 | m_items[item.ID] = item; | ||
173 | } | ||
158 | 174 | ||
159 | public void updateInventoryItem(InventoryItemBase item) { addInventoryItem(item); } | 175 | public void updateInventoryItem(InventoryItemBase item) { addInventoryItem(item); } |
160 | 176 | ||