diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 5de8adc..d794f00 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | |||
@@ -51,32 +51,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
51 | 51 | ||
52 | private CachedUserInfo m_userInfo; | 52 | private CachedUserInfo m_userInfo; |
53 | private string m_invPath; | 53 | private string m_invPath; |
54 | 54 | ||
55 | /// <value> | 55 | /// <value> |
56 | /// The stream from which the inventory archive will be loaded. | 56 | /// The stream from which the inventory archive will be loaded. |
57 | /// </value> | 57 | /// </value> |
58 | private Stream m_loadStream; | 58 | private Stream m_loadStream; |
59 | 59 | ||
60 | CommunicationsManager commsManager; | 60 | CommunicationsManager commsManager; |
61 | 61 | ||
62 | public InventoryArchiveReadRequest( | 62 | public InventoryArchiveReadRequest( |
63 | CachedUserInfo userInfo, string invPath, string loadPath, CommunicationsManager commsManager) | 63 | CachedUserInfo userInfo, string invPath, string loadPath, CommunicationsManager commsManager) |
64 | : this( | 64 | : this( |
65 | userInfo, | 65 | userInfo, |
66 | invPath, | 66 | invPath, |
67 | new GZipStream(new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress), | 67 | new GZipStream(new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress), |
68 | commsManager) | 68 | commsManager) |
69 | { | 69 | { |
70 | } | 70 | } |
71 | 71 | ||
72 | public InventoryArchiveReadRequest( | 72 | public InventoryArchiveReadRequest( |
73 | CachedUserInfo userInfo, string invPath, Stream loadStream, CommunicationsManager commsManager) | 73 | CachedUserInfo userInfo, string invPath, Stream loadStream, CommunicationsManager commsManager) |
74 | { | 74 | { |
75 | m_userInfo = userInfo; | 75 | m_userInfo = userInfo; |
76 | m_invPath = invPath; | 76 | m_invPath = invPath; |
77 | m_loadStream = loadStream; | 77 | m_loadStream = loadStream; |
78 | this.commsManager = commsManager; | 78 | this.commsManager = commsManager; |
79 | } | 79 | } |
80 | 80 | ||
81 | protected InventoryItemBase LoadInvItem(string contents) | 81 | protected InventoryItemBase LoadInvItem(string contents) |
82 | { | 82 | { |
@@ -157,11 +157,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
157 | int failedAssetRestores = 0; | 157 | int failedAssetRestores = 0; |
158 | int successfulItemRestores = 0; | 158 | int successfulItemRestores = 0; |
159 | List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>(); | 159 | List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>(); |
160 | 160 | ||
161 | if (!m_userInfo.HasReceivedInventory) | 161 | if (!m_userInfo.HasReceivedInventory) |
162 | { | 162 | { |
163 | // If the region server has access to the user admin service (by which users are created), | 163 | // If the region server has access to the user admin service (by which users are created), |
164 | // then we'll assume that it's okay to fiddle with the user's inventory even if they are not on the | 164 | // then we'll assume that it's okay to fiddle with the user's inventory even if they are not on the |
165 | // server. | 165 | // server. |
166 | // | 166 | // |
167 | // FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might | 167 | // FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might |
@@ -191,7 +191,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
191 | } | 191 | } |
192 | 192 | ||
193 | archive = new TarArchiveReader(m_loadStream); | 193 | archive = new TarArchiveReader(m_loadStream); |
194 | 194 | ||
195 | // In order to load identically named folders, we need to keep track of the folders that we have already | 195 | // In order to load identically named folders, we need to keep track of the folders that we have already |
196 | // created | 196 | // created |
197 | Dictionary <string, InventoryFolderImpl> foldersCreated = new Dictionary<string, InventoryFolderImpl>(); | 197 | Dictionary <string, InventoryFolderImpl> foldersCreated = new Dictionary<string, InventoryFolderImpl>(); |
@@ -200,18 +200,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
200 | TarArchiveReader.TarEntryType entryType; | 200 | TarArchiveReader.TarEntryType entryType; |
201 | while ((data = archive.ReadEntry(out filePath, out entryType)) != null) | 201 | while ((data = archive.ReadEntry(out filePath, out entryType)) != null) |
202 | { | 202 | { |
203 | if (entryType == TarArchiveReader.TarEntryType.TYPE_DIRECTORY) | 203 | if (entryType == TarArchiveReader.TarEntryType.TYPE_DIRECTORY) |
204 | { | 204 | { |
205 | m_log.WarnFormat("[INVENTORY ARCHIVER]: Ignoring directory entry {0}", filePath); | 205 | m_log.WarnFormat("[INVENTORY ARCHIVER]: Ignoring directory entry {0}", filePath); |
206 | } | 206 | } |
207 | else if (filePath.StartsWith(InventoryArchiveConstants.ASSETS_PATH)) | 207 | else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) |
208 | { | 208 | { |
209 | if (LoadAsset(filePath, data)) | 209 | if (LoadAsset(filePath, data)) |
210 | successfulAssetRestores++; | 210 | successfulAssetRestores++; |
211 | else | 211 | else |
212 | failedAssetRestores++; | 212 | failedAssetRestores++; |
213 | } | 213 | } |
214 | else if (filePath.StartsWith(InventoryArchiveConstants.INVENTORY_PATH)) | 214 | else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) |
215 | { | 215 | { |
216 | InventoryItemBase item = LoadInvItem(m_asciiEncoding.GetString(data)); | 216 | InventoryItemBase item = LoadInvItem(m_asciiEncoding.GetString(data)); |
217 | 217 | ||
@@ -219,16 +219,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
219 | { | 219 | { |
220 | // Don't use the item ID that's in the file | 220 | // Don't use the item ID that's in the file |
221 | item.ID = UUID.Random(); | 221 | item.ID = UUID.Random(); |
222 | 222 | ||
223 | item.Creator = m_userInfo.UserProfile.ID; | 223 | item.Creator = m_userInfo.UserProfile.ID; |
224 | item.Owner = m_userInfo.UserProfile.ID; | 224 | item.Owner = m_userInfo.UserProfile.ID; |
225 | 225 | ||
226 | string fsPath = filePath.Substring(InventoryArchiveConstants.INVENTORY_PATH.Length); | 226 | string fsPath = filePath.Substring(ArchiveConstants.INVENTORY_PATH.Length); |
227 | fsPath = fsPath.Remove(fsPath.LastIndexOf("/") + 1); | 227 | fsPath = fsPath.Remove(fsPath.LastIndexOf("/") + 1); |
228 | string originalFsPath = fsPath; | 228 | string originalFsPath = fsPath; |
229 | 229 | ||
230 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Loading to folder {0}", fsPath); | 230 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Loading to folder {0}", fsPath); |
231 | 231 | ||
232 | InventoryFolderImpl foundFolder = null; | 232 | InventoryFolderImpl foundFolder = null; |
233 | while (null == foundFolder && fsPath.Length > 0) | 233 | while (null == foundFolder && fsPath.Length > 0) |
234 | { | 234 | { |
@@ -241,7 +241,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
241 | { | 241 | { |
242 | // Don't include the last slash | 242 | // Don't include the last slash |
243 | int penultimateSlashIndex = fsPath.LastIndexOf("/", fsPath.Length - 2); | 243 | int penultimateSlashIndex = fsPath.LastIndexOf("/", fsPath.Length - 2); |
244 | 244 | ||
245 | if (penultimateSlashIndex >= 0) | 245 | if (penultimateSlashIndex >= 0) |
246 | { | 246 | { |
247 | fsPath = fsPath.Remove(penultimateSlashIndex + 1); | 247 | fsPath = fsPath.Remove(penultimateSlashIndex + 1); |
@@ -254,42 +254,42 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
254 | fsPath = string.Empty; | 254 | fsPath = string.Empty; |
255 | foundFolder = rootDestinationFolder; | 255 | foundFolder = rootDestinationFolder; |
256 | } | 256 | } |
257 | } | 257 | } |
258 | } | 258 | } |
259 | 259 | ||
260 | string fsPathSectionToCreate = originalFsPath.Substring(fsPath.Length); | 260 | string fsPathSectionToCreate = originalFsPath.Substring(fsPath.Length); |
261 | string[] rawDirsToCreate | 261 | string[] rawDirsToCreate |
262 | = fsPathSectionToCreate.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); | 262 | = fsPathSectionToCreate.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); |
263 | int i = 0; | 263 | int i = 0; |
264 | 264 | ||
265 | while (i < rawDirsToCreate.Length) | 265 | while (i < rawDirsToCreate.Length) |
266 | { | 266 | { |
267 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawDirsToCreate[i]); | 267 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawDirsToCreate[i]); |
268 | 268 | ||
269 | int identicalNameIdentifierIndex | 269 | int identicalNameIdentifierIndex |
270 | = rawDirsToCreate[i].LastIndexOf( | 270 | = rawDirsToCreate[i].LastIndexOf( |
271 | InventoryArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR); | 271 | ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR); |
272 | string folderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex); | 272 | string folderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex); |
273 | 273 | ||
274 | UUID newFolderId = UUID.Random(); | 274 | UUID newFolderId = UUID.Random(); |
275 | m_userInfo.CreateFolder( | 275 | m_userInfo.CreateFolder( |
276 | folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID); | 276 | folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID); |
277 | foundFolder = foundFolder.GetChildFolder(newFolderId); | 277 | foundFolder = foundFolder.GetChildFolder(newFolderId); |
278 | 278 | ||
279 | // Record that we have now created this folder | 279 | // Record that we have now created this folder |
280 | fsPath += rawDirsToCreate[i] + "/"; | 280 | fsPath += rawDirsToCreate[i] + "/"; |
281 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Recording creation of fs path {0}", fsPath); | 281 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Recording creation of fs path {0}", fsPath); |
282 | foldersCreated[fsPath] = foundFolder; | 282 | foldersCreated[fsPath] = foundFolder; |
283 | 283 | ||
284 | if (0 == i) | 284 | if (0 == i) |
285 | nodesLoaded.Add(foundFolder); | 285 | nodesLoaded.Add(foundFolder); |
286 | 286 | ||
287 | i++; | 287 | i++; |
288 | } | 288 | } |
289 | 289 | ||
290 | /* | 290 | /* |
291 | string[] rawFolders = filePath.Split(new char[] { '/' }); | 291 | string[] rawFolders = filePath.Split(new char[] { '/' }); |
292 | 292 | ||
293 | // Find the folders that do exist along the path given | 293 | // Find the folders that do exist along the path given |
294 | int i = 0; | 294 | int i = 0; |
295 | bool noFolder = false; | 295 | bool noFolder = false; |
@@ -306,27 +306,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
306 | else | 306 | else |
307 | { | 307 | { |
308 | noFolder = true; | 308 | noFolder = true; |
309 | } | 309 | } |
310 | } | 310 | } |
311 | 311 | ||
312 | // Create any folders that did not previously exist | 312 | // Create any folders that did not previously exist |
313 | while (i < rawFolders.Length) | 313 | while (i < rawFolders.Length) |
314 | { | 314 | { |
315 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawFolders[i]); | 315 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawFolders[i]); |
316 | 316 | ||
317 | UUID newFolderId = UUID.Random(); | 317 | UUID newFolderId = UUID.Random(); |
318 | m_userInfo.CreateFolder( | 318 | m_userInfo.CreateFolder( |
319 | rawFolders[i++], newFolderId, (ushort)AssetType.Folder, foundFolder.ID); | 319 | rawFolders[i++], newFolderId, (ushort)AssetType.Folder, foundFolder.ID); |
320 | foundFolder = foundFolder.GetChildFolder(newFolderId); | 320 | foundFolder = foundFolder.GetChildFolder(newFolderId); |
321 | } | 321 | } |
322 | */ | 322 | */ |
323 | 323 | ||
324 | // Reset folder ID to the one in which we want to load it | 324 | // Reset folder ID to the one in which we want to load it |
325 | item.Folder = foundFolder.ID; | 325 | item.Folder = foundFolder.ID; |
326 | 326 | ||
327 | m_userInfo.AddItem(item); | 327 | m_userInfo.AddItem(item); |
328 | successfulItemRestores++; | 328 | successfulItemRestores++; |
329 | 329 | ||
330 | // If we're loading an item directly into the given destination folder then we need to record | 330 | // If we're loading an item directly into the given destination folder then we need to record |
331 | // it separately from any loaded root folders | 331 | // it separately from any loaded root folders |
332 | if (rootDestinationFolder == foundFolder) | 332 | if (rootDestinationFolder == foundFolder) |
@@ -339,7 +339,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
339 | 339 | ||
340 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Restored {0} assets", successfulAssetRestores); | 340 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Restored {0} assets", successfulAssetRestores); |
341 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Restored {0} items", successfulItemRestores); | 341 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Restored {0} items", successfulItemRestores); |
342 | 342 | ||
343 | return nodesLoaded; | 343 | return nodesLoaded; |
344 | } | 344 | } |
345 | 345 | ||
@@ -353,14 +353,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
353 | { | 353 | { |
354 | //IRegionSerialiser serialiser = scene.RequestModuleInterface<IRegionSerialiser>(); | 354 | //IRegionSerialiser serialiser = scene.RequestModuleInterface<IRegionSerialiser>(); |
355 | // Right now we're nastily obtaining the UUID from the filename | 355 | // Right now we're nastily obtaining the UUID from the filename |
356 | string filename = assetPath.Remove(0, InventoryArchiveConstants.ASSETS_PATH.Length); | 356 | string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length); |
357 | int i = filename.LastIndexOf(InventoryArchiveConstants.ASSET_EXTENSION_SEPARATOR); | 357 | int i = filename.LastIndexOf(ArchiveConstants.ASSET_EXTENSION_SEPARATOR); |
358 | 358 | ||
359 | if (i == -1) | 359 | if (i == -1) |
360 | { | 360 | { |
361 | m_log.ErrorFormat( | 361 | m_log.ErrorFormat( |
362 | "[INVENTORY ARCHIVER]: Could not find extension information in asset path {0} since it's missing the separator {1}. Skipping", | 362 | "[INVENTORY ARCHIVER]: Could not find extension information in asset path {0} since it's missing the separator {1}. Skipping", |
363 | assetPath, InventoryArchiveConstants.ASSET_EXTENSION_SEPARATOR); | 363 | assetPath, ArchiveConstants.ASSET_EXTENSION_SEPARATOR); |
364 | 364 | ||
365 | return false; | 365 | return false; |
366 | } | 366 | } |
@@ -368,9 +368,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
368 | string extension = filename.Substring(i); | 368 | string extension = filename.Substring(i); |
369 | string uuid = filename.Remove(filename.Length - extension.Length); | 369 | string uuid = filename.Remove(filename.Length - extension.Length); |
370 | 370 | ||
371 | if (InventoryArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension)) | 371 | if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension)) |
372 | { | 372 | { |
373 | sbyte assetType = InventoryArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; | 373 | sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; |
374 | 374 | ||
375 | //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); | 375 | //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); |
376 | 376 | ||