* Support loading empty folders in an iar

0.6.5-rc1
Justin Clarke Casey 2009-03-13 20:46:53 +00:00
parent 6573e2ee2f
commit c04e7cdf2b
6 changed files with 115 additions and 94 deletions

View File

@ -65,6 +65,7 @@ namespace OpenSim.Framework
if (m_pqueue.Count > 0) if (m_pqueue.Count > 0)
return m_pqueue.Dequeue(); return m_pqueue.Dequeue();
return m_queue.Dequeue(); return m_queue.Dequeue();
} }
} }

View File

@ -214,9 +214,7 @@ namespace OpenSim.Framework.Communications.Cache
req.IsTexture = isTexture; req.IsTexture = isTexture;
m_assetRequests.Enqueue(req); m_assetRequests.Enqueue(req);
#if DEBUG //m_log.DebugFormat("[ASSET SERVER]: Added {0} to request queue", assetID);
//m_log.InfoFormat("[ASSET SERVER]: Added {0} to request queue", assetID);
#endif
} }
public virtual void UpdateAsset(AssetBase asset) public virtual void UpdateAsset(AssetBase asset)

View File

@ -200,11 +200,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
TarArchiveReader.TarEntryType entryType; TarArchiveReader.TarEntryType entryType;
while ((data = archive.ReadEntry(out filePath, out entryType)) != null) while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
{ {
if (entryType == TarArchiveReader.TarEntryType.TYPE_DIRECTORY) if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
{
m_log.WarnFormat("[INVENTORY ARCHIVER]: Ignoring directory entry {0}", filePath);
}
else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
{ {
if (LoadAsset(filePath, data)) if (LoadAsset(filePath, data))
successfulAssetRestores++; successfulAssetRestores++;
@ -212,24 +208,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
failedAssetRestores++; failedAssetRestores++;
} }
else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH))
{ {
InventoryItemBase item = LoadInvItem(m_asciiEncoding.GetString(data)); string fsPath = filePath.Substring(ArchiveConstants.INVENTORY_PATH.Length);
if (item != null) // Remove the file portion if we aren't already dealing with a directory path
{ if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
// 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);
fsPath = fsPath.Remove(fsPath.LastIndexOf("/") + 1); 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) while (null == foundFolder && fsPath.Length > 0)
{ {
if (foldersCreated.ContainsKey(fsPath)) 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 fsPathSectionToCreate = originalFsPath.Substring(fsPath.Length);
string[] rawDirsToCreate string[] rawDirsToCreate
= fsPathSectionToCreate.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); = fsPathSectionToCreate.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
int i = 0; int i = 0;
while (i < rawDirsToCreate.Length) 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);
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;
if (0 == i)
nodesLoaded.Add(foundFolder);
i++;
}
/*
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)
{
InventoryFolderImpl folder = foundFolder.FindFolderByPath(rawFolders[i]);
if (null != folder)
{ {
m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawDirsToCreate[i]); m_log.DebugFormat("[INVENTORY ARCHIVER]: Found folder {0}", folder.Name);
foundFolder = folder;
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);
// 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);
i++; i++;
} }
else
/*
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)
{ {
InventoryFolderImpl folder = foundFolder.FindFolderByPath(rawFolders[i]); noFolder = true;
if (null != folder)
{
m_log.DebugFormat("[INVENTORY ARCHIVER]: Found folder {0}", folder.Name);
foundFolder = folder;
i++;
}
else
{
noFolder = true;
}
} }
}
// Create any folders that did not previously exist // Create any folders that did not previously exist
while (i < rawFolders.Length) while (i < rawFolders.Length)
{ {
m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawFolders[i]); m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawFolders[i]);
UUID newFolderId = UUID.Random(); UUID newFolderId = UUID.Random();
m_userInfo.CreateFolder( m_userInfo.CreateFolder(
rawFolders[i++], newFolderId, (ushort)AssetType.Folder, foundFolder.ID); rawFolders[i++], newFolderId, (ushort)AssetType.Folder, foundFolder.ID);
foundFolder = foundFolder.GetChildFolder(newFolderId); foundFolder = foundFolder.GetChildFolder(newFolderId);
}
*/
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);
} }
*/
// 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);
} }
} }
} }

View File

@ -83,6 +83,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
protected internal void Execute() 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 // We can stop here if there are no assets to fetch
if (m_repliesRequired == 0) if (m_repliesRequired == 0)
m_assetsRequestCallback(m_assets, m_notFoundAssetUuids); m_assetsRequestCallback(m_assets, m_notFoundAssetUuids);
@ -100,6 +102,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
/// <param name="asset"></param> /// <param name="asset"></param>
public void AssetRequestCallback(UUID assetID, AssetBase asset) public void AssetRequestCallback(UUID assetID, AssetBase asset)
{ {
//m_log.DebugFormat("[ARCHIVER]: Received callback for asset {0}", assetID);
if (asset != null) if (asset != null)
{ {
m_assetCache.ExpireAsset(assetID); m_assetCache.ExpireAsset(assetID);
@ -110,11 +114,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver
m_notFoundAssetUuids.Add(assetID); 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) 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 // 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); Thread newThread = new Thread(PerformAssetsRequestCallback);
newThread.Name = "OpenSimulator archiving thread post assets receipt"; newThread.Name = "OpenSimulator archiving thread post assets receipt";

View File

@ -222,6 +222,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
object1PartLoaded.RotationOffset, Is.EqualTo(rotationOffset), "object1 rotation offset not equal"); object1PartLoaded.RotationOffset, Is.EqualTo(rotationOffset), "object1 rotation offset not equal");
Assert.That( Assert.That(
object1PartLoaded.OffsetPosition, Is.EqualTo(offsetPosition), "object1 offset position not equal"); object1PartLoaded.OffsetPosition, Is.EqualTo(offsetPosition), "object1 offset position not equal");
// Temporary
Console.WriteLine("Successfully completed {0}", MethodBase.GetCurrentMethod());
} }
/// <summary> /// <summary>
@ -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, 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.Name, Is.EqualTo(part2Name), "object2 names not identical after merge");
Assert.That(object2PartMerged.GroupPosition, Is.EqualTo(part2GroupPosition), "object2 group position not equal after merge"); Assert.That(object2PartMerged.GroupPosition, Is.EqualTo(part2GroupPosition), "object2 group position not equal after merge");
} }
// Temporary
Console.WriteLine("Successfully completed {0}", MethodBase.GetCurrentMethod());
} }
} }
} }

View File

@ -518,6 +518,7 @@ namespace OpenSim.Region.Framework.Scenes
itemCopy.GroupPermissions = item.GroupPermissions & item.NextPermissions; itemCopy.GroupPermissions = item.GroupPermissions & item.NextPermissions;
itemCopy.BasePermissions = item.BasePermissions; itemCopy.BasePermissions = item.BasePermissions;
} }
itemCopy.GroupID = UUID.Zero; itemCopy.GroupID = UUID.Zero;
itemCopy.GroupOwned = false; itemCopy.GroupOwned = false;
itemCopy.Flags = item.Flags; itemCopy.Flags = item.Flags;
@ -2467,12 +2468,16 @@ namespace OpenSim.Region.Framework.Scenes
part.NextOwnerMask = item.NextPermissions; part.NextOwnerMask = item.NextPermissions;
} }
} }
rootPart.TrimPermissions(); rootPart.TrimPermissions();
if (group.RootPart.Shape.PCode == (byte)PCode.Prim) if (group.RootPart.Shape.PCode == (byte)PCode.Prim)
{ {
group.ClearPartAttachmentData(); group.ClearPartAttachmentData();
} }
group.UpdateGroupRotation(rot); group.UpdateGroupRotation(rot);
//group.ApplyPhysics(m_physicalPrim); //group.ApplyPhysics(m_physicalPrim);
if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical && vel != Vector3.Zero) if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical && vel != Vector3.Zero)
{ {