change iar load to make discrete inventory service requests rather than the cache

remotes/origin/0.6.7-post-fixes
Justin Clark-Casey (justincc) 2009-09-06 22:07:35 +01:00
parent 5640cac8e0
commit 61c286f5d6
2 changed files with 51 additions and 33 deletions

View File

@ -100,6 +100,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
int successfulItemRestores = 0;
List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>();
/*
if (!m_userInfo.HasReceivedInventory)
{
// If the region server has access to the user admin service (by which users are created),
@ -127,8 +128,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
}
}
}
InventoryFolderImpl rootDestinationFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath);
*/
//InventoryFolderImpl rootDestinationFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath);
InventoryFolderBase rootDestinationFolder
= InventoryArchiveUtils.FindFolderByPath(
m_scene.InventoryService, m_userInfo.UserProfile.ID, m_invPath);
if (null == rootDestinationFolder)
{
@ -142,7 +147,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
// In order to load identically named folders, we need to keep track of the folders that we have already
// created
Dictionary <string, InventoryFolderImpl> foldersCreated = new Dictionary<string, InventoryFolderImpl>();
Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>();
byte[] data;
TarArchiveReader.TarEntryType entryType;
@ -157,7 +162,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
}
else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH))
{
InventoryFolderImpl foundFolder
InventoryFolderBase foundFolder
= ReplicateArchivePathToUserInventory(
filePath, TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType,
rootDestinationFolder, foldersCreated, nodesLoaded);
@ -178,7 +183,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
// Reset folder ID to the one in which we want to load it
item.Folder = foundFolder.ID;
m_userInfo.AddItem(item);
//m_userInfo.AddItem(item);
m_scene.InventoryService.AddItem(item);
successfulItemRestores++;
// If we're loading an item directly into the given destination folder then we need to record
@ -211,11 +217,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
/// chain, only the root node needs to be recorded
/// </param>
/// <returns>The last user inventory folder created or found for the archive path</returns>
public InventoryFolderImpl ReplicateArchivePathToUserInventory(
public InventoryFolderBase ReplicateArchivePathToUserInventory(
string fsPath,
bool isDir,
InventoryFolderImpl rootDestinationFolder,
Dictionary <string, InventoryFolderImpl> foldersCreated,
InventoryFolderBase rootDestFolder,
Dictionary <string, InventoryFolderBase> foldersCreated,
List<InventoryNodeBase> nodesLoaded)
{
fsPath = fsPath.Substring(ArchiveConstants.INVENTORY_PATH.Length);
@ -228,17 +234,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
m_log.DebugFormat("[INVENTORY ARCHIVER]: Loading to folder {0}", fsPath);
InventoryFolderImpl foundFolder = null;
InventoryFolderBase destFolder = 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 == destFolder && fsPath.Length > 0)
{
if (foldersCreated.ContainsKey(fsPath))
{
m_log.DebugFormat("[INVENTORY ARCHIVER]: Found previously created fs path {0}", fsPath);
foundFolder = foldersCreated[fsPath];
destFolder = foldersCreated[fsPath];
}
else
{
@ -255,14 +261,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
"[INVENTORY ARCHIVER]: Found no previously created fs path for {0}",
originalFsPath);
fsPath = string.Empty;
foundFolder = rootDestinationFolder;
destFolder = rootDestFolder;
}
}
}
}
else
{
foundFolder = rootDestinationFolder;
destFolder = rootDestFolder;
}
string fsPathSectionToCreate = originalFsPath.Substring(fsPath.Length);
@ -277,30 +283,39 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
int identicalNameIdentifierIndex
= rawDirsToCreate[i].LastIndexOf(
ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR);
string folderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex);
string newFolderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex);
UUID newFolderId = UUID.Random();
m_userInfo.CreateFolder(
folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID);
destFolder
= new InventoryFolderBase(
newFolderId, newFolderName, m_userInfo.UserProfile.ID,
(short)AssetType.Folder, destFolder.ID, 0);
m_scene.InventoryService.AddFolder(destFolder);
// UUID newFolderId = UUID.Random();
// m_scene.InventoryService.AddFolder(
// m_userInfo.CreateFolder(
// folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID);
m_log.DebugFormat("[INVENTORY ARCHIVER]: Retrieving newly created folder {0}", folderName);
foundFolder = foundFolder.GetChildFolder(newFolderId);
m_log.DebugFormat(
"[INVENTORY ARCHIVER]: Retrieved newly created folder {0} with ID {1}",
foundFolder.Name, foundFolder.ID);
// m_log.DebugFormat("[INVENTORY ARCHIVER]: Retrieving newly created folder {0}", folderName);
// foundFolder = foundFolder.GetChildFolder(newFolderId);
// m_log.DebugFormat(
// "[INVENTORY ARCHIVER]: Retrieved newly created folder {0} with ID {1}",
// foundFolder.Name, foundFolder.ID);
// 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;
foldersCreated[fsPath] = destFolder;
if (0 == i)
nodesLoaded.Add(foundFolder);
nodesLoaded.Add(destFolder);
i++;
}
return foundFolder;
return destFolder;
/*
string[] rawFolders = filePath.Split(new char[] { '/' });

View File

@ -267,7 +267,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
= scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName);
InventoryItemBase foundItem
= InventoryArchiveUtils.FindItemByPath( scene.InventoryService, userInfo.UserProfile.ID, itemName);
= InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, itemName);
Assert.That(foundItem, Is.Not.Null, "Didn't find loaded item");
Assert.That(
@ -378,9 +378,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
Monitor.Wait(this, 60000);
}
Console.WriteLine("userInfo.RootFolder 1: {0}", userInfo.RootFolder);
//Console.WriteLine("userInfo.RootFolder 1: {0}", userInfo.RootFolder);
Dictionary <string, InventoryFolderImpl> foldersCreated = new Dictionary<string, InventoryFolderImpl>();
Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>();
List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>();
string folder1Name = "a";
@ -398,17 +398,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
"{0}{1}/{2}/{3}",
ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemName);
Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder);
//Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder);
new InventoryArchiveReadRequest(scene, userInfo, null, (Stream)null)
.ReplicateArchivePathToUserInventory(
itemArchivePath, false, userInfo.RootFolder, foldersCreated, nodesLoaded);
itemArchivePath, false, scene.InventoryService.GetRootFolder(userInfo.UserProfile.ID),
foldersCreated, nodesLoaded);
Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder);
InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a");
//Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder);
//InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a");
InventoryFolderBase folder1
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userInfo.UserProfile.ID, "a");
Assert.That(folder1, Is.Not.Null, "Could not find folder a");
InventoryFolderImpl folder2 = folder1.FindFolderByPath("b");
InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b");
Assert.That(folder2, Is.Not.Null, "Could not find folder b");
}
}
}
}