diff options
author | Justin Clark-Casey (justincc) | 2009-09-08 16:12:15 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2009-09-08 16:12:15 +0100 |
commit | 76b21860e9f727391849c9b38c620b9bc16e4312 (patch) | |
tree | 8191cb1f4ec2a7359d35b1d3b8eeeb52bcfb4907 /OpenSim/Region/CoreModules/Avatar | |
parent | Only allow iar load/save if user is logged in to the region simulator (diff) | |
download | opensim-SC_OLD-76b21860e9f727391849c9b38c620b9bc16e4312.zip opensim-SC_OLD-76b21860e9f727391849c9b38c620b9bc16e4312.tar.gz opensim-SC_OLD-76b21860e9f727391849c9b38c620b9bc16e4312.tar.bz2 opensim-SC_OLD-76b21860e9f727391849c9b38c620b9bc16e4312.tar.xz |
refactor iar name generation
slightly change the format of item archive names
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | 67 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | 31 |
2 files changed, 71 insertions, 27 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index dee4a5d..b178772 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | |||
@@ -138,7 +138,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
138 | 138 | ||
139 | protected void SaveInvItem(InventoryItemBase inventoryItem, string path) | 139 | protected void SaveInvItem(InventoryItemBase inventoryItem, string path) |
140 | { | 140 | { |
141 | string filename = string.Format("{0}{1}_{2}.xml", path, inventoryItem.Name, inventoryItem.ID); | 141 | string filename = path + CreateArchiveItemName(inventoryItem); |
142 | 142 | ||
143 | // Record the creator of this item for user record purposes (which might go away soon) | 143 | // Record the creator of this item for user record purposes (which might go away soon) |
144 | m_userUuids[inventoryItem.CreatorIdAsUuid] = 1; | 144 | m_userUuids[inventoryItem.CreatorIdAsUuid] = 1; |
@@ -162,12 +162,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
162 | { | 162 | { |
163 | if (saveThisFolderItself) | 163 | if (saveThisFolderItself) |
164 | { | 164 | { |
165 | path += | 165 | path += CreateArchiveFolderName(inventoryFolder); |
166 | string.Format( | ||
167 | "{0}{1}{2}/", | ||
168 | inventoryFolder.Name, | ||
169 | ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, | ||
170 | inventoryFolder.ID); | ||
171 | 166 | ||
172 | // We need to make sure that we record empty folders | 167 | // We need to make sure that we record empty folders |
173 | m_archiveWriter.WriteDir(path); | 168 | m_archiveWriter.WriteDir(path); |
@@ -356,5 +351,63 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
356 | } | 351 | } |
357 | } | 352 | } |
358 | } | 353 | } |
354 | |||
355 | /// <summary> | ||
356 | /// Create the archive name for a particular folder. | ||
357 | /// </summary> | ||
358 | /// | ||
359 | /// These names are prepended with an inventory folder's UUID so that more than one folder can have the | ||
360 | /// same name | ||
361 | /// | ||
362 | /// <param name="folder"></param> | ||
363 | /// <returns></returns> | ||
364 | public static string CreateArchiveFolderName(InventoryFolderBase folder) | ||
365 | { | ||
366 | return CreateArchiveFolderName(folder.Name, folder.ID); | ||
367 | } | ||
368 | |||
369 | /// <summary> | ||
370 | /// Create the archive name for a particular item. | ||
371 | /// </summary> | ||
372 | /// | ||
373 | /// These names are prepended with an inventory item's UUID so that more than one item can have the | ||
374 | /// same name | ||
375 | /// | ||
376 | /// <param name="item"></param> | ||
377 | /// <returns></returns> | ||
378 | public static string CreateArchiveItemName(InventoryItemBase item) | ||
379 | { | ||
380 | return CreateArchiveItemName(item.Name, item.ID); | ||
381 | } | ||
382 | |||
383 | /// <summary> | ||
384 | /// Create an archive folder name given its constituent components | ||
385 | /// </summary> | ||
386 | /// <param name="name"></param> | ||
387 | /// <param name="id"></param> | ||
388 | /// <returns></returns> | ||
389 | public static string CreateArchiveFolderName(string name, UUID id) | ||
390 | { | ||
391 | return string.Format( | ||
392 | "{0}{1}{2}/", | ||
393 | name, | ||
394 | ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, | ||
395 | id); | ||
396 | } | ||
397 | |||
398 | /// <summary> | ||
399 | /// Create an archive item name given its constituent components | ||
400 | /// </summary> | ||
401 | /// <param name="name"></param> | ||
402 | /// <param name="id"></param> | ||
403 | /// <returns></returns> | ||
404 | public static string CreateArchiveItemName(string name, UUID id) | ||
405 | { | ||
406 | return string.Format( | ||
407 | "{0}{1}{2}.xml", | ||
408 | name, | ||
409 | ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, | ||
410 | id); | ||
411 | } | ||
359 | } | 412 | } |
360 | } | 413 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index d579a81..5461ea2 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -153,19 +153,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
153 | //bool gotControlFile = false; | 153 | //bool gotControlFile = false; |
154 | bool gotObject1File = false; | 154 | bool gotObject1File = false; |
155 | //bool gotObject2File = false; | 155 | //bool gotObject2File = false; |
156 | string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1); | ||
156 | string expectedObject1FilePath = string.Format( | 157 | string expectedObject1FilePath = string.Format( |
157 | "{0}{1}/{2}_{3}.xml", | 158 | "{0}{1}{2}", |
158 | ArchiveConstants.INVENTORY_PATH, | 159 | ArchiveConstants.INVENTORY_PATH, |
159 | string.Format( | 160 | InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder), |
160 | "Objects{0}{1}", ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, objsFolder.ID), | 161 | expectedObject1FileName); |
161 | item1.Name, | ||
162 | item1Id); | ||
163 | |||
164 | // string expectedObject2FileName = string.Format( | ||
165 | // "{0}_{1:000}-{2:000}-{3:000}__{4}.xml", | ||
166 | // part2.Name, | ||
167 | // Math.Round(part2.GroupPosition.X), Math.Round(part2.GroupPosition.Y), Math.Round(part2.GroupPosition.Z), | ||
168 | // part2.UUID); | ||
169 | 162 | ||
170 | string filePath; | 163 | string filePath; |
171 | TarArchiveReader.TarEntryType tarEntryType; | 164 | TarArchiveReader.TarEntryType tarEntryType; |
@@ -187,7 +180,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
187 | // | 180 | // |
188 | // if (fileName.StartsWith(part1.Name)) | 181 | // if (fileName.StartsWith(part1.Name)) |
189 | // { | 182 | // { |
190 | Assert.That(filePath, Is.EqualTo(expectedObject1FilePath)); | 183 | Assert.That(expectedObject1FilePath, Is.EqualTo(filePath)); |
191 | gotObject1File = true; | 184 | gotObject1File = true; |
192 | // } | 185 | // } |
193 | // else if (fileName.StartsWith(part2.Name)) | 186 | // else if (fileName.StartsWith(part2.Name)) |
@@ -385,16 +378,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
385 | string folder2Name = "b"; | 378 | string folder2Name = "b"; |
386 | string itemName = "c.lsl"; | 379 | string itemName = "c.lsl"; |
387 | 380 | ||
388 | string folder1ArchiveName | 381 | string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random()); |
389 | = string.Format( | 382 | string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); |
390 | "{0}{1}{2}", folder1Name, ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, UUID.Random()); | 383 | string itemArchiveName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); |
391 | string folder2ArchiveName | 384 | |
392 | = string.Format( | ||
393 | "{0}{1}{2}", folder2Name, ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, UUID.Random()); | ||
394 | string itemArchivePath | 385 | string itemArchivePath |
395 | = string.Format( | 386 | = string.Format( |
396 | "{0}{1}/{2}/{3}", | 387 | "{0}{1}{2}{3}", |
397 | ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemName); | 388 | ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName); |
398 | 389 | ||
399 | //Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder); | 390 | //Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder); |
400 | 391 | ||