diff options
author | Justin Clarke Casey | 2009-02-17 15:39:18 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2009-02-17 15:39:18 +0000 |
commit | 229b69e044ca81233f248ff623b22516136bb3c6 (patch) | |
tree | 6c8d1d8f145b5bb2ec7745fe1209b1d3221496c3 /OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | |
parent | * Ignored a bunch of genned files (diff) | |
download | opensim-SC_OLD-229b69e044ca81233f248ff623b22516136bb3c6.zip opensim-SC_OLD-229b69e044ca81233f248ff623b22516136bb3c6.tar.gz opensim-SC_OLD-229b69e044ca81233f248ff623b22516136bb3c6.tar.bz2 opensim-SC_OLD-229b69e044ca81233f248ff623b22516136bb3c6.tar.xz |
* Establish InventoryArchiveSaved event for unit tests
* This is done on the inventory archiver module directly rather than Scene.EventManager - the module seems the more appropriate location
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index d916eba..456831d 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | |||
@@ -45,9 +45,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | protected TarArchiveWriter archive = new TarArchiveWriter(); | 47 | protected TarArchiveWriter archive = new TarArchiveWriter(); |
48 | protected CommunicationsManager commsManager; | ||
49 | protected Dictionary<UUID, int> assetUuids = new Dictionary<UUID, int>(); | 48 | protected Dictionary<UUID, int> assetUuids = new Dictionary<UUID, int>(); |
50 | 49 | ||
50 | private InventoryArchiverModule m_module; | ||
51 | private CachedUserInfo m_userInfo; | 51 | private CachedUserInfo m_userInfo; |
52 | private string m_invPath; | 52 | private string m_invPath; |
53 | 53 | ||
@@ -60,12 +60,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
60 | /// Constructor | 60 | /// Constructor |
61 | /// </summary> | 61 | /// </summary> |
62 | public InventoryArchiveWriteRequest( | 62 | public InventoryArchiveWriteRequest( |
63 | CachedUserInfo userInfo, string invPath, string savePath, CommunicationsManager commsManager) | 63 | InventoryArchiverModule module, CachedUserInfo userInfo, string invPath, string savePath) |
64 | : this( | 64 | : this( |
65 | module, | ||
65 | userInfo, | 66 | userInfo, |
66 | invPath, | 67 | invPath, |
67 | new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress), | 68 | new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress)) |
68 | commsManager) | ||
69 | { | 69 | { |
70 | } | 70 | } |
71 | 71 | ||
@@ -73,19 +73,33 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
73 | /// Constructor | 73 | /// Constructor |
74 | /// </summary> | 74 | /// </summary> |
75 | public InventoryArchiveWriteRequest( | 75 | public InventoryArchiveWriteRequest( |
76 | CachedUserInfo userInfo, string invPath, Stream saveStream, CommunicationsManager commsManager) | 76 | InventoryArchiverModule module, CachedUserInfo userInfo, string invPath, Stream saveStream) |
77 | { | 77 | { |
78 | m_module = module; | ||
78 | m_userInfo = userInfo; | 79 | m_userInfo = userInfo; |
79 | m_invPath = invPath; | 80 | m_invPath = invPath; |
80 | m_saveStream = saveStream; | 81 | m_saveStream = saveStream; |
81 | this.commsManager = commsManager; | ||
82 | } | 82 | } |
83 | 83 | ||
84 | protected void ReceivedAllAssets(IDictionary<UUID, AssetBase> assetsFound, ICollection<UUID> assetsNotFoundUuids) | 84 | protected void ReceivedAllAssets(IDictionary<UUID, AssetBase> assetsFound, ICollection<UUID> assetsNotFoundUuids) |
85 | { | 85 | { |
86 | AssetsArchiver assetsArchiver = new AssetsArchiver(assetsFound); | 86 | AssetsArchiver assetsArchiver = new AssetsArchiver(assetsFound); |
87 | assetsArchiver.Archive(archive); | 87 | assetsArchiver.Archive(archive); |
88 | archive.WriteTar(m_saveStream); | 88 | |
89 | Exception reportedException = null; | ||
90 | bool succeeded = true; | ||
91 | |||
92 | try | ||
93 | { | ||
94 | archive.WriteTar(m_saveStream); | ||
95 | } | ||
96 | catch (IOException e) | ||
97 | { | ||
98 | reportedException = e; | ||
99 | succeeded = false; | ||
100 | } | ||
101 | |||
102 | m_module.TriggerInventoryArchiveSaved(succeeded, m_userInfo, m_invPath, m_saveStream, reportedException); | ||
89 | } | 103 | } |
90 | 104 | ||
91 | protected void saveInvItem(InventoryItemBase inventoryItem, string path) | 105 | protected void saveInvItem(InventoryItemBase inventoryItem, string path) |
@@ -115,9 +129,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
115 | writer.WriteString(inventoryItem.Owner.ToString()); | 129 | writer.WriteString(inventoryItem.Owner.ToString()); |
116 | writer.WriteEndElement(); | 130 | writer.WriteEndElement(); |
117 | writer.WriteStartElement("Description"); | 131 | writer.WriteStartElement("Description"); |
118 | if (inventoryItem.Description.Length > 0) | 132 | writer.WriteString(inventoryItem.Description); |
119 | writer.WriteString(inventoryItem.Description); | ||
120 | else writer.WriteString("No Description"); | ||
121 | writer.WriteEndElement(); | 133 | writer.WriteEndElement(); |
122 | writer.WriteStartElement("AssetType"); | 134 | writer.WriteStartElement("AssetType"); |
123 | writer.WriteString(inventoryItem.AssetType.ToString()); | 135 | writer.WriteString(inventoryItem.AssetType.ToString()); |
@@ -191,7 +203,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
191 | // | 203 | // |
192 | // FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might | 204 | // FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might |
193 | // use a remote inventory service, though this is vanishingly rare at the moment. | 205 | // use a remote inventory service, though this is vanishingly rare at the moment. |
194 | if (null == commsManager.UserAdminService) | 206 | if (null == m_module.CommsManager.UserAdminService) |
195 | { | 207 | { |
196 | m_log.ErrorFormat( | 208 | m_log.ErrorFormat( |
197 | "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1}", | 209 | "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1}", |
@@ -242,7 +254,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
242 | } | 254 | } |
243 | else | 255 | else |
244 | { | 256 | { |
245 | m_log.InfoFormat( | 257 | m_log.DebugFormat( |
246 | "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}", | 258 | "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}", |
247 | inventoryItem.Name, inventoryItem.ID, m_invPath); | 259 | inventoryItem.Name, inventoryItem.ID, m_invPath); |
248 | 260 | ||
@@ -252,7 +264,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
252 | } | 264 | } |
253 | else | 265 | else |
254 | { | 266 | { |
255 | m_log.InfoFormat( | 267 | m_log.DebugFormat( |
256 | "[INVENTORY ARCHIVER]: Found folder {0} {1} at {2}", | 268 | "[INVENTORY ARCHIVER]: Found folder {0} {1} at {2}", |
257 | inventoryFolder.Name, inventoryFolder.ID, m_invPath); | 269 | inventoryFolder.Name, inventoryFolder.ID, m_invPath); |
258 | 270 | ||
@@ -260,7 +272,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
260 | saveInvDir(inventoryFolder, ""); | 272 | saveInvDir(inventoryFolder, ""); |
261 | } | 273 | } |
262 | 274 | ||
263 | new AssetsRequest(assetUuids.Keys, commsManager.AssetCache, ReceivedAllAssets).Execute(); | 275 | new AssetsRequest(assetUuids.Keys, m_module.CommsManager.AssetCache, ReceivedAllAssets).Execute(); |
264 | } | 276 | } |
265 | } | 277 | } |
266 | } | 278 | } |