From a5c9354df31c747f33e39631cf33bba593a5f071 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Wed, 25 Feb 2009 20:07:25 +0000
Subject: * Properly load items into correct folders when an iar is loaded * At
 the moment, any existing folders with the same name are reused - will need an
 option to always create new folders * not yet ready for general use

---
 .../Archiver/InventoryArchiveReadRequest.cs          | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index b61b524..fc63957 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -222,8 +222,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
                         item.Creator = m_userInfo.UserProfile.ID;
                         item.Owner = m_userInfo.UserProfile.ID;
                         
-                        /*
                         filePath = filePath.Substring(InventoryArchiveConstants.INVENTORY_PATH.Length);
+                        filePath = filePath.Remove(filePath.LastIndexOf("/"));
+                        
+                        m_log.DebugFormat("[INVENTORY ARCHIVER]: Loading to file path {0}", filePath);
+                        
                         string[] rawFolders = filePath.Split(new char[] { '/' });
                         
                         // Find the folders that do exist along the path given
@@ -248,17 +251,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
                         // Create any folders that did not previously exist
                         while (i < rawFolders.Length)
                         {
-                            m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawFolders[i]); 
-                            foundFolder.CreateChildFolder(UUID.Random(), rawFolders[i++], (ushort)AssetType.Folder);                            
+                            m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawFolders[i]);
+                            
+                            UUID newFolderId = UUID.Random();
+                            m_userInfo.CreateFolder(
+                                rawFolders[i++], newFolderId, (ushort)AssetType.Folder, foundFolder.ID);
+                            foundFolder = foundFolder.GetChildFolder(newFolderId);
                         }                        
 
                         // Reset folder ID to the one in which we want to load it
-                        // TODO: Properly restore entire folder structure.  At the moment all items are dumped in this
-                        // single folder no matter where in the saved folder structure they are.
                         item.Folder = foundFolder.ID;
-                        */
                         
-                        item.Folder = rootDestinationFolder.ID;
+                        //item.Folder = rootDestinationFolder.ID;
 
                         m_userInfo.AddItem(item);
                         successfulItemRestores++;
@@ -304,7 +308,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
             {
                 sbyte assetType = InventoryArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension];
 
-                m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType);
+                //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType);
 
                 AssetBase asset = new AssetBase(new UUID(uuid), "RandomName");
 
-- 
cgit v1.1