aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-10-19 18:19:18 +0000
committerJustin Clarke Casey2008-10-19 18:19:18 +0000
commit6e98233b2e64af56a97b2f0ce2676bbca7fc5c0f (patch)
tree8aec833ccb4cc9d66cc745b5f4af3f9e6cdab1ea /OpenSim/Region
parent* move command line parsing code from inventory archive modules to opensim se... (diff)
downloadopensim-SC-6e98233b2e64af56a97b2f0ce2676bbca7fc5c0f.zip
opensim-SC-6e98233b2e64af56a97b2f0ce2676bbca7fc5c0f.tar.gz
opensim-SC-6e98233b2e64af56a97b2f0ce2676bbca7fc5c0f.tar.bz2
opensim-SC-6e98233b2e64af56a97b2f0ce2676bbca7fc5c0f.tar.xz
* 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 yet
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs57
1 files changed, 47 insertions, 10 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/Environment/Modules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 79e00cd..a29931c 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -50,9 +50,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver
50 protected Scene scene; 50 protected Scene scene;
51 protected TarArchiveReader archive; 51 protected TarArchiveReader archive;
52 private static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding(); 52 private static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding();
53 53
54 CachedUserInfo userInfo;
55 UserProfileData userProfile;
56 CommunicationsManager commsManager; 54 CommunicationsManager commsManager;
57 55
58 public InventoryArchiveReadRequest(Scene currentScene, CommunicationsManager commsManager) 56 public InventoryArchiveReadRequest(Scene currentScene, CommunicationsManager commsManager)
@@ -81,15 +79,13 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver
81 item.InvType = System.Convert.ToInt32(reader.ReadString()); 79 item.InvType = System.Convert.ToInt32(reader.ReadString());
82 reader.ReadEndElement(); 80 reader.ReadEndElement();
83 reader.ReadStartElement("CreatorUUID"); 81 reader.ReadStartElement("CreatorUUID");
84 item.Creator = UUID.Parse(reader.ReadString()); 82 item.Creator = UUID.Parse(reader.ReadString());
85 item.Creator = userProfile.ID;
86 reader.ReadEndElement(); 83 reader.ReadEndElement();
87 reader.ReadStartElement("CreationDate"); 84 reader.ReadStartElement("CreationDate");
88 item.CreationDate = System.Convert.ToInt32(reader.ReadString()); 85 item.CreationDate = System.Convert.ToInt32(reader.ReadString());
89 reader.ReadEndElement(); 86 reader.ReadEndElement();
90 reader.ReadStartElement("Owner"); 87 reader.ReadStartElement("Owner");
91 item.Owner = UUID.Parse(reader.ReadString()); 88 item.Owner = UUID.Parse(reader.ReadString());
92 item.Owner = userProfile.ID;
93 reader.ReadEndElement(); 89 reader.ReadEndElement();
94 //No description would kill it 90 //No description would kill it
95 if (reader.IsEmptyElement) 91 if (reader.IsEmptyElement)
@@ -149,14 +145,47 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver
149 int successfulAssetRestores = 0; 145 int successfulAssetRestores = 0;
150 int failedAssetRestores = 0; 146 int failedAssetRestores = 0;
151 int successfulItemRestores = 0; 147 int successfulItemRestores = 0;
148
149 UserProfileData userProfile = commsManager.UserService.GetUserProfile(firstName, lastName);
150 if (null == userProfile)
151 {
152 m_log.ErrorFormat("[CONSOLE]: Failed to find user {0} {1}", firstName, lastName);
153 return;
154 }
155
156 CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userProfile.ID);
157 if (null == userInfo)
158 {
159 m_log.ErrorFormat(
160 "[CONSOLE]: Failed to find user info for {0} {1} {2}",
161 firstName, lastName, userProfile.ID);
162
163 return;
164 }
165
166 if (!userInfo.HasReceivedInventory)
167 {
168 m_log.ErrorFormat(
169 "[CONSOLE]: Have not yet received inventory info for user {0} {1} {2}",
170 firstName, lastName, userProfile.ID);
171
172 return;
173 }
174
175 InventoryFolderImpl inventoryFolder = userInfo.RootFolder.FindFolderByPath(invPath);
176
177 if (null == inventoryFolder)
178 {
179 // TODO: Later on, automatically create this folder if it does not exist
180 m_log.ErrorFormat("[ARCHIVER]: Inventory path {0} does not exist", invPath);
181
182 return;
183 }
152 184
153 archive 185 archive
154 = new TarArchiveReader(new GZipStream( 186 = new TarArchiveReader(new GZipStream(
155 new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress)); 187 new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress));
156 188
157 userProfile = commsManager.UserService.GetUserProfile(firstName, lastName);
158 userInfo = commsManager.UserProfileCacheService.GetUserDetails(userProfile.ID);
159
160 byte[] data; 189 byte[] data;
161 while ((data = archive.ReadEntry(out filePath)) != null) 190 while ((data = archive.ReadEntry(out filePath)) != null)
162 { 191 {
@@ -169,10 +198,18 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver
169 } 198 }
170 else 199 else
171 { 200 {
172 //Load the item
173 InventoryItemBase item = loadInvItem(filePath, m_asciiEncoding.GetString(data)); 201 InventoryItemBase item = loadInvItem(filePath, m_asciiEncoding.GetString(data));
202
174 if (item != null) 203 if (item != null)
175 { 204 {
205 item.Creator = userProfile.ID;
206 item.Owner = userProfile.ID;
207
208 // Reset folder ID to the one in which we want to load it
209 // TODO: Properly restore entire folder structure. At the moment all items are dumped in this
210 // single folder no matter where in the saved folder structure they are.
211 item.Folder = inventoryFolder.ID;
212
176 userInfo.AddItem(item); 213 userInfo.AddItem(item);
177 successfulItemRestores++; 214 successfulItemRestores++;
178 } 215 }