aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-08-04 20:56:52 +0100
committerJustin Clark-Casey (justincc)2010-08-04 20:56:52 +0100
commita133acbd5fc1a402796dfeb014ade20db77d4824 (patch)
tree7aae3a2c1eabc0d17f917800e735cc88e8631e72 /OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
parentBetter debug messages (diff)
parentAdd --merge switch to load iar. (diff)
downloadopensim-SC_OLD-a133acbd5fc1a402796dfeb014ade20db77d4824.zip
opensim-SC_OLD-a133acbd5fc1a402796dfeb014ade20db77d4824.tar.gz
opensim-SC_OLD-a133acbd5fc1a402796dfeb014ade20db77d4824.tar.bz2
opensim-SC_OLD-a133acbd5fc1a402796dfeb014ade20db77d4824.tar.xz
Merge branch 'iar-merge'
Conflicts: OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs110
1 files changed, 61 insertions, 49 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 31dfe14..7683288 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -54,6 +54,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
54 54
55 private UserAccount m_userInfo; 55 private UserAccount m_userInfo;
56 private string m_invPath; 56 private string m_invPath;
57
58 /// <summary>
59 /// Do we want to merge this load with existing inventory?
60 /// </summary>
61 protected bool m_merge;
57 62
58 /// <value> 63 /// <value>
59 /// We only use this to request modules 64 /// We only use this to request modules
@@ -66,19 +71,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
66 private Stream m_loadStream; 71 private Stream m_loadStream;
67 72
68 public InventoryArchiveReadRequest( 73 public InventoryArchiveReadRequest(
69 Scene scene, UserAccount userInfo, string invPath, string loadPath) 74 Scene scene, UserAccount userInfo, string invPath, string loadPath, bool merge)
70 : this( 75 : this(
71 scene, 76 scene,
72 userInfo, 77 userInfo,
73 invPath, 78 invPath,
74 new GZipStream(ArchiveHelpers.GetStream(loadPath), CompressionMode.Decompress)) 79 new GZipStream(ArchiveHelpers.GetStream(loadPath), CompressionMode.Decompress),
80 merge)
75 { 81 {
76 } 82 }
77 83
78 public InventoryArchiveReadRequest( 84 public InventoryArchiveReadRequest(
79 Scene scene, UserAccount userInfo, string invPath, Stream loadStream) 85 Scene scene, UserAccount userInfo, string invPath, Stream loadStream, bool merge)
80 { 86 {
81 m_scene = scene; 87 m_scene = scene;
88 m_merge = merge;
82 m_userInfo = userInfo; 89 m_userInfo = userInfo;
83 m_invPath = invPath; 90 m_invPath = invPath;
84 m_loadStream = loadStream; 91 m_loadStream = loadStream;
@@ -91,7 +98,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
91 /// A list of the inventory nodes loaded. If folders were loaded then only the root folders are 98 /// A list of the inventory nodes loaded. If folders were loaded then only the root folders are
92 /// returned 99 /// returned
93 /// </returns> 100 /// </returns>
94 public List<InventoryNodeBase> Execute() 101 public HashSet<InventoryNodeBase> Execute()
95 { 102 {
96 try 103 try
97 { 104 {
@@ -100,7 +107,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
100 int failedAssetRestores = 0; 107 int failedAssetRestores = 0;
101 int successfulItemRestores = 0; 108 int successfulItemRestores = 0;
102 109
103 List<InventoryNodeBase> loadedNodes = new List<InventoryNodeBase>(); 110 HashSet<InventoryNodeBase> loadedNodes = new HashSet<InventoryNodeBase>();
104 111
105 List<InventoryFolderBase> folderCandidates 112 List<InventoryFolderBase> folderCandidates
106 = InventoryArchiveUtils.FindFolderByPath( 113 = InventoryArchiveUtils.FindFolderByPath(
@@ -158,9 +165,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
158 { 165 {
159 successfulItemRestores++; 166 successfulItemRestores++;
160 167
161 // If we're loading an item directly into the given destination folder then we need to record 168 // If we aren't loading the folder containing the item then well need to update the
162 // it separately from any loaded root folders 169 // viewer separately for that item.
163 if (rootDestinationFolder == foundFolder) 170 if (!loadedNodes.Contains(foundFolder))
164 loadedNodes.Add(item); 171 loadedNodes.Add(item);
165 } 172 }
166 } 173 }
@@ -205,14 +212,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
205 string iarPath, 212 string iarPath,
206 InventoryFolderBase rootDestFolder, 213 InventoryFolderBase rootDestFolder,
207 Dictionary <string, InventoryFolderBase> resolvedFolders, 214 Dictionary <string, InventoryFolderBase> resolvedFolders,
208 List<InventoryNodeBase> loadedNodes) 215 HashSet<InventoryNodeBase> loadedNodes)
209 { 216 {
210 string iarPathExisting = iarPath; 217 string iarPathExisting = iarPath;
211 218
212// m_log.DebugFormat( 219// m_log.DebugFormat(
213// "[INVENTORY ARCHIVER]: Loading folder {0} {1}", rootDestFolder.Name, rootDestFolder.ID); 220// "[INVENTORY ARCHIVER]: Loading folder {0} {1}", rootDestFolder.Name, rootDestFolder.ID);
214 221
215 InventoryFolderBase destFolder = ResolveDestinationFolder(rootDestFolder, ref iarPathExisting, resolvedFolders); 222 InventoryFolderBase destFolder
223 = ResolveDestinationFolder(rootDestFolder, ref iarPathExisting, resolvedFolders);
216 224
217// m_log.DebugFormat( 225// m_log.DebugFormat(
218// "[INVENTORY ARCHIVER]: originalArchivePath [{0}], section already loaded [{1}]", 226// "[INVENTORY ARCHIVER]: originalArchivePath [{0}], section already loaded [{1}]",
@@ -251,46 +259,55 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
251 { 259 {
252// string originalArchivePath = archivePath; 260// string originalArchivePath = archivePath;
253 261
254 InventoryFolderBase destFolder = null; 262 while (archivePath.Length > 0)
255
256 if (archivePath.Length > 0)
257 { 263 {
258 while (null == destFolder && archivePath.Length > 0) 264 m_log.DebugFormat("[INVENTORY ARCHIVER]: Trying to resolve destination folder {0}", archivePath);
265
266 if (resolvedFolders.ContainsKey(archivePath))
267 {
268// m_log.DebugFormat(
269// "[INVENTORY ARCHIVER]: Found previously created folder from archive path {0}", archivePath);
270 return resolvedFolders[archivePath];
271 }
272 else
259 { 273 {
260// m_log.DebugFormat("[INVENTORY ARCHIVER]: Trying to resolve destination folder {0}", archivePath); 274 if (m_merge)
275 {
276 // TODO: Using m_invPath is totally wrong - what we need to do is strip the uuid from the
277 // iar name and try to find that instead.
278 string plainPath = ArchiveConstants.ExtractPlainPathFromIarPath(archivePath);
279 List<InventoryFolderBase> folderCandidates
280 = InventoryArchiveUtils.FindFolderByPath(
281 m_scene.InventoryService, m_userInfo.PrincipalID, plainPath);
282
283 if (folderCandidates.Count != 0)
284 {
285 InventoryFolderBase destFolder = folderCandidates[0];
286 resolvedFolders[archivePath] = destFolder;
287 return destFolder;
288 }
289 }
261 290
262 if (resolvedFolders.ContainsKey(archivePath)) 291 // Don't include the last slash so find the penultimate one
292 int penultimateSlashIndex = archivePath.LastIndexOf("/", archivePath.Length - 2);
293
294 if (penultimateSlashIndex >= 0)
263 { 295 {
264// m_log.DebugFormat( 296 // Remove the last section of path so that we can see if we've already resolved the parent
265// "[INVENTORY ARCHIVER]: Found previously created folder from archive path {0}", archivePath); 297 archivePath = archivePath.Remove(penultimateSlashIndex + 1);
266 destFolder = resolvedFolders[archivePath];
267 } 298 }
268 else 299 else
269 { 300 {
270 // Don't include the last slash so find the penultimate one 301// m_log.DebugFormat(
271 int penultimateSlashIndex = archivePath.LastIndexOf("/", archivePath.Length - 2); 302// "[INVENTORY ARCHIVER]: Found no previously created folder for archive path {0}",
272 303// originalArchivePath);
273 if (penultimateSlashIndex >= 0) 304 archivePath = string.Empty;
274 { 305 return rootDestFolder;
275 // Remove the last section of path so that we can see if we've already resolved the parent
276 archivePath = archivePath.Remove(penultimateSlashIndex + 1);
277 }
278 else
279 {
280// m_log.DebugFormat(
281// "[INVENTORY ARCHIVER]: Found no previously created folder for archive path {0}",
282// originalArchivePath);
283 archivePath = string.Empty;
284 destFolder = rootDestFolder;
285 }
286 } 306 }
287 } 307 }
288 } 308 }
289 309
290 if (null == destFolder) 310 return rootDestFolder;
291 destFolder = rootDestFolder;
292
293 return destFolder;
294 } 311 }
295 312
296 /// <summary> 313 /// <summary>
@@ -316,24 +333,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
316 string iarPathExisting, 333 string iarPathExisting,
317 string iarPathToReplicate, 334 string iarPathToReplicate,
318 Dictionary <string, InventoryFolderBase> resolvedFolders, 335 Dictionary <string, InventoryFolderBase> resolvedFolders,
319 List<InventoryNodeBase> loadedNodes) 336 HashSet<InventoryNodeBase> loadedNodes)
320 { 337 {
321 string[] rawDirsToCreate = iarPathToReplicate.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); 338 string[] rawDirsToCreate = iarPathToReplicate.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
322 int i = 0;
323 339
324 while (i < rawDirsToCreate.Length) 340 for (int i = 0; i < rawDirsToCreate.Length; i++)
325 { 341 {
326// m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0} from IAR", rawDirsToCreate[i]); 342// m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0} from IAR", rawDirsToCreate[i]);
327 343
344 if (!rawDirsToCreate[i].Contains(ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR))
345 continue;
346
328 int identicalNameIdentifierIndex 347 int identicalNameIdentifierIndex
329 = rawDirsToCreate[i].LastIndexOf( 348 = rawDirsToCreate[i].LastIndexOf(
330 ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR); 349 ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR);
331 350
332 if (identicalNameIdentifierIndex < 0)
333 {
334 i++;
335 continue;
336 }
337 string newFolderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex); 351 string newFolderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex);
338 352
339 newFolderName = InventoryArchiveUtils.UnescapeArchivePath(newFolderName); 353 newFolderName = InventoryArchiveUtils.UnescapeArchivePath(newFolderName);
@@ -356,8 +370,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
356 370
357 if (0 == i) 371 if (0 == i)
358 loadedNodes.Add(destFolder); 372 loadedNodes.Add(destFolder);
359
360 i++;
361 } 373 }
362 } 374 }
363 375