aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs90
1 files changed, 60 insertions, 30 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
index 90e2fcd..bfa4de9 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
@@ -43,29 +43,53 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
43{ 43{
44 public class InventoryArchiveWriteRequest 44 public class InventoryArchiveWriteRequest
45 { 45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 47
48 protected TarArchiveWriter archive; 48 protected TarArchiveWriter archive = new TarArchiveWriter();
49 protected CommunicationsManager commsManager; 49 protected CommunicationsManager commsManager;
50 Dictionary<UUID, int> assetUuids; 50 protected Dictionary<UUID, int> assetUuids = new Dictionary<UUID, int>();
51
52 private string m_firstName;
53 private string m_lastName;
54 private string m_invPath;
51 55
52 /// <value> 56 /// <value>
53 /// The path to which the inventory archive will be saved. 57 /// The stream to which the inventory archive will be saved.
54 /// </value> 58 /// </value>
55 private string m_savePath; 59 private Stream m_saveStream;
56 60
57 public InventoryArchiveWriteRequest(CommunicationsManager commsManager) 61 /// <summary>
62 /// Constructor
63 /// </summary>
64 public InventoryArchiveWriteRequest(
65 string firstName, string lastName, string invPath, string savePath, CommunicationsManager commsManager)
66 : this(
67 firstName,
68 lastName,
69 invPath,
70 new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress),
71 commsManager)
72 {
73 }
74
75 /// <summary>
76 /// Constructor
77 /// </summary>
78 public InventoryArchiveWriteRequest(
79 string firstName, string lastName, string invPath, Stream saveStream, CommunicationsManager commsManager)
58 { 80 {
59 archive = new TarArchiveWriter(); 81 m_firstName = firstName;
82 m_lastName = lastName;
83 m_invPath = invPath;
84 m_saveStream = saveStream;
60 this.commsManager = commsManager; 85 this.commsManager = commsManager;
61 assetUuids = new Dictionary<UUID, int>();
62 } 86 }
63 87
64 protected void ReceivedAllAssets(IDictionary<UUID, AssetBase> assetsFound, ICollection<UUID> assetsNotFoundUuids) 88 protected void ReceivedAllAssets(IDictionary<UUID, AssetBase> assetsFound, ICollection<UUID> assetsNotFoundUuids)
65 { 89 {
66 AssetsArchiver assetsArchiver = new AssetsArchiver(assetsFound); 90 AssetsArchiver assetsArchiver = new AssetsArchiver(assetsFound);
67 assetsArchiver.Archive(archive); 91 assetsArchiver.Archive(archive);
68 archive.WriteTar(new GZipStream(new FileStream(m_savePath, FileMode.Create), CompressionMode.Compress)); 92 archive.WriteTar(m_saveStream);
69 } 93 }
70 94
71 protected void saveInvItem(InventoryItemBase inventoryItem, string path) 95 protected void saveInvItem(InventoryItemBase inventoryItem, string path)
@@ -158,21 +182,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
158 } 182 }
159 } 183 }
160 184
161 public void execute(string firstName, string lastName, string invPath, string savePath) 185 public void Execute()
162 { 186 {
163 m_savePath = savePath; 187 UserProfileData userProfile = commsManager.UserService.GetUserProfile(m_firstName, m_lastName);
164
165 UserProfileData userProfile = commsManager.UserService.GetUserProfile(firstName, lastName);
166 if (null == userProfile) 188 if (null == userProfile)
167 { 189 {
168 m_log.ErrorFormat("[CONSOLE]: Failed to find user {0} {1}", firstName, lastName); 190 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Failed to find user {0} {1}", m_firstName, m_lastName);
169 return; 191 return;
170 } 192 }
171 193
172 CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userProfile.ID); 194 CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userProfile.ID);
173 if (null == userInfo) 195 if (null == userInfo)
174 { 196 {
175 m_log.ErrorFormat("[CONSOLE]: Failed to find user info for {0} {1} {2}", firstName, lastName, userProfile.ID); 197 m_log.ErrorFormat(
198 "[INVENTORY ARCHIVER]: Failed to find user info for {0} {1} {2}",
199 m_firstName, m_lastName, userProfile.ID);
176 return; 200 return;
177 } 201 }
178 202
@@ -184,34 +208,36 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
184 // Eliminate double slashes and any leading / on the path. This might be better done within InventoryFolderImpl 208 // Eliminate double slashes and any leading / on the path. This might be better done within InventoryFolderImpl
185 // itself (possibly at a small loss in efficiency). 209 // itself (possibly at a small loss in efficiency).
186 string[] components 210 string[] components
187 = invPath.Split(new string[] { InventoryFolderImpl.PATH_DELIMITER }, StringSplitOptions.RemoveEmptyEntries); 211 = m_invPath.Split(new string[] { InventoryFolderImpl.PATH_DELIMITER }, StringSplitOptions.RemoveEmptyEntries);
188 invPath = String.Empty; 212 m_invPath = String.Empty;
189 foreach (string c in components) 213 foreach (string c in components)
190 { 214 {
191 invPath += c + InventoryFolderImpl.PATH_DELIMITER; 215 m_invPath += c + InventoryFolderImpl.PATH_DELIMITER;
192 } 216 }
193 217
194 // Annoyingly Split actually returns the original string if the input string consists only of delimiters 218 // Annoyingly Split actually returns the original string if the input string consists only of delimiters
195 // Therefore if we still start with a / after the split, then we need the root folder 219 // Therefore if we still start with a / after the split, then we need the root folder
196 if (invPath.Length == 0) 220 if (m_invPath.Length == 0)
197 { 221 {
198 inventoryFolder = userInfo.RootFolder; 222 inventoryFolder = userInfo.RootFolder;
199 } 223 }
200 else 224 else
201 { 225 {
202 invPath = invPath.Remove(invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER)); 226 m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER));
203 inventoryFolder = userInfo.RootFolder.FindFolderByPath(invPath); 227 inventoryFolder = userInfo.RootFolder.FindFolderByPath(m_invPath);
204 } 228 }
205 229
206 // The path may point to an item instead 230 // The path may point to an item instead
207 if (inventoryFolder == null) 231 if (inventoryFolder == null)
208 { 232 {
209 inventoryItem = userInfo.RootFolder.FindItemByPath(invPath); 233 inventoryItem = userInfo.RootFolder.FindItemByPath(m_invPath);
210 } 234 }
211 } 235 }
212 else 236 else
213 { 237 {
214 m_log.ErrorFormat("[CONSOLE]: Have not yet received inventory info for user {0} {1} {2}", firstName, lastName, userProfile.ID); 238 m_log.ErrorFormat(
239 "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1} {2}",
240 m_firstName, m_lastName, userProfile.ID);
215 return; 241 return;
216 } 242 }
217 243
@@ -219,21 +245,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
219 { 245 {
220 if (null == inventoryItem) 246 if (null == inventoryItem)
221 { 247 {
222 m_log.ErrorFormat("[CONSOLE]: Could not find inventory entry at path {0}", invPath); 248 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Could not find inventory entry at path {0}", m_invPath);
223 return; 249 return;
224 } 250 }
225 else 251 else
226 { 252 {
227 m_log.InfoFormat("[CONSOLE]: Found item {0} {1} at {2}", inventoryItem.Name, inventoryItem.ID, 253 m_log.InfoFormat(
228 invPath); 254 "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}",
255 inventoryItem.Name, inventoryItem.ID, m_invPath);
256
229 //get and export item info 257 //get and export item info
230 saveInvItem(inventoryItem, invPath); 258 saveInvItem(inventoryItem, m_invPath);
231 } 259 }
232 } 260 }
233 else 261 else
234 { 262 {
235 m_log.InfoFormat("[CONSOLE]: Found folder {0} {1} at {2}", inventoryFolder.Name, inventoryFolder.ID, 263 m_log.InfoFormat(
236 invPath); 264 "[INVENTORY ARCHIVER]: Found folder {0} {1} at {2}",
265 inventoryFolder.Name, inventoryFolder.ID, m_invPath);
266
237 //recurse through all dirs getting dirs and files 267 //recurse through all dirs getting dirs and files
238 saveInvDir(inventoryFolder, ""); 268 saveInvDir(inventoryFolder, "");
239 } 269 }