diff options
author | Diva Canto | 2013-07-05 20:17:10 -0700 |
---|---|---|
committer | Diva Canto | 2013-07-05 20:17:10 -0700 |
commit | c358d5d168f349cbfbb10c1c4f1e992830b11fa4 (patch) | |
tree | 90cb5b5a085676e325d899fdf6236eb4fe41ba7e /OpenSim | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-c358d5d168f349cbfbb10c1c4f1e992830b11fa4.zip opensim-SC_OLD-c358d5d168f349cbfbb10c1c4f1e992830b11fa4.tar.gz opensim-SC_OLD-c358d5d168f349cbfbb10c1c4f1e992830b11fa4.tar.bz2 opensim-SC_OLD-c358d5d168f349cbfbb10c1c4f1e992830b11fa4.tar.xz |
Changed a few bits in Inventory/Archiver/InventoryArchiveReadRequest.cs to be less dependent on a Scene.
Diffstat (limited to 'OpenSim')
5 files changed, 29 insertions, 25 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 98285e9..31c42d8 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | |||
@@ -67,10 +67,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
67 | /// </summary> | 67 | /// </summary> |
68 | protected bool m_merge; | 68 | protected bool m_merge; |
69 | 69 | ||
70 | /// <value> | 70 | protected IInventoryService m_InventoryService; |
71 | /// We only use this to request modules | 71 | protected IAssetService m_AssetService; |
72 | /// </value> | 72 | protected IUserAccountService m_UserAccountService; |
73 | protected Scene m_scene; | ||
74 | 73 | ||
75 | /// <value> | 74 | /// <value> |
76 | /// The stream from which the inventory archive will be loaded. | 75 | /// The stream from which the inventory archive will be loaded. |
@@ -118,9 +117,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
118 | protected Dictionary<UUID, UUID> m_creatorIdForAssetId = new Dictionary<UUID, UUID>(); | 117 | protected Dictionary<UUID, UUID> m_creatorIdForAssetId = new Dictionary<UUID, UUID>(); |
119 | 118 | ||
120 | public InventoryArchiveReadRequest( | 119 | public InventoryArchiveReadRequest( |
121 | Scene scene, UserAccount userInfo, string invPath, string loadPath, bool merge) | 120 | IInventoryService inv, IAssetService assets, IUserAccountService uacc, UserAccount userInfo, string invPath, string loadPath, bool merge) |
122 | : this( | 121 | : this( |
123 | scene, | 122 | inv, |
123 | assets, | ||
124 | uacc, | ||
124 | userInfo, | 125 | userInfo, |
125 | invPath, | 126 | invPath, |
126 | new GZipStream(ArchiveHelpers.GetStream(loadPath), CompressionMode.Decompress), | 127 | new GZipStream(ArchiveHelpers.GetStream(loadPath), CompressionMode.Decompress), |
@@ -129,9 +130,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
129 | } | 130 | } |
130 | 131 | ||
131 | public InventoryArchiveReadRequest( | 132 | public InventoryArchiveReadRequest( |
132 | Scene scene, UserAccount userInfo, string invPath, Stream loadStream, bool merge) | 133 | IInventoryService inv, IAssetService assets, IUserAccountService uacc, UserAccount userInfo, string invPath, Stream loadStream, bool merge) |
133 | { | 134 | { |
134 | m_scene = scene; | 135 | m_InventoryService = inv; |
136 | m_AssetService = assets; | ||
137 | m_UserAccountService = uacc; | ||
135 | m_merge = merge; | 138 | m_merge = merge; |
136 | m_userInfo = userInfo; | 139 | m_userInfo = userInfo; |
137 | m_invPath = invPath; | 140 | m_invPath = invPath; |
@@ -162,7 +165,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
162 | 165 | ||
163 | List<InventoryFolderBase> folderCandidates | 166 | List<InventoryFolderBase> folderCandidates |
164 | = InventoryArchiveUtils.FindFoldersByPath( | 167 | = InventoryArchiveUtils.FindFoldersByPath( |
165 | m_scene.InventoryService, m_userInfo.PrincipalID, m_invPath); | 168 | m_InventoryService, m_userInfo.PrincipalID, m_invPath); |
166 | 169 | ||
167 | if (folderCandidates.Count == 0) | 170 | if (folderCandidates.Count == 0) |
168 | { | 171 | { |
@@ -297,7 +300,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
297 | string plainPath = ArchiveConstants.ExtractPlainPathFromIarPath(archivePath); | 300 | string plainPath = ArchiveConstants.ExtractPlainPathFromIarPath(archivePath); |
298 | List<InventoryFolderBase> folderCandidates | 301 | List<InventoryFolderBase> folderCandidates |
299 | = InventoryArchiveUtils.FindFoldersByPath( | 302 | = InventoryArchiveUtils.FindFoldersByPath( |
300 | m_scene.InventoryService, m_userInfo.PrincipalID, plainPath); | 303 | m_InventoryService, m_userInfo.PrincipalID, plainPath); |
301 | 304 | ||
302 | if (folderCandidates.Count != 0) | 305 | if (folderCandidates.Count != 0) |
303 | { | 306 | { |
@@ -380,7 +383,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
380 | = new InventoryFolderBase( | 383 | = new InventoryFolderBase( |
381 | newFolderId, newFolderName, m_userInfo.PrincipalID, | 384 | newFolderId, newFolderName, m_userInfo.PrincipalID, |
382 | (short)AssetType.Unknown, destFolder.ID, 1); | 385 | (short)AssetType.Unknown, destFolder.ID, 1); |
383 | m_scene.InventoryService.AddFolder(destFolder); | 386 | m_InventoryService.AddFolder(destFolder); |
384 | 387 | ||
385 | // Record that we have now created this folder | 388 | // Record that we have now created this folder |
386 | iarPathExisting += rawDirsToCreate[i] + "/"; | 389 | iarPathExisting += rawDirsToCreate[i] + "/"; |
@@ -406,7 +409,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
406 | // Don't use the item ID that's in the file | 409 | // Don't use the item ID that's in the file |
407 | item.ID = UUID.Random(); | 410 | item.ID = UUID.Random(); |
408 | 411 | ||
409 | UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.UserAccountService); | 412 | UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_UserAccountService); |
410 | if (UUID.Zero != ospResolvedId) // The user exists in this grid | 413 | if (UUID.Zero != ospResolvedId) // The user exists in this grid |
411 | { | 414 | { |
412 | // m_log.DebugFormat("[INVENTORY ARCHIVER]: Found creator {0} via OSPA resolution", ospResolvedId); | 415 | // m_log.DebugFormat("[INVENTORY ARCHIVER]: Found creator {0} via OSPA resolution", ospResolvedId); |
@@ -436,7 +439,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
436 | // relying on native tar tools. | 439 | // relying on native tar tools. |
437 | m_creatorIdForAssetId[item.AssetID] = item.CreatorIdAsUuid; | 440 | m_creatorIdForAssetId[item.AssetID] = item.CreatorIdAsUuid; |
438 | 441 | ||
439 | m_scene.AddInventoryItem(item); | 442 | if (!m_InventoryService.AddItem(item)) |
443 | m_log.WarnFormat("[INVENTORY ARCHIVER]: Unable to save item {0} in folder {1}", item.Name, item.Folder); | ||
440 | 444 | ||
441 | return item; | 445 | return item; |
442 | } | 446 | } |
@@ -533,7 +537,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
533 | AssetBase asset = new AssetBase(assetId, "From IAR", assetType, UUID.Zero.ToString()); | 537 | AssetBase asset = new AssetBase(assetId, "From IAR", assetType, UUID.Zero.ToString()); |
534 | asset.Data = data; | 538 | asset.Data = data; |
535 | 539 | ||
536 | m_scene.AssetService.Store(asset); | 540 | m_AssetService.Store(asset); |
537 | 541 | ||
538 | return true; | 542 | return true; |
539 | } | 543 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 849449b..797097f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | |||
@@ -294,7 +294,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
294 | 294 | ||
295 | try | 295 | try |
296 | { | 296 | { |
297 | request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream, merge); | 297 | request = new InventoryArchiveReadRequest(m_aScene.InventoryService, m_aScene.AssetService, m_aScene.UserAccountService, userInfo, invPath, loadStream, merge); |
298 | } | 298 | } |
299 | catch (EntryPointNotFoundException e) | 299 | catch (EntryPointNotFoundException e) |
300 | { | 300 | { |
@@ -342,7 +342,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
342 | 342 | ||
343 | try | 343 | try |
344 | { | 344 | { |
345 | request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath, merge); | 345 | request = new InventoryArchiveReadRequest(m_aScene.InventoryService, m_aScene.AssetService, m_aScene.UserAccountService, userInfo, invPath, loadPath, merge); |
346 | } | 346 | } |
347 | catch (EntryPointNotFoundException e) | 347 | catch (EntryPointNotFoundException e) |
348 | { | 348 | { |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveLoadPathTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveLoadPathTests.cs index 95f562e..08f199a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveLoadPathTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveLoadPathTests.cs | |||
@@ -229,7 +229,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
229 | 229 | ||
230 | { | 230 | { |
231 | // Test replication of path1 | 231 | // Test replication of path1 |
232 | new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false) | 232 | new InventoryArchiveReadRequest(scene.InventoryService, scene.AssetService, scene.UserAccountService, ua1, null, (Stream)null, false) |
233 | .ReplicateArchivePathToUserInventory( | 233 | .ReplicateArchivePathToUserInventory( |
234 | iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID), | 234 | iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID), |
235 | foldersCreated, nodesLoaded); | 235 | foldersCreated, nodesLoaded); |
@@ -246,7 +246,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
246 | 246 | ||
247 | { | 247 | { |
248 | // Test replication of path2 | 248 | // Test replication of path2 |
249 | new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false) | 249 | new InventoryArchiveReadRequest(scene.InventoryService, scene.AssetService, scene.UserAccountService, ua1, null, (Stream)null, false) |
250 | .ReplicateArchivePathToUserInventory( | 250 | .ReplicateArchivePathToUserInventory( |
251 | iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID), | 251 | iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID), |
252 | foldersCreated, nodesLoaded); | 252 | foldersCreated, nodesLoaded); |
@@ -291,8 +291,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
291 | string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); | 291 | string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); |
292 | 292 | ||
293 | string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName }); | 293 | string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName }); |
294 | 294 | ||
295 | new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false) | 295 | new InventoryArchiveReadRequest(scene.InventoryService, scene.AssetService, scene.UserAccountService, ua1, null, (Stream)null, false) |
296 | .ReplicateArchivePathToUserInventory( | 296 | .ReplicateArchivePathToUserInventory( |
297 | itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), | 297 | itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), |
298 | new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>()); | 298 | new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>()); |
@@ -342,8 +342,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
342 | string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); | 342 | string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); |
343 | 343 | ||
344 | string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName }); | 344 | string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName }); |
345 | 345 | ||
346 | new InventoryArchiveReadRequest(scene, ua1, folder1ExistingName, (Stream)null, true) | 346 | new InventoryArchiveReadRequest(scene.InventoryService, scene.AssetService, scene.UserAccountService, ua1, folder1ExistingName, (Stream)null, true) |
347 | .ReplicateArchivePathToUserInventory( | 347 | .ReplicateArchivePathToUserInventory( |
348 | itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), | 348 | itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), |
349 | new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>()); | 349 | new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>()); |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveSaveTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveSaveTests.cs index 5e7e24c..b85739e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveSaveTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveSaveTests.cs | |||
@@ -86,7 +86,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
86 | Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH)); | 86 | Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH)); |
87 | 87 | ||
88 | InventoryArchiveReadRequest iarr | 88 | InventoryArchiveReadRequest iarr |
89 | = new InventoryArchiveReadRequest(null, null, null, (Stream)null, false); | 89 | = new InventoryArchiveReadRequest(null, null, null, null, null, (Stream)null, false); |
90 | iarr.LoadControlFile(filePath, data); | 90 | iarr.LoadControlFile(filePath, data); |
91 | 91 | ||
92 | Assert.That(iarr.ControlFileLoaded, Is.True); | 92 | Assert.That(iarr.ControlFileLoaded, Is.True); |
diff --git a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs index d07cff4..69d7e16 100644 --- a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs | |||
@@ -176,7 +176,7 @@ namespace OpenSim.Region.CoreModules.Framework.Library | |||
176 | m_log.InfoFormat("[LIBRARY MODULE]: Loading library archive {0} ({1})...", iarFileName, simpleName); | 176 | m_log.InfoFormat("[LIBRARY MODULE]: Loading library archive {0} ({1})...", iarFileName, simpleName); |
177 | simpleName = GetInventoryPathFromName(simpleName); | 177 | simpleName = GetInventoryPathFromName(simpleName); |
178 | 178 | ||
179 | InventoryArchiveReadRequest archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, simpleName, iarFileName, false); | 179 | InventoryArchiveReadRequest archread = new InventoryArchiveReadRequest(m_MockScene.InventoryService, m_MockScene.AssetService, m_MockScene.UserAccountService, uinfo, simpleName, iarFileName, false); |
180 | try | 180 | try |
181 | { | 181 | { |
182 | HashSet<InventoryNodeBase> nodes = archread.Execute(); | 182 | HashSet<InventoryNodeBase> nodes = archread.Execute(); |
@@ -185,7 +185,7 @@ namespace OpenSim.Region.CoreModules.Framework.Library | |||
185 | // didn't find the subfolder with the given name; place it on the top | 185 | // didn't find the subfolder with the given name; place it on the top |
186 | m_log.InfoFormat("[LIBRARY MODULE]: Didn't find {0} in library. Placing archive on the top level", simpleName); | 186 | m_log.InfoFormat("[LIBRARY MODULE]: Didn't find {0} in library. Placing archive on the top level", simpleName); |
187 | archread.Close(); | 187 | archread.Close(); |
188 | archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, "/", iarFileName, false); | 188 | archread = new InventoryArchiveReadRequest(m_MockScene.InventoryService, m_MockScene.AssetService, m_MockScene.UserAccountService, uinfo, "/", iarFileName, false); |
189 | archread.Execute(); | 189 | archread.Execute(); |
190 | } | 190 | } |
191 | 191 | ||