diff options
author | Justin Clark-Casey (justincc) | 2009-09-06 22:07:35 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2009-09-06 22:07:35 +0100 |
commit | 61c286f5d66c4bf44d04c4aac991ba350deb62ea (patch) | |
tree | f982699a8908b82eec2aa8bfaf7d469611e43d80 | |
parent | Add convenience functions to InventoryArchiveUtils for locating folders by as... (diff) | |
download | opensim-SC_OLD-61c286f5d66c4bf44d04c4aac991ba350deb62ea.zip opensim-SC_OLD-61c286f5d66c4bf44d04c4aac991ba350deb62ea.tar.gz opensim-SC_OLD-61c286f5d66c4bf44d04c4aac991ba350deb62ea.tar.bz2 opensim-SC_OLD-61c286f5d66c4bf44d04c4aac991ba350deb62ea.tar.xz |
change iar load to make discrete inventory service requests rather than the cache
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | 65 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | 21 |
2 files changed, 52 insertions, 34 deletions
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 | |||
100 | int successfulItemRestores = 0; | 100 | int successfulItemRestores = 0; |
101 | List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>(); | 101 | List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>(); |
102 | 102 | ||
103 | /* | ||
103 | if (!m_userInfo.HasReceivedInventory) | 104 | if (!m_userInfo.HasReceivedInventory) |
104 | { | 105 | { |
105 | // 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), |
@@ -127,8 +128,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
127 | } | 128 | } |
128 | } | 129 | } |
129 | } | 130 | } |
130 | 131 | */ | |
131 | 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); | ||
132 | 137 | ||
133 | if (null == rootDestinationFolder) | 138 | if (null == rootDestinationFolder) |
134 | { | 139 | { |
@@ -142,7 +147,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
142 | 147 | ||
143 | // 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 |
144 | // created | 149 | // created |
145 | Dictionary <string, InventoryFolderImpl> foldersCreated = new Dictionary<string, InventoryFolderImpl>(); | 150 | Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>(); |
146 | 151 | ||
147 | byte[] data; | 152 | byte[] data; |
148 | TarArchiveReader.TarEntryType entryType; | 153 | TarArchiveReader.TarEntryType entryType; |
@@ -157,7 +162,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
157 | } | 162 | } |
158 | else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) | 163 | else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) |
159 | { | 164 | { |
160 | InventoryFolderImpl foundFolder | 165 | InventoryFolderBase foundFolder |
161 | = ReplicateArchivePathToUserInventory( | 166 | = ReplicateArchivePathToUserInventory( |
162 | filePath, TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType, | 167 | filePath, TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType, |
163 | rootDestinationFolder, foldersCreated, nodesLoaded); | 168 | rootDestinationFolder, foldersCreated, nodesLoaded); |
@@ -178,7 +183,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
178 | // 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 |
179 | item.Folder = foundFolder.ID; | 184 | item.Folder = foundFolder.ID; |
180 | 185 | ||
181 | m_userInfo.AddItem(item); | 186 | //m_userInfo.AddItem(item); |
187 | m_scene.InventoryService.AddItem(item); | ||
182 | successfulItemRestores++; | 188 | successfulItemRestores++; |
183 | 189 | ||
184 | // 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 |
@@ -211,11 +217,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
211 | /// chain, only the root node needs to be recorded | 217 | /// chain, only the root node needs to be recorded |
212 | /// </param> | 218 | /// </param> |
213 | /// <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> |
214 | public InventoryFolderImpl ReplicateArchivePathToUserInventory( | 220 | public InventoryFolderBase ReplicateArchivePathToUserInventory( |
215 | string fsPath, | 221 | string fsPath, |
216 | bool isDir, | 222 | bool isDir, |
217 | InventoryFolderImpl rootDestinationFolder, | 223 | InventoryFolderBase rootDestFolder, |
218 | Dictionary <string, InventoryFolderImpl> foldersCreated, | 224 | Dictionary <string, InventoryFolderBase> foldersCreated, |
219 | List<InventoryNodeBase> nodesLoaded) | 225 | List<InventoryNodeBase> nodesLoaded) |
220 | { | 226 | { |
221 | fsPath = fsPath.Substring(ArchiveConstants.INVENTORY_PATH.Length); | 227 | fsPath = fsPath.Substring(ArchiveConstants.INVENTORY_PATH.Length); |
@@ -228,17 +234,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
228 | 234 | ||
229 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Loading to folder {0}", fsPath); | 235 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Loading to folder {0}", fsPath); |
230 | 236 | ||
231 | InventoryFolderImpl foundFolder = null; | 237 | InventoryFolderBase destFolder = null; |
232 | 238 | ||
233 | // 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 |
234 | if (fsPath.Length > 0) | 240 | if (fsPath.Length > 0) |
235 | { | 241 | { |
236 | while (null == foundFolder && fsPath.Length > 0) | 242 | while (null == destFolder && fsPath.Length > 0) |
237 | { | 243 | { |
238 | if (foldersCreated.ContainsKey(fsPath)) | 244 | if (foldersCreated.ContainsKey(fsPath)) |
239 | { | 245 | { |
240 | 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); |
241 | foundFolder = foldersCreated[fsPath]; | 247 | destFolder = foldersCreated[fsPath]; |
242 | } | 248 | } |
243 | else | 249 | else |
244 | { | 250 | { |
@@ -255,14 +261,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
255 | "[INVENTORY ARCHIVER]: Found no previously created fs path for {0}", | 261 | "[INVENTORY ARCHIVER]: Found no previously created fs path for {0}", |
256 | originalFsPath); | 262 | originalFsPath); |
257 | fsPath = string.Empty; | 263 | fsPath = string.Empty; |
258 | foundFolder = rootDestinationFolder; | 264 | destFolder = rootDestFolder; |
259 | } | 265 | } |
260 | } | 266 | } |
261 | } | 267 | } |
262 | } | 268 | } |
263 | else | 269 | else |
264 | { | 270 | { |
265 | foundFolder = rootDestinationFolder; | 271 | destFolder = rootDestFolder; |
266 | } | 272 | } |
267 | 273 | ||
268 | string fsPathSectionToCreate = originalFsPath.Substring(fsPath.Length); | 274 | string fsPathSectionToCreate = originalFsPath.Substring(fsPath.Length); |
@@ -277,30 +283,39 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
277 | int identicalNameIdentifierIndex | 283 | int identicalNameIdentifierIndex |
278 | = rawDirsToCreate[i].LastIndexOf( | 284 | = rawDirsToCreate[i].LastIndexOf( |
279 | ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR); | 285 | ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR); |
280 | string folderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex); | ||
281 | 286 | ||
287 | string newFolderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex); | ||
282 | UUID newFolderId = UUID.Random(); | 288 | UUID newFolderId = UUID.Random(); |
283 | m_userInfo.CreateFolder( | 289 | |
284 | folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID); | 290 | destFolder |
285 | 291 | = new InventoryFolderBase( | |
286 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Retrieving newly created folder {0}", folderName); | 292 | newFolderId, newFolderName, m_userInfo.UserProfile.ID, |
287 | foundFolder = foundFolder.GetChildFolder(newFolderId); | 293 | (short)AssetType.Folder, destFolder.ID, 0); |
288 | m_log.DebugFormat( | 294 | m_scene.InventoryService.AddFolder(destFolder); |
289 | "[INVENTORY ARCHIVER]: Retrieved newly created folder {0} with ID {1}", | 295 | |
290 | 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); | ||
291 | 306 | ||
292 | // Record that we have now created this folder | 307 | // Record that we have now created this folder |
293 | fsPath += rawDirsToCreate[i] + "/"; | 308 | fsPath += rawDirsToCreate[i] + "/"; |
294 | 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); |
295 | foldersCreated[fsPath] = foundFolder; | 310 | foldersCreated[fsPath] = destFolder; |
296 | 311 | ||
297 | if (0 == i) | 312 | if (0 == i) |
298 | nodesLoaded.Add(foundFolder); | 313 | nodesLoaded.Add(destFolder); |
299 | 314 | ||
300 | i++; | 315 | i++; |
301 | } | 316 | } |
302 | 317 | ||
303 | return foundFolder; | 318 | return destFolder; |
304 | 319 | ||
305 | /* | 320 | /* |
306 | string[] rawFolders = filePath.Split(new char[] { '/' }); | 321 | 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 | |||
267 | = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); | 267 | = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); |
268 | 268 | ||
269 | InventoryItemBase foundItem | 269 | InventoryItemBase foundItem |
270 | = InventoryArchiveUtils.FindItemByPath( scene.InventoryService, userInfo.UserProfile.ID, itemName); | 270 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, itemName); |
271 | 271 | ||
272 | Assert.That(foundItem, Is.Not.Null, "Didn't find loaded item"); | 272 | Assert.That(foundItem, Is.Not.Null, "Didn't find loaded item"); |
273 | Assert.That( | 273 | Assert.That( |
@@ -378,9 +378,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
378 | Monitor.Wait(this, 60000); | 378 | Monitor.Wait(this, 60000); |
379 | } | 379 | } |
380 | 380 | ||
381 | Console.WriteLine("userInfo.RootFolder 1: {0}", userInfo.RootFolder); | 381 | //Console.WriteLine("userInfo.RootFolder 1: {0}", userInfo.RootFolder); |
382 | 382 | ||
383 | Dictionary <string, InventoryFolderImpl> foldersCreated = new Dictionary<string, InventoryFolderImpl>(); | 383 | Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>(); |
384 | List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>(); | 384 | List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>(); |
385 | 385 | ||
386 | string folder1Name = "a"; | 386 | string folder1Name = "a"; |
@@ -398,17 +398,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
398 | "{0}{1}/{2}/{3}", | 398 | "{0}{1}/{2}/{3}", |
399 | ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemName); | 399 | ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemName); |
400 | 400 | ||
401 | Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder); | 401 | //Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder); |
402 | 402 | ||
403 | new InventoryArchiveReadRequest(scene, userInfo, null, (Stream)null) | 403 | new InventoryArchiveReadRequest(scene, userInfo, null, (Stream)null) |
404 | .ReplicateArchivePathToUserInventory( | 404 | .ReplicateArchivePathToUserInventory( |
405 | itemArchivePath, false, userInfo.RootFolder, foldersCreated, nodesLoaded); | 405 | itemArchivePath, false, scene.InventoryService.GetRootFolder(userInfo.UserProfile.ID), |
406 | foldersCreated, nodesLoaded); | ||
406 | 407 | ||
407 | Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder); | 408 | //Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder); |
408 | InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a"); | 409 | //InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a"); |
410 | InventoryFolderBase folder1 | ||
411 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userInfo.UserProfile.ID, "a"); | ||
409 | Assert.That(folder1, Is.Not.Null, "Could not find folder a"); | 412 | Assert.That(folder1, Is.Not.Null, "Could not find folder a"); |
410 | InventoryFolderImpl folder2 = folder1.FindFolderByPath("b"); | 413 | InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b"); |
411 | Assert.That(folder2, Is.Not.Null, "Could not find folder b"); | 414 | Assert.That(folder2, Is.Not.Null, "Could not find folder b"); |
412 | } | 415 | } |
413 | } | 416 | } |
414 | } | 417 | } \ No newline at end of file |