diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | 91 |
1 files changed, 54 insertions, 37 deletions
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 | } |