diff options
author | Mike Mazur | 2009-03-12 06:04:17 +0000 |
---|---|---|
committer | Mike Mazur | 2009-03-12 06:04:17 +0000 |
commit | 7b2977d625d46718fe39051c778c477022153cc1 (patch) | |
tree | 58c39648c77751cf2b728e0a784e244e7e043735 /OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | |
parent | Moving TarArchive to OpenSim.Framework.Archive (diff) | |
download | opensim-SC_OLD-7b2977d625d46718fe39051c778c477022153cc1.zip opensim-SC_OLD-7b2977d625d46718fe39051c778c477022153cc1.tar.gz opensim-SC_OLD-7b2977d625d46718fe39051c778c477022153cc1.tar.bz2 opensim-SC_OLD-7b2977d625d46718fe39051c778c477022153cc1.tar.xz |
Move ArchiveConstants to OpenSim.Framework.Archive
- move a couple constants from InventoryArchiveConstants to
ArchiveConstants, now only one of these is needed
- change InventoryArchiveConstants references to ArchiveConstants
- remove InventoryArchive AssetInventoryServer plugin dependency on
OpenSim.Region.CodeModules
- trim trailing whitespace
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 71c4740..364dc28 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | |||
@@ -41,47 +41,47 @@ using OpenSim.Region.CoreModules.World.Archiver; | |||
41 | using OpenSim.Region.Framework.Scenes; | 41 | using OpenSim.Region.Framework.Scenes; |
42 | 42 | ||
43 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | 43 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver |
44 | { | 44 | { |
45 | public class InventoryArchiveWriteRequest | 45 | public class InventoryArchiveWriteRequest |
46 | { | 46 | { |
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | 48 | ||
49 | protected TarArchiveWriter m_archive; | 49 | protected TarArchiveWriter m_archive; |
50 | protected UuidGatherer m_assetGatherer; | 50 | protected UuidGatherer m_assetGatherer; |
51 | protected Dictionary<UUID, int> assetUuids = new Dictionary<UUID, int>(); | 51 | protected Dictionary<UUID, int> assetUuids = new Dictionary<UUID, int>(); |
52 | 52 | ||
53 | private InventoryArchiverModule m_module; | 53 | private InventoryArchiverModule m_module; |
54 | private CachedUserInfo m_userInfo; | 54 | private CachedUserInfo m_userInfo; |
55 | private string m_invPath; | 55 | private string m_invPath; |
56 | 56 | ||
57 | /// <value> | 57 | /// <value> |
58 | /// The stream to which the inventory archive will be saved. | 58 | /// The stream to which the inventory archive will be saved. |
59 | /// </value> | 59 | /// </value> |
60 | private Stream m_saveStream; | 60 | private Stream m_saveStream; |
61 | 61 | ||
62 | /// <summary> | 62 | /// <summary> |
63 | /// Constructor | 63 | /// Constructor |
64 | /// </summary> | 64 | /// </summary> |
65 | public InventoryArchiveWriteRequest( | 65 | public InventoryArchiveWriteRequest( |
66 | InventoryArchiverModule module, CachedUserInfo userInfo, string invPath, string savePath) | 66 | InventoryArchiverModule module, CachedUserInfo userInfo, string invPath, string savePath) |
67 | : this( | 67 | : this( |
68 | module, | 68 | module, |
69 | userInfo, | 69 | userInfo, |
70 | invPath, | 70 | invPath, |
71 | new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress)) | 71 | new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress)) |
72 | { | 72 | { |
73 | } | 73 | } |
74 | 74 | ||
75 | /// <summary> | 75 | /// <summary> |
76 | /// Constructor | 76 | /// Constructor |
77 | /// </summary> | 77 | /// </summary> |
78 | public InventoryArchiveWriteRequest( | 78 | public InventoryArchiveWriteRequest( |
79 | InventoryArchiverModule module, CachedUserInfo userInfo, string invPath, Stream saveStream) | 79 | InventoryArchiverModule module, CachedUserInfo userInfo, string invPath, Stream saveStream) |
80 | { | 80 | { |
81 | m_module = module; | 81 | m_module = module; |
82 | m_userInfo = userInfo; | 82 | m_userInfo = userInfo; |
83 | m_invPath = invPath; | 83 | m_invPath = invPath; |
84 | m_saveStream = saveStream; | 84 | m_saveStream = saveStream; |
85 | m_assetGatherer = new UuidGatherer(m_module.CommsManager.AssetCache); | 85 | m_assetGatherer = new UuidGatherer(m_module.CommsManager.AssetCache); |
86 | } | 86 | } |
87 | 87 | ||
@@ -89,22 +89,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
89 | { | 89 | { |
90 | AssetsArchiver assetsArchiver = new AssetsArchiver(assetsFound); | 90 | AssetsArchiver assetsArchiver = new AssetsArchiver(assetsFound); |
91 | assetsArchiver.Archive(m_archive); | 91 | assetsArchiver.Archive(m_archive); |
92 | 92 | ||
93 | Exception reportedException = null; | 93 | Exception reportedException = null; |
94 | bool succeeded = true; | 94 | bool succeeded = true; |
95 | 95 | ||
96 | try | 96 | try |
97 | { | 97 | { |
98 | m_archive.Close(); | 98 | m_archive.Close(); |
99 | } | 99 | } |
100 | catch (IOException e) | 100 | catch (IOException e) |
101 | { | 101 | { |
102 | m_saveStream.Close(); | 102 | m_saveStream.Close(); |
103 | reportedException = e; | 103 | reportedException = e; |
104 | succeeded = false; | 104 | succeeded = false; |
105 | } | 105 | } |
106 | 106 | ||
107 | m_module.TriggerInventoryArchiveSaved(succeeded, m_userInfo, m_invPath, m_saveStream, reportedException); | 107 | m_module.TriggerInventoryArchiveSaved(succeeded, m_userInfo, m_invPath, m_saveStream, reportedException); |
108 | } | 108 | } |
109 | 109 | ||
110 | protected void SaveInvItem(InventoryItemBase inventoryItem, string path) | 110 | protected void SaveInvItem(InventoryItemBase inventoryItem, string path) |
@@ -113,9 +113,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
113 | StringWriter sw = new StringWriter(); | 113 | StringWriter sw = new StringWriter(); |
114 | XmlTextWriter writer = new XmlTextWriter(sw); | 114 | XmlTextWriter writer = new XmlTextWriter(sw); |
115 | writer.Formatting = Formatting.Indented; | 115 | writer.Formatting = Formatting.Indented; |
116 | 116 | ||
117 | writer.WriteStartElement("InventoryItem"); | 117 | writer.WriteStartElement("InventoryItem"); |
118 | 118 | ||
119 | writer.WriteStartElement("Name"); | 119 | writer.WriteStartElement("Name"); |
120 | writer.WriteString(inventoryItem.Name); | 120 | writer.WriteString(inventoryItem.Name); |
121 | writer.WriteEndElement(); | 121 | writer.WriteEndElement(); |
@@ -170,7 +170,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
170 | writer.WriteStartElement("GroupOwned"); | 170 | writer.WriteStartElement("GroupOwned"); |
171 | writer.WriteString(inventoryItem.GroupOwned.ToString()); | 171 | writer.WriteString(inventoryItem.GroupOwned.ToString()); |
172 | writer.WriteEndElement(); | 172 | writer.WriteEndElement(); |
173 | 173 | ||
174 | writer.WriteEndElement(); | 174 | writer.WriteEndElement(); |
175 | 175 | ||
176 | m_archive.WriteFile(filename, sw.ToString()); | 176 | m_archive.WriteFile(filename, sw.ToString()); |
@@ -180,43 +180,43 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
180 | 180 | ||
181 | protected void SaveInvDir(InventoryFolderImpl inventoryFolder, string path) | 181 | protected void SaveInvDir(InventoryFolderImpl inventoryFolder, string path) |
182 | { | 182 | { |
183 | path += | 183 | path += |
184 | string.Format( | 184 | string.Format( |
185 | "{0}{1}{2}/", | 185 | "{0}{1}{2}/", |
186 | inventoryFolder.Name, | 186 | inventoryFolder.Name, |
187 | InventoryArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, | 187 | ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, |
188 | inventoryFolder.ID); | 188 | inventoryFolder.ID); |
189 | m_archive.WriteDir(path); | 189 | m_archive.WriteDir(path); |
190 | 190 | ||
191 | List<InventoryFolderImpl> childFolders = inventoryFolder.RequestListOfFolderImpls(); | 191 | List<InventoryFolderImpl> childFolders = inventoryFolder.RequestListOfFolderImpls(); |
192 | List<InventoryItemBase> items = inventoryFolder.RequestListOfItems(); | 192 | List<InventoryItemBase> items = inventoryFolder.RequestListOfItems(); |
193 | 193 | ||
194 | /* | 194 | /* |
195 | Dictionary identicalFolderNames = new Dictionary<string, int>(); | 195 | Dictionary identicalFolderNames = new Dictionary<string, int>(); |
196 | 196 | ||
197 | foreach (InventoryFolderImpl folder in inventories) | 197 | foreach (InventoryFolderImpl folder in inventories) |
198 | { | 198 | { |
199 | 199 | ||
200 | if (!identicalFolderNames.ContainsKey(folder.Name)) | 200 | if (!identicalFolderNames.ContainsKey(folder.Name)) |
201 | identicalFolderNames[folder.Name] = 0; | 201 | identicalFolderNames[folder.Name] = 0; |
202 | else | 202 | else |
203 | identicalFolderNames[folder.Name] = identicalFolderNames[folder.Name]++; | 203 | identicalFolderNames[folder.Name] = identicalFolderNames[folder.Name]++; |
204 | 204 | ||
205 | int folderNameNumber = identicalFolderName[folder.Name]; | 205 | int folderNameNumber = identicalFolderName[folder.Name]; |
206 | 206 | ||
207 | SaveInvDir( | 207 | SaveInvDir( |
208 | folder, | 208 | folder, |
209 | string.Format( | 209 | string.Format( |
210 | "{0}{1}{2}/", | 210 | "{0}{1}{2}/", |
211 | path, InventoryArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, folderNameNumber)); | 211 | path, ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, folderNameNumber)); |
212 | } | 212 | } |
213 | */ | 213 | */ |
214 | 214 | ||
215 | foreach (InventoryFolderImpl childFolder in childFolders) | 215 | foreach (InventoryFolderImpl childFolder in childFolders) |
216 | { | 216 | { |
217 | SaveInvDir(childFolder, path); | 217 | SaveInvDir(childFolder, path); |
218 | } | 218 | } |
219 | 219 | ||
220 | foreach (InventoryItemBase item in items) | 220 | foreach (InventoryItemBase item in items) |
221 | { | 221 | { |
222 | SaveInvItem(item, path); | 222 | SaveInvItem(item, path); |
@@ -232,9 +232,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
232 | InventoryItemBase inventoryItem = null; | 232 | InventoryItemBase inventoryItem = null; |
233 | 233 | ||
234 | if (!m_userInfo.HasReceivedInventory) | 234 | if (!m_userInfo.HasReceivedInventory) |
235 | { | 235 | { |
236 | // If the region server has access to the user admin service (by which users are created), | 236 | // If the region server has access to the user admin service (by which users are created), |
237 | // then we'll assume that it's okay to fiddle with the user's inventory even if they are not on the | 237 | // then we'll assume that it's okay to fiddle with the user's inventory even if they are not on the |
238 | // server. | 238 | // server. |
239 | // | 239 | // |
240 | // FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might | 240 | // FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might |
@@ -252,7 +252,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
252 | m_userInfo.FetchInventory(); | 252 | m_userInfo.FetchInventory(); |
253 | } | 253 | } |
254 | } | 254 | } |
255 | 255 | ||
256 | // Eliminate double slashes and any leading / on the path. This might be better done within InventoryFolderImpl | 256 | // Eliminate double slashes and any leading / on the path. This might be better done within InventoryFolderImpl |
257 | // itself (possibly at a small loss in efficiency). | 257 | // itself (possibly at a small loss in efficiency). |
258 | string[] components | 258 | string[] components |
@@ -280,8 +280,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
280 | { | 280 | { |
281 | inventoryItem = m_userInfo.RootFolder.FindItemByPath(m_invPath); | 281 | inventoryItem = m_userInfo.RootFolder.FindItemByPath(m_invPath); |
282 | } | 282 | } |
283 | 283 | ||
284 | m_archive = new TarArchiveWriter(m_saveStream); | 284 | m_archive = new TarArchiveWriter(m_saveStream); |
285 | 285 | ||
286 | if (null == inventoryFolder) | 286 | if (null == inventoryFolder) |
287 | { | 287 | { |
@@ -289,16 +289,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
289 | { | 289 | { |
290 | m_saveStream.Close(); | 290 | m_saveStream.Close(); |
291 | m_module.TriggerInventoryArchiveSaved( | 291 | m_module.TriggerInventoryArchiveSaved( |
292 | false, m_userInfo, m_invPath, m_saveStream, | 292 | false, m_userInfo, m_invPath, m_saveStream, |
293 | new Exception(string.Format("Could not find inventory entry at path {0}", m_invPath))); | 293 | new Exception(string.Format("Could not find inventory entry at path {0}", m_invPath))); |
294 | return; | 294 | return; |
295 | } | 295 | } |
296 | else | 296 | else |
297 | { | 297 | { |
298 | m_log.DebugFormat( | 298 | m_log.DebugFormat( |
299 | "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}", | 299 | "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}", |
300 | inventoryItem.Name, inventoryItem.ID, m_invPath); | 300 | inventoryItem.Name, inventoryItem.ID, m_invPath); |
301 | 301 | ||
302 | //get and export item info | 302 | //get and export item info |
303 | SaveInvItem(inventoryItem, m_invPath); | 303 | SaveInvItem(inventoryItem, m_invPath); |
304 | } | 304 | } |
@@ -306,11 +306,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
306 | else | 306 | else |
307 | { | 307 | { |
308 | m_log.DebugFormat( | 308 | m_log.DebugFormat( |
309 | "[INVENTORY ARCHIVER]: Found folder {0} {1} at {2}", | 309 | "[INVENTORY ARCHIVER]: Found folder {0} {1} at {2}", |
310 | inventoryFolder.Name, inventoryFolder.ID, m_invPath); | 310 | inventoryFolder.Name, inventoryFolder.ID, m_invPath); |
311 | 311 | ||
312 | //recurse through all dirs getting dirs and files | 312 | //recurse through all dirs getting dirs and files |
313 | SaveInvDir(inventoryFolder, InventoryArchiveConstants.INVENTORY_PATH); | 313 | SaveInvDir(inventoryFolder, ArchiveConstants.INVENTORY_PATH); |
314 | } | 314 | } |
315 | 315 | ||
316 | new AssetsRequest(assetUuids.Keys, m_module.CommsManager.AssetCache, ReceivedAllAssets).Execute(); | 316 | new AssetsRequest(assetUuids.Keys, m_module.CommsManager.AssetCache, ReceivedAllAssets).Execute(); |