aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-03-13 20:46:53 +0000
committerJustin Clarke Casey2009-03-13 20:46:53 +0000
commitc04e7cdf2b8f95534dafe7faedb29e1ff1af36c8 (patch)
treefc5a72b39ba72eee84afba4dc9ff315acbb0096f /OpenSim/Region/CoreModules/Avatar
parent* Remove asset cache size and texture stat reports from ASSET STATS since the... (diff)
downloadopensim-SC_OLD-c04e7cdf2b8f95534dafe7faedb29e1ff1af36c8.zip
opensim-SC_OLD-c04e7cdf2b8f95534dafe7faedb29e1ff1af36c8.tar.gz
opensim-SC_OLD-c04e7cdf2b8f95534dafe7faedb29e1ff1af36c8.tar.bz2
opensim-SC_OLD-c04e7cdf2b8f95534dafe7faedb29e1ff1af36c8.tar.xz
* Support loading empty folders in an iar
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs168
1 files changed, 90 insertions, 78 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index d794f00..4ad9974 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -200,11 +200,7 @@ 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 (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
204 {
205 m_log.WarnFormat("[INVENTORY ARCHIVER]: Ignoring directory entry {0}", filePath);
206 }
207 else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
208 { 204 {
209 if (LoadAsset(filePath, data)) 205 if (LoadAsset(filePath, data))
210 successfulAssetRestores++; 206 successfulAssetRestores++;
@@ -212,24 +208,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
212 failedAssetRestores++; 208 failedAssetRestores++;
213 } 209 }
214 else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) 210 else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH))
215 { 211 {
216 InventoryItemBase item = LoadInvItem(m_asciiEncoding.GetString(data)); 212 string fsPath = filePath.Substring(ArchiveConstants.INVENTORY_PATH.Length);
217
218 if (item != null)
219 {
220 // Don't use the item ID that's in the file
221 item.ID = UUID.Random();
222
223 item.Creator = m_userInfo.UserProfile.ID;
224 item.Owner = m_userInfo.UserProfile.ID;
225 213
226 string fsPath = filePath.Substring(ArchiveConstants.INVENTORY_PATH.Length); 214 // Remove the file portion if we aren't already dealing with a directory path
215 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
227 fsPath = fsPath.Remove(fsPath.LastIndexOf("/") + 1); 216 fsPath = fsPath.Remove(fsPath.LastIndexOf("/") + 1);
228 string originalFsPath = fsPath; 217
218 string originalFsPath = fsPath;
229 219
230 m_log.DebugFormat("[INVENTORY ARCHIVER]: Loading to folder {0}", fsPath); 220 m_log.DebugFormat("[INVENTORY ARCHIVER]: Loading to folder {0}", fsPath);
231 221
232 InventoryFolderImpl foundFolder = null; 222 InventoryFolderImpl foundFolder = null;
223
224 // XXX: Nasty way of dealing with a path that has no directory component
225 if (fsPath.Length > 0)
226 {
233 while (null == foundFolder && fsPath.Length > 0) 227 while (null == foundFolder && fsPath.Length > 0)
234 { 228 {
235 if (foldersCreated.ContainsKey(fsPath)) 229 if (foldersCreated.ContainsKey(fsPath))
@@ -256,81 +250,99 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
256 } 250 }
257 } 251 }
258 } 252 }
253 }
254 else
255 {
256 foundFolder = rootDestinationFolder;
257 }
259 258
260 string fsPathSectionToCreate = originalFsPath.Substring(fsPath.Length); 259 string fsPathSectionToCreate = originalFsPath.Substring(fsPath.Length);
261 string[] rawDirsToCreate 260 string[] rawDirsToCreate
262 = fsPathSectionToCreate.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); 261 = fsPathSectionToCreate.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
263 int i = 0; 262 int i = 0;
264 263
265 while (i < rawDirsToCreate.Length) 264 while (i < rawDirsToCreate.Length)
266 { 265 {
267 m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawDirsToCreate[i]); 266 m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawDirsToCreate[i]);
268 267
269 int identicalNameIdentifierIndex 268 int identicalNameIdentifierIndex
270 = rawDirsToCreate[i].LastIndexOf( 269 = rawDirsToCreate[i].LastIndexOf(
271 ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR); 270 ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR);
272 string folderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex); 271 string folderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex);
273 272
274 UUID newFolderId = UUID.Random(); 273 UUID newFolderId = UUID.Random();
275 m_userInfo.CreateFolder( 274 m_userInfo.CreateFolder(
276 folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID); 275 folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID);
277 foundFolder = foundFolder.GetChildFolder(newFolderId); 276 foundFolder = foundFolder.GetChildFolder(newFolderId);
278 277
279 // Record that we have now created this folder 278 // Record that we have now created this folder
280 fsPath += rawDirsToCreate[i] + "/"; 279 fsPath += rawDirsToCreate[i] + "/";
281 m_log.DebugFormat("[INVENTORY ARCHIVER]: Recording creation of fs path {0}", fsPath); 280 m_log.DebugFormat("[INVENTORY ARCHIVER]: Recording creation of fs path {0}", fsPath);
282 foldersCreated[fsPath] = foundFolder; 281 foldersCreated[fsPath] = foundFolder;
283 282
284 if (0 == i) 283 if (0 == i)
285 nodesLoaded.Add(foundFolder); 284 nodesLoaded.Add(foundFolder);
286 285
287 i++; 286 i++;
288 } 287 }
289 288
290 /* 289 /*
291 string[] rawFolders = filePath.Split(new char[] { '/' }); 290 string[] rawFolders = filePath.Split(new char[] { '/' });
292 291
293 // Find the folders that do exist along the path given 292 // Find the folders that do exist along the path given
294 int i = 0; 293 int i = 0;
295 bool noFolder = false; 294 bool noFolder = false;
296 InventoryFolderImpl foundFolder = rootDestinationFolder; 295 InventoryFolderImpl foundFolder = rootDestinationFolder;
297 while (!noFolder && i < rawFolders.Length) 296 while (!noFolder && i < rawFolders.Length)
297 {
298 InventoryFolderImpl folder = foundFolder.FindFolderByPath(rawFolders[i]);
299 if (null != folder)
298 { 300 {
299 InventoryFolderImpl folder = foundFolder.FindFolderByPath(rawFolders[i]); 301 m_log.DebugFormat("[INVENTORY ARCHIVER]: Found folder {0}", folder.Name);
300 if (null != folder) 302 foundFolder = folder;
301 { 303 i++;
302 m_log.DebugFormat("[INVENTORY ARCHIVER]: Found folder {0}", folder.Name);
303 foundFolder = folder;
304 i++;
305 }
306 else
307 {
308 noFolder = true;
309 }
310 } 304 }
311 305 else
312 // Create any folders that did not previously exist
313 while (i < rawFolders.Length)
314 { 306 {
315 m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawFolders[i]); 307 noFolder = true;
316
317 UUID newFolderId = UUID.Random();
318 m_userInfo.CreateFolder(
319 rawFolders[i++], newFolderId, (ushort)AssetType.Folder, foundFolder.ID);
320 foundFolder = foundFolder.GetChildFolder(newFolderId);
321 } 308 }
322 */ 309 }
323 310
324 // Reset folder ID to the one in which we want to load it 311 // Create any folders that did not previously exist
325 item.Folder = foundFolder.ID; 312 while (i < rawFolders.Length)
313 {
314 m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawFolders[i]);
326 315
327 m_userInfo.AddItem(item); 316 UUID newFolderId = UUID.Random();
328 successfulItemRestores++; 317 m_userInfo.CreateFolder(
318 rawFolders[i++], newFolderId, (ushort)AssetType.Folder, foundFolder.ID);
319 foundFolder = foundFolder.GetChildFolder(newFolderId);
320 }
321 */
329 322
330 // If we're loading an item directly into the given destination folder then we need to record 323 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
331 // it separately from any loaded root folders 324 {
332 if (rootDestinationFolder == foundFolder) 325 InventoryItemBase item = LoadInvItem(m_asciiEncoding.GetString(data));
333 nodesLoaded.Add(item); 326
327 if (item != null)
328 {
329 // Don't use the item ID that's in the file
330 item.ID = UUID.Random();
331
332 item.Creator = m_userInfo.UserProfile.ID;
333 item.Owner = m_userInfo.UserProfile.ID;
334
335 // Reset folder ID to the one in which we want to load it
336 item.Folder = foundFolder.ID;
337
338 m_userInfo.AddItem(item);
339 successfulItemRestores++;
340
341 // If we're loading an item directly into the given destination folder then we need to record
342 // it separately from any loaded root folders
343 if (rootDestinationFolder == foundFolder)
344 nodesLoaded.Add(item);
345 }
334 } 346 }
335 } 347 }
336 } 348 }