Make it so that "load iar / ..." does not save the 'root' "My Inventory" folder.

Really "My Inventory" is just the name of the root, it isn't a folder in its own right.
This also makes it more intuitive for users to save whole inventory iars for backup/later restoration, as they don't need to remember to use /*
/* will still work and this is a special case just for the root
If you want to save only the contents of other folders (rather than the folder itself), you still need to specify something like a/b/*
Added a regression test for this case.
0.7.4-extended
Justin Clark-Casey (justincc) 2013-02-16 00:49:06 +00:00
parent f1b49aaa99
commit f7de17c9d9
2 changed files with 60 additions and 1 deletions

View File

@ -266,6 +266,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
saveFolderContentsOnly = true; saveFolderContentsOnly = true;
maxComponentIndex--; maxComponentIndex--;
} }
else if (maxComponentIndex == -1)
{
// If the user has just specified "/", then don't save the root "My Inventory" folder. This is
// more intuitive then requiring the user to specify "/*" for this.
saveFolderContentsOnly = true;
}
m_invPath = String.Empty; m_invPath = String.Empty;
for (int i = 0; i <= maxComponentIndex; i++) for (int i = 0; i <= maxComponentIndex; i++)

View File

@ -122,11 +122,64 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
Assert.That(iarr.ControlFileLoaded, Is.True); Assert.That(iarr.ControlFileLoaded, Is.True);
} }
[Test]
public void TestSaveRootFolderToIar()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
string userFirstName = "Jock";
string userLastName = "Stirrup";
string userPassword = "troll";
UUID userId = TestHelpers.ParseTail(0x20);
UserAccountHelpers.CreateUserWithInventory(m_scene, userFirstName, userLastName, userId, userPassword);
MemoryStream archiveWriteStream = new MemoryStream();
m_archiverModule.OnInventoryArchiveSaved += SaveCompleted;
mre.Reset();
m_archiverModule.ArchiveInventory(
Guid.NewGuid(), userFirstName, userLastName, "/", userPassword, archiveWriteStream);
mre.WaitOne(60000, false);
// Test created iar
byte[] archive = archiveWriteStream.ToArray();
MemoryStream archiveReadStream = new MemoryStream(archive);
TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
// InventoryArchiveUtils.
bool gotObjectsFolder = false;
string objectsFolderName
= string.Format(
"{0}{1}",
ArchiveConstants.INVENTORY_PATH,
InventoryArchiveWriteRequest.CreateArchiveFolderName(
UserInventoryHelpers.GetInventoryFolder(m_scene.InventoryService, userId, "Objects")));
string filePath;
TarArchiveReader.TarEntryType tarEntryType;
while (tar.ReadEntry(out filePath, out tarEntryType) != null)
{
// Console.WriteLine("Got {0}", filePath);
// Lazily, we only bother to look for the system objects folder created when we call CreateUserWithInventory()
// XXX: But really we need to stop all that stuff being created in tests or check for such folders
// more thoroughly
if (filePath == objectsFolderName)
gotObjectsFolder = true;
}
Assert.That(gotObjectsFolder, Is.True);
}
[Test] [Test]
public void TestSaveNonRootFolderToIar() public void TestSaveNonRootFolderToIar()
{ {
TestHelpers.InMethod(); TestHelpers.InMethod();
TestHelpers.EnableLogging(); // TestHelpers.EnableLogging();
string userFirstName = "Jock"; string userFirstName = "Jock";
string userLastName = "Stirrup"; string userLastName = "Stirrup";