aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-03-27 19:45:07 +0000
committerJustin Clarke Casey2009-03-27 19:45:07 +0000
commitbd8d6fad45c2a8ba06470644484e12a98b15aff5 (patch)
treeb52fa821ab45849d1f8cab0d238c7b342b820288 /OpenSim
parent* Fix single item iar saving (diff)
downloadopensim-SC-bd8d6fad45c2a8ba06470644484e12a98b15aff5.zip
opensim-SC-bd8d6fad45c2a8ba06470644484e12a98b15aff5.tar.gz
opensim-SC-bd8d6fad45c2a8ba06470644484e12a98b15aff5.tar.bz2
opensim-SC-bd8d6fad45c2a8ba06470644484e12a98b15aff5.tar.xz
* Implement * wildcard in save iar requests
* not yet ready for use
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs50
1 files changed, 36 insertions, 14 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
index 46aba68..90a51c3 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
@@ -46,6 +46,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
46 public class InventoryArchiveWriteRequest 46 public class InventoryArchiveWriteRequest
47 { 47 {
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49
50 /// <value>
51 /// Used to select all inventory nodes in a folder but not the folder itself
52 /// </value>
53 private const string STAR_WILDCARD = "*";
49 54
50 private InventoryArchiverModule m_module; 55 private InventoryArchiverModule m_module;
51 private CachedUserInfo m_userInfo; 56 private CachedUserInfo m_userInfo;
@@ -197,17 +202,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
197 /// </summary> 202 /// </summary>
198 /// <param name="inventoryFolder">The inventory folder to save</param> 203 /// <param name="inventoryFolder">The inventory folder to save</param>
199 /// <param name="path">The path to which the folder should be saved</param> 204 /// <param name="path">The path to which the folder should be saved</param>
200 protected void SaveInvFolder(InventoryFolderImpl inventoryFolder, string path) 205 /// <param name="saveThisFolderItself">If true, save this folder itself. If false, only saves contents</param>
206 protected void SaveInvFolder(InventoryFolderImpl inventoryFolder, string path, bool saveThisFolderItself)
201 { 207 {
202 path += 208 if (saveThisFolderItself)
203 string.Format( 209 {
204 "{0}{1}{2}/", 210 path +=
205 inventoryFolder.Name, 211 string.Format(
206 ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, 212 "{0}{1}{2}/",
207 inventoryFolder.ID); 213 inventoryFolder.Name,
208 214 ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR,
209 // We need to make sure that we record empty folders 215 inventoryFolder.ID);
210 m_archive.WriteDir(path); 216
217 // We need to make sure that we record empty folders
218 m_archive.WriteDir(path);
219 }
211 220
212 List<InventoryFolderImpl> childFolders = inventoryFolder.RequestListOfFolderImpls(); 221 List<InventoryFolderImpl> childFolders = inventoryFolder.RequestListOfFolderImpls();
213 List<InventoryItemBase> items = inventoryFolder.RequestListOfItems(); 222 List<InventoryItemBase> items = inventoryFolder.RequestListOfItems();
@@ -235,7 +244,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
235 244
236 foreach (InventoryFolderImpl childFolder in childFolders) 245 foreach (InventoryFolderImpl childFolder in childFolders)
237 { 246 {
238 SaveInvFolder(childFolder, path); 247 SaveInvFolder(childFolder, path, true);
239 } 248 }
240 249
241 foreach (InventoryItemBase item in items) 250 foreach (InventoryItemBase item in items)
@@ -274,14 +283,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
274 } 283 }
275 } 284 }
276 285
286 bool foundStar = false;
287
277 // Eliminate double slashes and any leading / on the path. This might be better done within InventoryFolderImpl 288 // Eliminate double slashes and any leading / on the path. This might be better done within InventoryFolderImpl
278 // itself (possibly at a small loss in efficiency). 289 // itself (possibly at a small loss in efficiency).
279 string[] components 290 string[] components
280 = m_invPath.Split(new string[] { InventoryFolderImpl.PATH_DELIMITER }, StringSplitOptions.RemoveEmptyEntries); 291 = m_invPath.Split(new string[] { InventoryFolderImpl.PATH_DELIMITER }, StringSplitOptions.RemoveEmptyEntries);
292
293 int maxComponentIndex = components.Length - 1;
294
295 // If the path terminates with a STAR then later on we want to archive all nodes in the folder but not the
296 // folder itself. This may get more sophisicated later on
297 if (maxComponentIndex >= 0 && components[maxComponentIndex] == STAR_WILDCARD)
298 {
299 foundStar = true;
300 maxComponentIndex--;
301 }
302
281 m_invPath = String.Empty; 303 m_invPath = String.Empty;
282 foreach (string c in components) 304 for (int i = 0; i <= maxComponentIndex; i++)
283 { 305 {
284 m_invPath += c + InventoryFolderImpl.PATH_DELIMITER; 306 m_invPath += components[i] + InventoryFolderImpl.PATH_DELIMITER;
285 } 307 }
286 308
287 // Annoyingly Split actually returns the original string if the input string consists only of delimiters 309 // Annoyingly Split actually returns the original string if the input string consists only of delimiters
@@ -331,7 +353,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
331 inventoryFolder.Name, inventoryFolder.ID, m_invPath); 353 inventoryFolder.Name, inventoryFolder.ID, m_invPath);
332 354
333 //recurse through all dirs getting dirs and files 355 //recurse through all dirs getting dirs and files
334 SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH); 356 SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !foundStar);
335 } 357 }
336 358
337 SaveUsers(); 359 SaveUsers();