/// <summary> /// Resolve a destination folder /// </summary> /// We require here a root destination folder (usually the root of the user's inventory) and the archive /// path. We also pass in a list of previously resolved folders in case we've found this one previously. /// <param name = "archivePath"> /// The item archive path to resolve. The portion of the path passed back is that /// which corresponds to the resolved desintation folder. /// <param name = "rootDestinationFolder"> /// The root folder for the inventory load /// </param> /// <param name = "resolvedFolders"> /// The folders that we have resolved so far for a given archive path. /// </param> /// <returns> /// The folder in the user's inventory that matches best the archive path given. If no such folder was found /// then the passed in root destination folder is returned. /// </returns> protected InventoryFolderBase ResolveDestinationFolder( InventoryFolderBase rootDestFolder, ref string archivePath, ref Dictionary <string, InventoryFolderBase> resolvedFolders) { // string originalArchivePath = archivePath; while (archivePath.Length > 0) { // MainConsole.Instance.DebugFormat("[INVENTORY ARCHIVER]: Trying to resolve destination folder {0}", archivePath); if (resolvedFolders.ContainsKey(archivePath)) { // MainConsole.Instance.DebugFormat( // "[INVENTORY ARCHIVER]: Found previously created folder from archive path {0}", archivePath); return(resolvedFolders[archivePath]); } else { if (m_merge) { // TODO: Using m_invPath is totally wrong - what we need to do is strip the uuid from the // iar name and try to find that instead. string plainPath = ArchiveConstants.ExtractPlainPathFromIarPath(archivePath); List <InventoryFolderBase> folderCandidates = InventoryArchiveUtils.FindFolderByPath( m_registry.RequestModuleInterface <IInventoryService>(), m_userInfo.PrincipalID, plainPath); if (folderCandidates.Count != 0) { InventoryFolderBase destFolder = folderCandidates[0]; resolvedFolders[archivePath] = destFolder; return(destFolder); } } // Don't include the last slash so find the penultimate one int penultimateSlashIndex = archivePath.LastIndexOf("/", archivePath.Length - 2); if (penultimateSlashIndex >= 0) { // Remove the last section of path so that we can see if we've already resolved the parent archivePath = archivePath.Remove(penultimateSlashIndex + 1); } else { // MainConsole.Instance.DebugFormat( // "[INVENTORY ARCHIVER]: Found no previously created folder for archive path {0}", // originalArchivePath); archivePath = string.Empty; return(rootDestFolder); } } } return(rootDestFolder); }
protected void Save(Scene scene, List <SceneObjectGroup> sceneObjects, string regionDir) { if (regionDir != string.Empty) { regionDir = ArchiveConstants.REGIONS_PATH + regionDir + "/"; } m_log.InfoFormat("[ARCHIVER]: Adding region settings to archive."); // Write out region settings string settingsPath = String.Format("{0}{1}{2}.xml", regionDir, ArchiveConstants.SETTINGS_PATH, scene.RegionInfo.RegionName); m_archiveWriter.WriteFile(settingsPath, RegionSettingsSerializer.Serialize(scene.RegionInfo.RegionSettings, scene.RegionEnvironment)); m_log.InfoFormat("[ARCHIVER]: Adding parcel settings to archive."); // Write out land data (aka parcel) settings List <ILandObject> landObjects = scene.LandChannel.AllParcels(); foreach (ILandObject lo in landObjects) { LandData landData = lo.LandData; string landDataPath = String.Format("{0}{1}", regionDir, ArchiveConstants.CreateOarLandDataPath(landData)); m_archiveWriter.WriteFile(landDataPath, LandDataSerializer.Serialize(landData, m_options)); } m_log.InfoFormat("[ARCHIVER]: Adding terrain information to archive."); // Write out terrain string terrainPath = String.Format("{0}{1}{2}.r32", regionDir, ArchiveConstants.TERRAINS_PATH, scene.RegionInfo.RegionName); using (MemoryStream ms = new MemoryStream()) { scene.RequestModuleInterface <ITerrainModule>().SaveToStream(terrainPath, ms); m_archiveWriter.WriteFile(terrainPath, ms.ToArray()); } m_log.InfoFormat("[ARCHIVER]: Adding scene objects to archive."); // Write out scene object metadata IRegionSerialiserModule serializer = scene.RequestModuleInterface <IRegionSerialiserModule>(); foreach (SceneObjectGroup sceneObject in sceneObjects) { //m_log.DebugFormat("[ARCHIVER]: Saving {0} {1}, {2}", entity.Name, entity.UUID, entity.GetType()); if (sceneObject.IsDeleted || sceneObject.inTransit) { continue; } string serializedObject = serializer.SerializeGroupToXml2(sceneObject, m_options); string objectPath = string.Format("{0}{1}", regionDir, ArchiveHelpers.CreateObjectPath(sceneObject)); m_archiveWriter.WriteFile(objectPath, serializedObject); } }
/// <summary> /// Create the path used to store an object in an OpenSim Archive. /// </summary> /// <param name="objectName"></param> /// <param name="uuid"></param> /// <param name="pos"></param> /// <returns></returns> public static string CreateObjectPath(SceneObjectGroup sog) { return(ArchiveConstants.CreateOarObjectPath(sog.Name, sog.UUID, sog.AbsolutePosition)); }