From c04e7cdf2b8f95534dafe7faedb29e1ff1af36c8 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Fri, 13 Mar 2009 20:46:53 +0000
Subject: * Support loading empty folders in an iar
---
.../Archiver/InventoryArchiveReadRequest.cs | 168 +++++++++++----------
.../CoreModules/World/Archiver/AssetsRequest.cs | 11 +-
.../World/Archiver/Tests/ArchiverTests.cs | 8 +-
OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 5 +
4 files changed, 107 insertions(+), 85 deletions(-)
(limited to 'OpenSim/Region')
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
TarArchiveReader.TarEntryType entryType;
while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
{
- if (entryType == TarArchiveReader.TarEntryType.TYPE_DIRECTORY)
- {
- m_log.WarnFormat("[INVENTORY ARCHIVER]: Ignoring directory entry {0}", filePath);
- }
- else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
+ if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
{
if (LoadAsset(filePath, data))
successfulAssetRestores++;
@@ -212,24 +208,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
failedAssetRestores++;
}
else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH))
- {
- InventoryItemBase item = LoadInvItem(m_asciiEncoding.GetString(data));
-
- if (item != null)
- {
- // Don't use the item ID that's in the file
- item.ID = UUID.Random();
-
- item.Creator = m_userInfo.UserProfile.ID;
- item.Owner = m_userInfo.UserProfile.ID;
+ {
+ string fsPath = filePath.Substring(ArchiveConstants.INVENTORY_PATH.Length);
- string fsPath = filePath.Substring(ArchiveConstants.INVENTORY_PATH.Length);
+ // Remove the file portion if we aren't already dealing with a directory path
+ if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
fsPath = fsPath.Remove(fsPath.LastIndexOf("/") + 1);
- string originalFsPath = fsPath;
+
+ string originalFsPath = fsPath;
- m_log.DebugFormat("[INVENTORY ARCHIVER]: Loading to folder {0}", fsPath);
+ m_log.DebugFormat("[INVENTORY ARCHIVER]: Loading to folder {0}", fsPath);
- InventoryFolderImpl foundFolder = null;
+ InventoryFolderImpl foundFolder = null;
+
+ // XXX: Nasty way of dealing with a path that has no directory component
+ if (fsPath.Length > 0)
+ {
while (null == foundFolder && fsPath.Length > 0)
{
if (foldersCreated.ContainsKey(fsPath))
@@ -256,81 +250,99 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
}
}
}
+ }
+ else
+ {
+ foundFolder = rootDestinationFolder;
+ }
- string fsPathSectionToCreate = originalFsPath.Substring(fsPath.Length);
- string[] rawDirsToCreate
- = fsPathSectionToCreate.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
- int i = 0;
+ string fsPathSectionToCreate = originalFsPath.Substring(fsPath.Length);
+ string[] rawDirsToCreate
+ = fsPathSectionToCreate.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
+ int i = 0;
- while (i < rawDirsToCreate.Length)
- {
- m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawDirsToCreate[i]);
+ while (i < rawDirsToCreate.Length)
+ {
+ m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawDirsToCreate[i]);
- int identicalNameIdentifierIndex
- = rawDirsToCreate[i].LastIndexOf(
- ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR);
- string folderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex);
+ int identicalNameIdentifierIndex
+ = rawDirsToCreate[i].LastIndexOf(
+ ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR);
+ string folderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex);
- UUID newFolderId = UUID.Random();
- m_userInfo.CreateFolder(
- folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID);
- foundFolder = foundFolder.GetChildFolder(newFolderId);
+ UUID newFolderId = UUID.Random();
+ m_userInfo.CreateFolder(
+ folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID);
+ foundFolder = foundFolder.GetChildFolder(newFolderId);
- // Record that we have now created this folder
- fsPath += rawDirsToCreate[i] + "/";
- m_log.DebugFormat("[INVENTORY ARCHIVER]: Recording creation of fs path {0}", fsPath);
- foldersCreated[fsPath] = foundFolder;
+ // Record that we have now created this folder
+ fsPath += rawDirsToCreate[i] + "/";
+ m_log.DebugFormat("[INVENTORY ARCHIVER]: Recording creation of fs path {0}", fsPath);
+ foldersCreated[fsPath] = foundFolder;
- if (0 == i)
- nodesLoaded.Add(foundFolder);
+ if (0 == i)
+ nodesLoaded.Add(foundFolder);
- i++;
- }
+ i++;
+ }
- /*
- string[] rawFolders = filePath.Split(new char[] { '/' });
+ /*
+ string[] rawFolders = filePath.Split(new char[] { '/' });
- // Find the folders that do exist along the path given
- int i = 0;
- bool noFolder = false;
- InventoryFolderImpl foundFolder = rootDestinationFolder;
- while (!noFolder && i < rawFolders.Length)
+ // Find the folders that do exist along the path given
+ int i = 0;
+ bool noFolder = false;
+ InventoryFolderImpl foundFolder = rootDestinationFolder;
+ while (!noFolder && i < rawFolders.Length)
+ {
+ InventoryFolderImpl folder = foundFolder.FindFolderByPath(rawFolders[i]);
+ if (null != folder)
{
- InventoryFolderImpl folder = foundFolder.FindFolderByPath(rawFolders[i]);
- if (null != folder)
- {
- m_log.DebugFormat("[INVENTORY ARCHIVER]: Found folder {0}", folder.Name);
- foundFolder = folder;
- i++;
- }
- else
- {
- noFolder = true;
- }
+ m_log.DebugFormat("[INVENTORY ARCHIVER]: Found folder {0}", folder.Name);
+ foundFolder = folder;
+ i++;
}
-
- // Create any folders that did not previously exist
- while (i < rawFolders.Length)
+ else
{
- 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);
+ noFolder = true;
}
- */
+ }
- // Reset folder ID to the one in which we want to load it
- item.Folder = foundFolder.ID;
+ // Create any folders that did not previously exist
+ while (i < rawFolders.Length)
+ {
+ m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawFolders[i]);
- m_userInfo.AddItem(item);
- successfulItemRestores++;
+ UUID newFolderId = UUID.Random();
+ m_userInfo.CreateFolder(
+ rawFolders[i++], newFolderId, (ushort)AssetType.Folder, foundFolder.ID);
+ foundFolder = foundFolder.GetChildFolder(newFolderId);
+ }
+ */
- // If we're loading an item directly into the given destination folder then we need to record
- // it separately from any loaded root folders
- if (rootDestinationFolder == foundFolder)
- nodesLoaded.Add(item);
+ if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
+ {
+ InventoryItemBase item = LoadInvItem(m_asciiEncoding.GetString(data));
+
+ if (item != null)
+ {
+ // Don't use the item ID that's in the file
+ item.ID = UUID.Random();
+
+ item.Creator = m_userInfo.UserProfile.ID;
+ item.Owner = m_userInfo.UserProfile.ID;
+
+ // Reset folder ID to the one in which we want to load it
+ item.Folder = foundFolder.ID;
+
+ m_userInfo.AddItem(item);
+ successfulItemRestores++;
+
+ // If we're loading an item directly into the given destination folder then we need to record
+ // it separately from any loaded root folders
+ if (rootDestinationFolder == foundFolder)
+ nodesLoaded.Add(item);
+ }
}
}
}
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
index 076fbce..0a0bb4c 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
@@ -83,6 +83,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
protected internal void Execute()
{
+ m_log.DebugFormat("[ARCHIVER]: AssetsRequest executed looking for {0} assets", m_repliesRequired);
+
// We can stop here if there are no assets to fetch
if (m_repliesRequired == 0)
m_assetsRequestCallback(m_assets, m_notFoundAssetUuids);
@@ -100,6 +102,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
///
public void AssetRequestCallback(UUID assetID, AssetBase asset)
{
+ //m_log.DebugFormat("[ARCHIVER]: Received callback for asset {0}", assetID);
+
if (asset != null)
{
m_assetCache.ExpireAsset(assetID);
@@ -110,11 +114,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver
m_notFoundAssetUuids.Add(assetID);
}
- //m_log.DebugFormat(
- // "[ARCHIVER]: Received {0} assets and notification of {1} missing assets", m_assets.Count, m_notFoundAssetUuids.Count);
-
if (m_assets.Count + m_notFoundAssetUuids.Count == m_repliesRequired)
{
+ m_log.DebugFormat(
+ "[ARCHIVER]: Successfully received {0} assets and notification of {1} missing assets",
+ m_assets.Count, m_notFoundAssetUuids.Count);
+
// We want to stop using the asset cache thread asap as we now need to do the actual work of producing the archive
Thread newThread = new Thread(PerformAssetsRequestCallback);
newThread.Name = "OpenSimulator archiving thread post assets receipt";
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index 7aafaee..f6d0347 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -222,6 +222,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
object1PartLoaded.RotationOffset, Is.EqualTo(rotationOffset), "object1 rotation offset not equal");
Assert.That(
object1PartLoaded.OffsetPosition, Is.EqualTo(offsetPosition), "object1 offset position not equal");
+
+ // Temporary
+ Console.WriteLine("Successfully completed {0}", MethodBase.GetCurrentMethod());
}
///
@@ -304,10 +307,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
Assert.That(object2PartMerged, Is.Not.Null, "object2 was not present after merge");
Assert.That(object2PartMerged.Name, Is.EqualTo(part2Name), "object2 names not identical after merge");
Assert.That(object2PartMerged.GroupPosition, Is.EqualTo(part2GroupPosition), "object2 group position not equal after merge");
- }
-
- // Temporary
- Console.WriteLine("Successfully completed {0}", MethodBase.GetCurrentMethod());
+ }
}
}
}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 4eb8a28..011d9a6 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -518,6 +518,7 @@ namespace OpenSim.Region.Framework.Scenes
itemCopy.GroupPermissions = item.GroupPermissions & item.NextPermissions;
itemCopy.BasePermissions = item.BasePermissions;
}
+
itemCopy.GroupID = UUID.Zero;
itemCopy.GroupOwned = false;
itemCopy.Flags = item.Flags;
@@ -2467,12 +2468,16 @@ namespace OpenSim.Region.Framework.Scenes
part.NextOwnerMask = item.NextPermissions;
}
}
+
rootPart.TrimPermissions();
+
if (group.RootPart.Shape.PCode == (byte)PCode.Prim)
{
group.ClearPartAttachmentData();
}
+
group.UpdateGroupRotation(rot);
+
//group.ApplyPhysics(m_physicalPrim);
if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical && vel != Vector3.Zero)
{
--
cgit v1.1