diff options
author | Justin Clarke Casey | 2009-03-04 20:31:03 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2009-03-04 20:31:03 +0000 |
commit | b52ac542ade6af9ad404dcebf68be3bef769b0e1 (patch) | |
tree | 2a304eb111ed61080c04893f14f89858bedda2e2 /OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | |
parent | * Whoops. Left MiniModule enabled to anyone. (potential security risk). Disab... (diff) | |
download | opensim-SC_OLD-b52ac542ade6af9ad404dcebf68be3bef769b0e1.zip opensim-SC_OLD-b52ac542ade6af9ad404dcebf68be3bef769b0e1.tar.gz opensim-SC_OLD-b52ac542ade6af9ad404dcebf68be3bef769b0e1.tar.bz2 opensim-SC_OLD-b52ac542ade6af9ad404dcebf68be3bef769b0e1.tar.xz |
* Add the abilty to load and save iar item nodes where folders have identical names
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | 55 |
1 files changed, 41 insertions, 14 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 2b071f0..357ed40 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | |||
@@ -106,14 +106,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
106 | m_module.TriggerInventoryArchiveSaved(succeeded, m_userInfo, m_invPath, m_saveStream, reportedException); | 106 | m_module.TriggerInventoryArchiveSaved(succeeded, m_userInfo, m_invPath, m_saveStream, reportedException); |
107 | } | 107 | } |
108 | 108 | ||
109 | protected void saveInvItem(InventoryItemBase inventoryItem, string path) | 109 | protected void SaveInvItem(InventoryItemBase inventoryItem, string path) |
110 | { | 110 | { |
111 | string filename = string.Format("{0}{1}_{2}.xml", path, inventoryItem.Name, inventoryItem.ID); | 111 | string filename = string.Format("{0}{1}_{2}.xml", path, inventoryItem.Name, inventoryItem.ID); |
112 | StringWriter sw = new StringWriter(); | 112 | StringWriter sw = new StringWriter(); |
113 | XmlTextWriter writer = new XmlTextWriter(sw); | 113 | XmlTextWriter writer = new XmlTextWriter(sw); |
114 | writer.Formatting = Formatting.Indented; | 114 | writer.Formatting = Formatting.Indented; |
115 | 115 | ||
116 | writer.WriteStartElement("InventoryObject"); | 116 | writer.WriteStartElement("InventoryItem"); |
117 | |||
117 | writer.WriteStartElement("Name"); | 118 | writer.WriteStartElement("Name"); |
118 | writer.WriteString(inventoryItem.Name); | 119 | writer.WriteString(inventoryItem.Name); |
119 | writer.WriteEndElement(); | 120 | writer.WriteEndElement(); |
@@ -168,9 +169,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
168 | writer.WriteStartElement("GroupOwned"); | 169 | writer.WriteStartElement("GroupOwned"); |
169 | writer.WriteString(inventoryItem.GroupOwned.ToString()); | 170 | writer.WriteString(inventoryItem.GroupOwned.ToString()); |
170 | writer.WriteEndElement(); | 171 | writer.WriteEndElement(); |
171 | writer.WriteStartElement("ParentFolderID"); | 172 | |
172 | writer.WriteString(inventoryItem.Folder.ToString()); | ||
173 | writer.WriteEndElement(); | ||
174 | writer.WriteEndElement(); | 173 | writer.WriteEndElement(); |
175 | 174 | ||
176 | archive.AddFile(filename, sw.ToString()); | 175 | archive.AddFile(filename, sw.ToString()); |
@@ -178,20 +177,48 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
178 | m_assetGatherer.GatherAssetUuids(inventoryItem.AssetID, (AssetType)inventoryItem.AssetType, assetUuids); | 177 | m_assetGatherer.GatherAssetUuids(inventoryItem.AssetID, (AssetType)inventoryItem.AssetType, assetUuids); |
179 | } | 178 | } |
180 | 179 | ||
181 | protected void saveInvDir(InventoryFolderImpl inventoryFolder, string path) | 180 | protected void SaveInvDir(InventoryFolderImpl inventoryFolder, string path) |
182 | { | 181 | { |
183 | List<InventoryFolderImpl> inventories = inventoryFolder.RequestListOfFolderImpls(); | 182 | path += |
184 | List<InventoryItemBase> items = inventoryFolder.RequestListOfItems(); | 183 | string.Format( |
185 | string newPath = path + inventoryFolder.Name + InventoryFolderImpl.PATH_DELIMITER; | 184 | "{0}{1}{2}/", |
186 | archive.AddDir(newPath); | 185 | inventoryFolder.Name, |
186 | InventoryArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, | ||
187 | inventoryFolder.ID); | ||
188 | archive.AddDir(path); | ||
189 | |||
190 | List<InventoryFolderImpl> childFolders = inventoryFolder.RequestListOfFolderImpls(); | ||
191 | List<InventoryItemBase> items = inventoryFolder.RequestListOfItems(); | ||
192 | |||
193 | /* | ||
194 | Dictionary identicalFolderNames = new Dictionary<string, int>(); | ||
187 | 195 | ||
188 | foreach (InventoryFolderImpl folder in inventories) | 196 | foreach (InventoryFolderImpl folder in inventories) |
189 | { | 197 | { |
190 | saveInvDir(folder, newPath); | 198 | |
199 | if (!identicalFolderNames.ContainsKey(folder.Name)) | ||
200 | identicalFolderNames[folder.Name] = 0; | ||
201 | else | ||
202 | identicalFolderNames[folder.Name] = identicalFolderNames[folder.Name]++; | ||
203 | |||
204 | int folderNameNumber = identicalFolderName[folder.Name]; | ||
205 | |||
206 | SaveInvDir( | ||
207 | folder, | ||
208 | string.Format( | ||
209 | "{0}{1}{2}/", | ||
210 | path, InventoryArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, folderNameNumber)); | ||
211 | } | ||
212 | */ | ||
213 | |||
214 | foreach (InventoryFolderImpl childFolder in childFolders) | ||
215 | { | ||
216 | SaveInvDir(childFolder, path); | ||
191 | } | 217 | } |
218 | |||
192 | foreach (InventoryItemBase item in items) | 219 | foreach (InventoryItemBase item in items) |
193 | { | 220 | { |
194 | saveInvItem(item, newPath); | 221 | SaveInvItem(item, path); |
195 | } | 222 | } |
196 | } | 223 | } |
197 | 224 | ||
@@ -270,7 +297,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
270 | inventoryItem.Name, inventoryItem.ID, m_invPath); | 297 | inventoryItem.Name, inventoryItem.ID, m_invPath); |
271 | 298 | ||
272 | //get and export item info | 299 | //get and export item info |
273 | saveInvItem(inventoryItem, m_invPath); | 300 | SaveInvItem(inventoryItem, m_invPath); |
274 | } | 301 | } |
275 | } | 302 | } |
276 | else | 303 | else |
@@ -280,7 +307,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
280 | inventoryFolder.Name, inventoryFolder.ID, m_invPath); | 307 | inventoryFolder.Name, inventoryFolder.ID, m_invPath); |
281 | 308 | ||
282 | //recurse through all dirs getting dirs and files | 309 | //recurse through all dirs getting dirs and files |
283 | saveInvDir(inventoryFolder, InventoryArchiveConstants.INVENTORY_PATH); | 310 | SaveInvDir(inventoryFolder, InventoryArchiveConstants.INVENTORY_PATH); |
284 | } | 311 | } |
285 | 312 | ||
286 | new AssetsRequest(assetUuids.Keys, m_module.CommsManager.AssetCache, ReceivedAllAssets).Execute(); | 313 | new AssetsRequest(assetUuids.Keys, m_module.CommsManager.AssetCache, ReceivedAllAssets).Execute(); |