* Restore loaded inventory items to the given folder
* Among many other deficiencies, currently a cache clear and relog is needed to see them, which is highly unsatisfactory * No user funcionality yet0.6.0-stable
parent
f7205da1d9
commit
6e98233b2e
|
@ -51,8 +51,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver
|
||||||
protected TarArchiveReader archive;
|
protected TarArchiveReader archive;
|
||||||
private static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding();
|
private static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding();
|
||||||
|
|
||||||
CachedUserInfo userInfo;
|
|
||||||
UserProfileData userProfile;
|
|
||||||
CommunicationsManager commsManager;
|
CommunicationsManager commsManager;
|
||||||
|
|
||||||
public InventoryArchiveReadRequest(Scene currentScene, CommunicationsManager commsManager)
|
public InventoryArchiveReadRequest(Scene currentScene, CommunicationsManager commsManager)
|
||||||
|
@ -82,14 +80,12 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver
|
||||||
reader.ReadEndElement();
|
reader.ReadEndElement();
|
||||||
reader.ReadStartElement("CreatorUUID");
|
reader.ReadStartElement("CreatorUUID");
|
||||||
item.Creator = UUID.Parse(reader.ReadString());
|
item.Creator = UUID.Parse(reader.ReadString());
|
||||||
item.Creator = userProfile.ID;
|
|
||||||
reader.ReadEndElement();
|
reader.ReadEndElement();
|
||||||
reader.ReadStartElement("CreationDate");
|
reader.ReadStartElement("CreationDate");
|
||||||
item.CreationDate = System.Convert.ToInt32(reader.ReadString());
|
item.CreationDate = System.Convert.ToInt32(reader.ReadString());
|
||||||
reader.ReadEndElement();
|
reader.ReadEndElement();
|
||||||
reader.ReadStartElement("Owner");
|
reader.ReadStartElement("Owner");
|
||||||
item.Owner = UUID.Parse(reader.ReadString());
|
item.Owner = UUID.Parse(reader.ReadString());
|
||||||
item.Owner = userProfile.ID;
|
|
||||||
reader.ReadEndElement();
|
reader.ReadEndElement();
|
||||||
//No description would kill it
|
//No description would kill it
|
||||||
if (reader.IsEmptyElement)
|
if (reader.IsEmptyElement)
|
||||||
|
@ -150,13 +146,46 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver
|
||||||
int failedAssetRestores = 0;
|
int failedAssetRestores = 0;
|
||||||
int successfulItemRestores = 0;
|
int successfulItemRestores = 0;
|
||||||
|
|
||||||
|
UserProfileData userProfile = commsManager.UserService.GetUserProfile(firstName, lastName);
|
||||||
|
if (null == userProfile)
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat("[CONSOLE]: Failed to find user {0} {1}", firstName, lastName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userProfile.ID);
|
||||||
|
if (null == userInfo)
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat(
|
||||||
|
"[CONSOLE]: Failed to find user info for {0} {1} {2}",
|
||||||
|
firstName, lastName, userProfile.ID);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!userInfo.HasReceivedInventory)
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat(
|
||||||
|
"[CONSOLE]: Have not yet received inventory info for user {0} {1} {2}",
|
||||||
|
firstName, lastName, userProfile.ID);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
InventoryFolderImpl inventoryFolder = userInfo.RootFolder.FindFolderByPath(invPath);
|
||||||
|
|
||||||
|
if (null == inventoryFolder)
|
||||||
|
{
|
||||||
|
// TODO: Later on, automatically create this folder if it does not exist
|
||||||
|
m_log.ErrorFormat("[ARCHIVER]: Inventory path {0} does not exist", invPath);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
archive
|
archive
|
||||||
= new TarArchiveReader(new GZipStream(
|
= new TarArchiveReader(new GZipStream(
|
||||||
new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress));
|
new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress));
|
||||||
|
|
||||||
userProfile = commsManager.UserService.GetUserProfile(firstName, lastName);
|
|
||||||
userInfo = commsManager.UserProfileCacheService.GetUserDetails(userProfile.ID);
|
|
||||||
|
|
||||||
byte[] data;
|
byte[] data;
|
||||||
while ((data = archive.ReadEntry(out filePath)) != null)
|
while ((data = archive.ReadEntry(out filePath)) != null)
|
||||||
{
|
{
|
||||||
|
@ -169,10 +198,18 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Load the item
|
|
||||||
InventoryItemBase item = loadInvItem(filePath, m_asciiEncoding.GetString(data));
|
InventoryItemBase item = loadInvItem(filePath, m_asciiEncoding.GetString(data));
|
||||||
|
|
||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
|
item.Creator = userProfile.ID;
|
||||||
|
item.Owner = userProfile.ID;
|
||||||
|
|
||||||
|
// Reset folder ID to the one in which we want to load it
|
||||||
|
// TODO: Properly restore entire folder structure. At the moment all items are dumped in this
|
||||||
|
// single folder no matter where in the saved folder structure they are.
|
||||||
|
item.Folder = inventoryFolder.ID;
|
||||||
|
|
||||||
userInfo.AddItem(item);
|
userInfo.AddItem(item);
|
||||||
successfulItemRestores++;
|
successfulItemRestores++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue