aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs67
1 files changed, 45 insertions, 22 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 704296c..7e57275 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -50,13 +50,37 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
50 protected TarArchiveReader archive; 50 protected TarArchiveReader archive;
51 private static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding(); 51 private static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding();
52 52
53 private string m_firstName;
54 private string m_lastName;
55 private string m_invPath;
56
57 /// <value>
58 /// The stream from which the inventory archive will be loaded.
59 /// </value>
60 private Stream m_loadStream;
61
53 CommunicationsManager commsManager; 62 CommunicationsManager commsManager;
54 63
55 public InventoryArchiveReadRequest(CommunicationsManager commsManager) 64 public InventoryArchiveReadRequest(
65 string firstName, string lastName, string invPath, string loadPath, CommunicationsManager commsManager)
66 : this(
67 firstName,
68 lastName,
69 invPath,
70 new GZipStream(new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress),
71 commsManager)
56 { 72 {
57 //List<string> serialisedObjects = new List<string>();
58 this.commsManager = commsManager;
59 } 73 }
74
75 public InventoryArchiveReadRequest(
76 string firstName, string lastName, string invPath, Stream loadStream, CommunicationsManager commsManager)
77 {
78 m_firstName = firstName;
79 m_lastName = lastName;
80 m_invPath = invPath;
81 m_loadStream = loadStream;
82 this.commsManager = commsManager;
83 }
60 84
61 protected InventoryItemBase loadInvItem(string path, string contents) 85 protected InventoryItemBase loadInvItem(string path, string contents)
62 { 86 {
@@ -137,17 +161,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
137 return item; 161 return item;
138 } 162 }
139 163
140 public void execute(string firstName, string lastName, string invPath, string loadPath) 164 public void Execute()
141 { 165 {
142 string filePath = "ERROR"; 166 string filePath = "ERROR";
143 int successfulAssetRestores = 0; 167 int successfulAssetRestores = 0;
144 int failedAssetRestores = 0; 168 int failedAssetRestores = 0;
145 int successfulItemRestores = 0; 169 int successfulItemRestores = 0;
146 170
147 UserProfileData userProfile = commsManager.UserService.GetUserProfile(firstName, lastName); 171 UserProfileData userProfile = commsManager.UserService.GetUserProfile(m_firstName, m_lastName);
148 if (null == userProfile) 172 if (null == userProfile)
149 { 173 {
150 m_log.ErrorFormat("[CONSOLE]: Failed to find user {0} {1}", firstName, lastName); 174 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Failed to find user {0} {1}", m_firstName, m_lastName);
151 return; 175 return;
152 } 176 }
153 177
@@ -155,8 +179,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
155 if (null == userInfo) 179 if (null == userInfo)
156 { 180 {
157 m_log.ErrorFormat( 181 m_log.ErrorFormat(
158 "[CONSOLE]: Failed to find user info for {0} {1} {2}", 182 "[INVENTORY ARCHIVER]: Failed to find user info for {0} {1} {2}",
159 firstName, lastName, userProfile.ID); 183 m_firstName, m_lastName, userProfile.ID);
160 184
161 return; 185 return;
162 } 186 }
@@ -164,33 +188,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
164 if (!userInfo.HasReceivedInventory) 188 if (!userInfo.HasReceivedInventory)
165 { 189 {
166 m_log.ErrorFormat( 190 m_log.ErrorFormat(
167 "[CONSOLE]: Have not yet received inventory info for user {0} {1} {2}", 191 "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1} {2}",
168 firstName, lastName, userProfile.ID); 192 m_firstName, m_lastName, userProfile.ID);
169 193
170 return; 194 return;
171 } 195 }
172 196
173 InventoryFolderImpl inventoryFolder = userInfo.RootFolder.FindFolderByPath(invPath); 197 InventoryFolderImpl inventoryFolder = userInfo.RootFolder.FindFolderByPath(m_invPath);
174 198
175 if (null == inventoryFolder) 199 if (null == inventoryFolder)
176 { 200 {
177 // TODO: Later on, automatically create this folder if it does not exist 201 // TODO: Later on, automatically create this folder if it does not exist
178 m_log.ErrorFormat("[ARCHIVER]: Inventory path {0} does not exist", invPath); 202 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath);
179 203
180 return; 204 return;
181 } 205 }
182 206
183 archive 207 archive = new TarArchiveReader(m_loadStream);
184 = new TarArchiveReader(new GZipStream(
185 new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress));
186 208
187 byte[] data; 209 byte[] data;
188 TarArchiveReader.TarEntryType entryType; 210 TarArchiveReader.TarEntryType entryType;
189 while ((data = archive.ReadEntry(out filePath, out entryType)) != null) 211 while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
190 { 212 {
191 if (entryType == TarArchiveReader.TarEntryType.TYPE_DIRECTORY) { 213 if (entryType == TarArchiveReader.TarEntryType.TYPE_DIRECTORY) {
192 m_log.WarnFormat("[ARCHIVER]: Ignoring directory entry {0}", filePath); 214 m_log.WarnFormat("[INVENTORY ARCHIVER]: Ignoring directory entry {0}", filePath);
193 } else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) 215 }
216 else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
194 { 217 {
195 if (LoadAsset(filePath, data)) 218 if (LoadAsset(filePath, data))
196 successfulAssetRestores++; 219 successfulAssetRestores++;
@@ -219,8 +242,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
219 242
220 archive.Close(); 243 archive.Close();
221 244
222 m_log.DebugFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores); 245 m_log.DebugFormat("[INVENTORY ARCHIVER]: Restored {0} assets", successfulAssetRestores);
223 m_log.InfoFormat("[ARCHIVER]: Restored {0} items", successfulItemRestores); 246 m_log.InfoFormat("[INVENTORY ARCHIVER]: Restored {0} items", successfulItemRestores);
224 } 247 }
225 248
226 /// <summary> 249 /// <summary>
@@ -239,7 +262,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
239 if (i == -1) 262 if (i == -1)
240 { 263 {
241 m_log.ErrorFormat( 264 m_log.ErrorFormat(
242 "[ARCHIVER]: Could not find extension information in asset path {0} since it's missing the separator {1}. Skipping", 265 "[INVENTORY ARCHIVER]: Could not find extension information in asset path {0} since it's missing the separator {1}. Skipping",
243 assetPath, ArchiveConstants.ASSET_EXTENSION_SEPARATOR); 266 assetPath, ArchiveConstants.ASSET_EXTENSION_SEPARATOR);
244 267
245 return false; 268 return false;
@@ -252,7 +275,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
252 { 275 {
253 sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; 276 sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension];
254 277
255 m_log.DebugFormat("[ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); 278 m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType);
256 279
257 AssetBase asset = new AssetBase(new UUID(uuid), "RandomName"); 280 AssetBase asset = new AssetBase(new UUID(uuid), "RandomName");
258 281
@@ -266,7 +289,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
266 else 289 else
267 { 290 {
268 m_log.ErrorFormat( 291 m_log.ErrorFormat(
269 "[ARCHIVER]: Tried to dearchive data with path {0} with an unknown type extension {1}", 292 "[INVENTORY ARCHIVER]: Tried to dearchive data with path {0} with an unknown type extension {1}",
270 assetPath, extension); 293 assetPath, extension);
271 294
272 return false; 295 return false;