aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs91
1 files changed, 77 insertions, 14 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index fc63957..4a681bc 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -85,7 +85,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
85 85
86 if (contents.Equals("")) return null; 86 if (contents.Equals("")) return null;
87 87
88 reader.ReadStartElement("InventoryObject"); 88 reader.ReadStartElement("InventoryItem");
89 reader.ReadStartElement("Name"); 89 reader.ReadStartElement("Name");
90 item.Name = reader.ReadString(); 90 item.Name = reader.ReadString();
91 reader.ReadEndElement(); 91 reader.ReadEndElement();
@@ -138,10 +138,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
138 reader.ReadStartElement("GroupOwned"); 138 reader.ReadStartElement("GroupOwned");
139 item.GroupOwned = Convert.ToBoolean(reader.ReadString()); 139 item.GroupOwned = Convert.ToBoolean(reader.ReadString());
140 reader.ReadEndElement(); 140 reader.ReadEndElement();
141 //reader.ReadStartElement("ParentFolderID");
142 //item.Folder = UUID.Parse(reader.ReadString());
143 //reader.ReadEndElement();
144 //reader.ReadEndElement();
145 141
146 return item; 142 return item;
147 } 143 }
@@ -187,13 +183,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
187 183
188 if (null == rootDestinationFolder) 184 if (null == rootDestinationFolder)
189 { 185 {
190 // TODO: Later on, automatically create this folder if it does not exist 186 // Possibly provide an option later on to automatically create this folder if it does not exist
191 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath); 187 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath);
192 188
193 return nodesLoaded; 189 return nodesLoaded;
194 } 190 }
195 191
196 archive = new TarArchiveReader(m_loadStream); 192 archive = new TarArchiveReader(m_loadStream);
193
194 // In order to load identically named folders, we need to keep track of the folders that we have already
195 // created
196 Dictionary <string, InventoryFolderImpl> foldersCreated = new Dictionary<string, InventoryFolderImpl>();
197 197
198 byte[] data; 198 byte[] data;
199 TarArchiveReader.TarEntryType entryType; 199 TarArchiveReader.TarEntryType entryType;
@@ -222,12 +222,72 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
222 item.Creator = m_userInfo.UserProfile.ID; 222 item.Creator = m_userInfo.UserProfile.ID;
223 item.Owner = m_userInfo.UserProfile.ID; 223 item.Owner = m_userInfo.UserProfile.ID;
224 224
225 filePath = filePath.Substring(InventoryArchiveConstants.INVENTORY_PATH.Length); 225 string fsPath = filePath.Substring(InventoryArchiveConstants.INVENTORY_PATH.Length);
226 filePath = filePath.Remove(filePath.LastIndexOf("/")); 226 fsPath = fsPath.Remove(fsPath.LastIndexOf("/") + 1);
227 string originalFsPath = fsPath;
228
229 m_log.DebugFormat("[INVENTORY ARCHIVER]: Loading to folder {0}", fsPath);
227 230
228 m_log.DebugFormat("[INVENTORY ARCHIVER]: Loading to file path {0}", filePath); 231 InventoryFolderImpl foundFolder = null;
232 while (null == foundFolder && fsPath.Length > 0)
233 {
234 if (foldersCreated.ContainsKey(fsPath))
235 {
236 m_log.DebugFormat("[INVENTORY ARCHIVER]: Found previously created fs path {0}", fsPath);
237 foundFolder = foldersCreated[fsPath];
238 }
239 else
240 {
241 // Don't include the last slash
242 int penultimateSlashIndex = fsPath.LastIndexOf("/", fsPath.Length - 2);
243
244 if (penultimateSlashIndex >= 0)
245 {
246 fsPath = fsPath.Remove(penultimateSlashIndex + 1);
247 }
248 else
249 {
250 m_log.DebugFormat(
251 "[INVENTORY ARCHIVER]: Found no previously created fs path for {0}",
252 originalFsPath);
253 fsPath = string.Empty;
254 foundFolder = rootDestinationFolder;
255 }
256 }
257 }
229 258
230 string[] rawFolders = filePath.Split(new char[] { '/' }); 259 string fsPathSectionToCreate = originalFsPath.Substring(fsPath.Length);
260 string[] rawDirsToCreate
261 = fsPathSectionToCreate.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
262 int i = 0;
263
264 while (i < rawDirsToCreate.Length)
265 {
266 m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawDirsToCreate[i]);
267
268 int identicalNameIdentifierIndex
269 = rawDirsToCreate[i].LastIndexOf(
270 InventoryArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR);
271 string folderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex);
272
273 UUID newFolderId = UUID.Random();
274 m_userInfo.CreateFolder(
275 folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID);
276 foundFolder = foundFolder.GetChildFolder(newFolderId);
277
278 // Record that we have now created this folder
279 fsPath += rawDirsToCreate[i] + "/";
280 m_log.DebugFormat("[INVENTORY ARCHIVER]: Recording creation of fs path {0}", fsPath);
281 foldersCreated[fsPath] = foundFolder;
282
283 if (0 == i)
284 nodesLoaded.Add(foundFolder);
285
286 i++;
287 }
288
289 /*
290 string[] rawFolders = filePath.Split(new char[] { '/' });
231 291
232 // Find the folders that do exist along the path given 292 // Find the folders that do exist along the path given
233 int i = 0; 293 int i = 0;
@@ -257,16 +317,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
257 m_userInfo.CreateFolder( 317 m_userInfo.CreateFolder(
258 rawFolders[i++], newFolderId, (ushort)AssetType.Folder, foundFolder.ID); 318 rawFolders[i++], newFolderId, (ushort)AssetType.Folder, foundFolder.ID);
259 foundFolder = foundFolder.GetChildFolder(newFolderId); 319 foundFolder = foundFolder.GetChildFolder(newFolderId);
260 } 320 }
321 */
261 322
262 // Reset folder ID to the one in which we want to load it 323 // Reset folder ID to the one in which we want to load it
263 item.Folder = foundFolder.ID; 324 item.Folder = foundFolder.ID;
264
265 //item.Folder = rootDestinationFolder.ID;
266 325
267 m_userInfo.AddItem(item); 326 m_userInfo.AddItem(item);
268 successfulItemRestores++; 327 successfulItemRestores++;
269 nodesLoaded.Add(item); 328
329 // If we're loading an item directly into the given destination folder then we need to record
330 // it separately from any loaded root folders
331 if (rootDestinationFolder == foundFolder)
332 nodesLoaded.Add(item);
270 } 333 }
271 } 334 }
272 } 335 }