diff options
author | Kevin Cozens | 2012-02-10 14:09:46 -0500 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-04-13 23:31:12 +0100 |
commit | a366c05ae2fdfbcce1bc592166f89e3e286bcae4 (patch) | |
tree | d3c38c613a2e4c04ea70353afe3e4b27c6820ddd /OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | |
parent | Change threat level of osNpcStopMoveToTarget from Low to High to match other ... (diff) | |
download | opensim-SC_OLD-a366c05ae2fdfbcce1bc592166f89e3e286bcae4.zip opensim-SC_OLD-a366c05ae2fdfbcce1bc592166f89e3e286bcae4.tar.gz opensim-SC_OLD-a366c05ae2fdfbcce1bc592166f89e3e286bcae4.tar.bz2 opensim-SC_OLD-a366c05ae2fdfbcce1bc592166f89e3e286bcae4.tar.xz |
Added ability to exclude inventory items or folders when saving IAR files.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | 88 |
1 files changed, 59 insertions, 29 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index a26c73a..0ee7606 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | |||
@@ -91,7 +91,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
91 | /// Constructor | 91 | /// Constructor |
92 | /// </summary> | 92 | /// </summary> |
93 | public InventoryArchiveWriteRequest( | 93 | public InventoryArchiveWriteRequest( |
94 | Guid id, InventoryArchiverModule module, Scene scene, | 94 | Guid id, InventoryArchiverModule module, Scene scene, |
95 | UserAccount userInfo, string invPath, string savePath) | 95 | UserAccount userInfo, string invPath, string savePath) |
96 | : this( | 96 | : this( |
97 | id, | 97 | id, |
@@ -107,7 +107,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
107 | /// Constructor | 107 | /// Constructor |
108 | /// </summary> | 108 | /// </summary> |
109 | public InventoryArchiveWriteRequest( | 109 | public InventoryArchiveWriteRequest( |
110 | Guid id, InventoryArchiverModule module, Scene scene, | 110 | Guid id, InventoryArchiverModule module, Scene scene, |
111 | UserAccount userInfo, string invPath, Stream saveStream) | 111 | UserAccount userInfo, string invPath, Stream saveStream) |
112 | { | 112 | { |
113 | m_id = id; | 113 | m_id = id; |
@@ -125,7 +125,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
125 | { | 125 | { |
126 | Exception reportedException = null; | 126 | Exception reportedException = null; |
127 | bool succeeded = true; | 127 | bool succeeded = true; |
128 | 128 | ||
129 | try | 129 | try |
130 | { | 130 | { |
131 | m_archiveWriter.Close(); | 131 | m_archiveWriter.Close(); |
@@ -146,6 +146,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
146 | 146 | ||
147 | protected void SaveInvItem(InventoryItemBase inventoryItem, string path, Dictionary<string, object> options, IUserAccountService userAccountService) | 147 | protected void SaveInvItem(InventoryItemBase inventoryItem, string path, Dictionary<string, object> options, IUserAccountService userAccountService) |
148 | { | 148 | { |
149 | if (options.ContainsKey("exclude")) | ||
150 | { | ||
151 | if (((List<String>)options["exclude"]).Contains(inventoryItem.Name) || | ||
152 | ((List<String>)options["exclude"]).Contains(inventoryItem.ID.ToString())) | ||
153 | { | ||
154 | if (options.ContainsKey("verbose")) | ||
155 | { | ||
156 | m_log.InfoFormat( | ||
157 | "[INVENTORY ARCHIVER]: Skipping inventory item {0} {1} at {2}", | ||
158 | inventoryItem.Name, inventoryItem.ID, path); | ||
159 | } | ||
160 | return; | ||
161 | } | ||
162 | } | ||
163 | |||
149 | if (options.ContainsKey("verbose")) | 164 | if (options.ContainsKey("verbose")) |
150 | m_log.InfoFormat( | 165 | m_log.InfoFormat( |
151 | "[INVENTORY ARCHIVER]: Saving item {0} {1} with asset {2}", | 166 | "[INVENTORY ARCHIVER]: Saving item {0} {1} with asset {2}", |
@@ -175,12 +190,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
175 | /// <param name="options"></param> | 190 | /// <param name="options"></param> |
176 | /// <param name="userAccountService"></param> | 191 | /// <param name="userAccountService"></param> |
177 | protected void SaveInvFolder( | 192 | protected void SaveInvFolder( |
178 | InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself, | 193 | InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself, |
179 | Dictionary<string, object> options, IUserAccountService userAccountService) | 194 | Dictionary<string, object> options, IUserAccountService userAccountService) |
180 | { | 195 | { |
196 | if (options.ContainsKey("excludefolders")) | ||
197 | { | ||
198 | if (((List<String>)options["excludefolders"]).Contains(inventoryFolder.Name) || | ||
199 | ((List<String>)options["excludefolders"]).Contains(inventoryFolder.ID.ToString())) | ||
200 | { | ||
201 | if (options.ContainsKey("verbose")) | ||
202 | { | ||
203 | m_log.InfoFormat( | ||
204 | "[INVENTORY ARCHIVER]: Skipping folder {0} at {1}", | ||
205 | inventoryFolder.Name, path); | ||
206 | } | ||
207 | return; | ||
208 | } | ||
209 | } | ||
210 | |||
181 | if (options.ContainsKey("verbose")) | 211 | if (options.ContainsKey("verbose")) |
182 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Saving folder {0}", inventoryFolder.Name); | 212 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Saving folder {0}", inventoryFolder.Name); |
183 | 213 | ||
184 | if (saveThisFolderItself) | 214 | if (saveThisFolderItself) |
185 | { | 215 | { |
186 | path += CreateArchiveFolderName(inventoryFolder); | 216 | path += CreateArchiveFolderName(inventoryFolder); |
@@ -189,7 +219,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
189 | m_archiveWriter.WriteDir(path); | 219 | m_archiveWriter.WriteDir(path); |
190 | } | 220 | } |
191 | 221 | ||
192 | InventoryCollection contents | 222 | InventoryCollection contents |
193 | = m_scene.InventoryService.GetFolderContent(inventoryFolder.Owner, inventoryFolder.ID); | 223 | = m_scene.InventoryService.GetFolderContent(inventoryFolder.Owner, inventoryFolder.ID); |
194 | 224 | ||
195 | foreach (InventoryFolderBase childFolder in contents.Folders) | 225 | foreach (InventoryFolderBase childFolder in contents.Folders) |
@@ -216,16 +246,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
216 | InventoryFolderBase inventoryFolder = null; | 246 | InventoryFolderBase inventoryFolder = null; |
217 | InventoryItemBase inventoryItem = null; | 247 | InventoryItemBase inventoryItem = null; |
218 | InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(m_userInfo.PrincipalID); | 248 | InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(m_userInfo.PrincipalID); |
219 | 249 | ||
220 | bool saveFolderContentsOnly = false; | 250 | bool saveFolderContentsOnly = false; |
221 | 251 | ||
222 | // Eliminate double slashes and any leading / on the path. | 252 | // Eliminate double slashes and any leading / on the path. |
223 | string[] components | 253 | string[] components |
224 | = m_invPath.Split( | 254 | = m_invPath.Split( |
225 | new string[] { InventoryFolderImpl.PATH_DELIMITER }, StringSplitOptions.RemoveEmptyEntries); | 255 | new string[] { InventoryFolderImpl.PATH_DELIMITER }, StringSplitOptions.RemoveEmptyEntries); |
226 | 256 | ||
227 | int maxComponentIndex = components.Length - 1; | 257 | int maxComponentIndex = components.Length - 1; |
228 | 258 | ||
229 | // If the path terminates with a STAR then later on we want to archive all nodes in the folder but not the | 259 | // If the path terminates with a STAR then later on we want to archive all nodes in the folder but not the |
230 | // folder itself. This may get more sophisicated later on | 260 | // folder itself. This may get more sophisicated later on |
231 | if (maxComponentIndex >= 0 && components[maxComponentIndex] == STAR_WILDCARD) | 261 | if (maxComponentIndex >= 0 && components[maxComponentIndex] == STAR_WILDCARD) |
@@ -233,13 +263,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
233 | saveFolderContentsOnly = true; | 263 | saveFolderContentsOnly = true; |
234 | maxComponentIndex--; | 264 | maxComponentIndex--; |
235 | } | 265 | } |
236 | 266 | ||
237 | m_invPath = String.Empty; | 267 | m_invPath = String.Empty; |
238 | for (int i = 0; i <= maxComponentIndex; i++) | 268 | for (int i = 0; i <= maxComponentIndex; i++) |
239 | { | 269 | { |
240 | m_invPath += components[i] + InventoryFolderImpl.PATH_DELIMITER; | 270 | m_invPath += components[i] + InventoryFolderImpl.PATH_DELIMITER; |
241 | } | 271 | } |
242 | 272 | ||
243 | // Annoyingly Split actually returns the original string if the input string consists only of delimiters | 273 | // Annoyingly Split actually returns the original string if the input string consists only of delimiters |
244 | // Therefore if we still start with a / after the split, then we need the root folder | 274 | // Therefore if we still start with a / after the split, then we need the root folder |
245 | if (m_invPath.Length == 0) | 275 | if (m_invPath.Length == 0) |
@@ -249,25 +279,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
249 | else | 279 | else |
250 | { | 280 | { |
251 | m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER)); | 281 | m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER)); |
252 | List<InventoryFolderBase> candidateFolders | 282 | List<InventoryFolderBase> candidateFolders |
253 | = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, rootFolder, m_invPath); | 283 | = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, rootFolder, m_invPath); |
254 | if (candidateFolders.Count > 0) | 284 | if (candidateFolders.Count > 0) |
255 | inventoryFolder = candidateFolders[0]; | 285 | inventoryFolder = candidateFolders[0]; |
256 | } | 286 | } |
257 | 287 | ||
258 | // The path may point to an item instead | 288 | // The path may point to an item instead |
259 | if (inventoryFolder == null) | 289 | if (inventoryFolder == null) |
260 | inventoryItem = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, rootFolder, m_invPath); | 290 | inventoryItem = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, rootFolder, m_invPath); |
261 | 291 | ||
262 | if (null == inventoryFolder && null == inventoryItem) | 292 | if (null == inventoryFolder && null == inventoryItem) |
263 | { | 293 | { |
264 | // We couldn't find the path indicated | 294 | // We couldn't find the path indicated |
265 | string errorMessage = string.Format("Aborted save. Could not find inventory path {0}", m_invPath); | 295 | string errorMessage = string.Format("Aborted save. Could not find inventory path {0}", m_invPath); |
266 | Exception e = new InventoryArchiverException(errorMessage); | 296 | Exception e = new InventoryArchiverException(errorMessage); |
267 | m_module.TriggerInventoryArchiveSaved(m_id, false, m_userInfo, m_invPath, m_saveStream, e); | 297 | m_module.TriggerInventoryArchiveSaved(m_id, false, m_userInfo, m_invPath, m_saveStream, e); |
268 | throw e; | 298 | throw e; |
269 | } | 299 | } |
270 | 300 | ||
271 | m_archiveWriter = new TarArchiveWriter(m_saveStream); | 301 | m_archiveWriter = new TarArchiveWriter(m_saveStream); |
272 | 302 | ||
273 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Adding control file to archive."); | 303 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Adding control file to archive."); |
@@ -281,10 +311,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
281 | { | 311 | { |
282 | m_log.DebugFormat( | 312 | m_log.DebugFormat( |
283 | "[INVENTORY ARCHIVER]: Found folder {0} {1} at {2}", | 313 | "[INVENTORY ARCHIVER]: Found folder {0} {1} at {2}", |
284 | inventoryFolder.Name, | 314 | inventoryFolder.Name, |
285 | inventoryFolder.ID, | 315 | inventoryFolder.ID, |
286 | m_invPath == String.Empty ? InventoryFolderImpl.PATH_DELIMITER : m_invPath); | 316 | m_invPath == String.Empty ? InventoryFolderImpl.PATH_DELIMITER : m_invPath); |
287 | 317 | ||
288 | //recurse through all dirs getting dirs and files | 318 | //recurse through all dirs getting dirs and files |
289 | SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !saveFolderContentsOnly, options, userAccountService); | 319 | SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !saveFolderContentsOnly, options, userAccountService); |
290 | } | 320 | } |
@@ -293,10 +323,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
293 | m_log.DebugFormat( | 323 | m_log.DebugFormat( |
294 | "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}", | 324 | "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}", |
295 | inventoryItem.Name, inventoryItem.ID, m_invPath); | 325 | inventoryItem.Name, inventoryItem.ID, m_invPath); |
296 | 326 | ||
297 | SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH, options, userAccountService); | 327 | SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH, options, userAccountService); |
298 | } | 328 | } |
299 | 329 | ||
300 | // Don't put all this profile information into the archive right now. | 330 | // Don't put all this profile information into the archive right now. |
301 | //SaveUsers(); | 331 | //SaveUsers(); |
302 | 332 | ||
@@ -355,7 +385,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
355 | /// | 385 | /// |
356 | /// These names are prepended with an inventory folder's UUID so that more than one folder can have the | 386 | /// These names are prepended with an inventory folder's UUID so that more than one folder can have the |
357 | /// same name | 387 | /// same name |
358 | /// | 388 | /// |
359 | /// <param name="folder"></param> | 389 | /// <param name="folder"></param> |
360 | /// <returns></returns> | 390 | /// <returns></returns> |
361 | public static string CreateArchiveFolderName(InventoryFolderBase folder) | 391 | public static string CreateArchiveFolderName(InventoryFolderBase folder) |
@@ -369,7 +399,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
369 | /// | 399 | /// |
370 | /// These names are prepended with an inventory item's UUID so that more than one item can have the | 400 | /// These names are prepended with an inventory item's UUID so that more than one item can have the |
371 | /// same name | 401 | /// same name |
372 | /// | 402 | /// |
373 | /// <param name="item"></param> | 403 | /// <param name="item"></param> |
374 | /// <returns></returns> | 404 | /// <returns></returns> |
375 | public static string CreateArchiveItemName(InventoryItemBase item) | 405 | public static string CreateArchiveItemName(InventoryItemBase item) |
@@ -415,7 +445,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
415 | public string CreateControlFile(Dictionary<string, object> options) | 445 | public string CreateControlFile(Dictionary<string, object> options) |
416 | { | 446 | { |
417 | int majorVersion, minorVersion; | 447 | int majorVersion, minorVersion; |
418 | 448 | ||
419 | if (options.ContainsKey("home")) | 449 | if (options.ContainsKey("home")) |
420 | { | 450 | { |
421 | majorVersion = 1; | 451 | majorVersion = 1; |
@@ -425,10 +455,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
425 | { | 455 | { |
426 | majorVersion = 0; | 456 | majorVersion = 0; |
427 | minorVersion = 3; | 457 | minorVersion = 3; |
428 | } | 458 | } |
429 | 459 | ||
430 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Creating version {0}.{1} IAR", majorVersion, minorVersion); | 460 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Creating version {0}.{1} IAR", majorVersion, minorVersion); |
431 | 461 | ||
432 | StringWriter sw = new StringWriter(); | 462 | StringWriter sw = new StringWriter(); |
433 | XmlTextWriter xtw = new XmlTextWriter(sw); | 463 | XmlTextWriter xtw = new XmlTextWriter(sw); |
434 | xtw.Formatting = Formatting.Indented; | 464 | xtw.Formatting = Formatting.Indented; |
@@ -450,4 +480,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
450 | return s; | 480 | return s; |
451 | } | 481 | } |
452 | } | 482 | } |
453 | } \ No newline at end of file | 483 | } |