public static CoalescedObjectSnapshot FromCoalescedObject(CoalescedObject csog, SerializationFlags flags) { List <Tuple <SceneObjectGroupSnapshot, ItemPermissionBlockSnapshot> > snapGroups = new List <Tuple <SceneObjectGroupSnapshot, ItemPermissionBlockSnapshot> >(); foreach (var group in csog.Groups) { snapGroups.Add( new Tuple <SceneObjectGroupSnapshot, ItemPermissionBlockSnapshot>( SceneObjectGroupSnapshot.FromSceneObjectGroup(group, flags), ItemPermissionBlockSnapshot.FromItemPermissionBlock(csog.FindPermissions(group.UUID))) ); } return(new CoalescedObjectSnapshot { GroupsWithPermissions = snapGroups.ToArray() }); }
/// <summary> /// Write an assets metadata file to the given archive /// </summary> /// <param name="archive"></param> // protected void WriteMetadata(TarArchiveWriter archive) // { // StringWriter sw = new StringWriter(); // XmlTextWriter xtw = new XmlTextWriter(sw); // // xtw.Formatting = Formatting.Indented; // xtw.WriteStartDocument(); // // xtw.WriteStartElement("assets"); // // foreach (UUID uuid in m_assets.Keys) // { // AssetBase asset = m_assets[uuid]; // // if (asset != null) // { // xtw.WriteStartElement("asset"); // // string extension = String.Empty; // // if (ArchiveConstants.ASSET_TYPE_TO_EXTENSION.ContainsKey(asset.Type)) // { // extension = ArchiveConstants.ASSET_TYPE_TO_EXTENSION[asset.Type]; // } // // xtw.WriteElementString("filename", uuid.ToString() + extension); // // xtw.WriteElementString("name", asset.Name); // xtw.WriteElementString("description", asset.Description); // xtw.WriteElementString("asset-type", asset.Type.ToString()); // // xtw.WriteEndElement(); // } // } // // xtw.WriteEndElement(); // // xtw.WriteEndDocument(); // // archive.WriteFile("assets.xml", sw.ToString()); // } /// <summary> /// Write asset data files to the given archive /// </summary> /// <param name="asset"></param> protected void WriteData(AssetBase asset) { // It appears that gtar, at least, doesn't need the intermediate directory entries in the tar //archive.AddDir("assets"); string extension = String.Empty; if (ArchiveConstants.ASSET_TYPE_TO_EXTENSION.ContainsKey(asset.Type)) { extension = ArchiveConstants.ASSET_TYPE_TO_EXTENSION[asset.Type]; } else { m_log.ErrorFormat( "[ARCHIVER]: Unrecognized asset type {0} with uuid {1}. This asset will be saved but not reloaded", asset.Type, asset.ID); } // Check for Thoosa Inventory object and decode to XML if necessary for Archive. string xmlData; if ((asset.Type == (sbyte)AssetType.Object) && (m_inventorySerializer != null) && (m_inventorySerializer.CanDeserialize(asset.Data))) { if (m_inventorySerializer.IsValidCoalesced(asset.Data)) { CoalescedObject obj = m_inventorySerializer.DeserializeCoalescedObjFromInventoryBytes(asset.Data); List <ItemPermissionBlock> perms = new List <ItemPermissionBlock>(); foreach (var grp in obj.Groups) { perms.Add(obj.FindPermissions(grp.UUID)); } xmlData = CoalescedSceneObjectSerializer.ToXmlFormat(obj.Groups, perms, StopScriptReason.None); } else if (m_inventorySerializer.IsValidGroup(asset.Data)) { SceneObjectGroup grp = m_inventorySerializer.DeserializeGroupFromInventoryBytes(asset.Data); xmlData = m_serializer.SaveGroupToOriginalXml(grp); } else { return; // can't pass the CanDeserialize test above, but makes the compiler happy } // Now write out the XML format asset m_archiveWriter.WriteFile( ArchiveConstants.ASSETS_PATH + asset.FullID.ToString() + extension, xmlData); } else { // Now write out the same (raw) asset unchanged. m_archiveWriter.WriteFile( ArchiveConstants.ASSETS_PATH + asset.FullID.ToString() + extension, asset.Data); } m_assetsWritten++; if (m_assetsWritten % LOG_ASSET_LOAD_NOTIFICATION_INTERVAL == 0) { m_log.InfoFormat("[ARCHIVER]: Added {0} assets to archive", m_assetsWritten); } }