Esempio n. 1
0
        public ArchiveReadRequest(Scene scene, string loadPath, bool merge, bool skipAssets, Guid requestId)
        {
            m_rootScene = scene;

            m_loadPath = loadPath;
            try
            {
                m_loadStream = new GZipStream(ArchiveHelpers.GetStream(loadPath), CompressionMode.Decompress);
            }
            catch (EntryPointNotFoundException e)
            {
                m_log.ErrorFormat(
                    "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
                    + "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
                m_log.Error(e);
            }

            m_errorMessage = String.Empty;
            m_merge        = merge;
            m_skipAssets   = skipAssets;
            m_requestId    = requestId;

            // Zero can never be a valid user id
            m_validUserUuids[UUID.Zero] = false;

            m_groupsModule = m_rootScene.RequestModuleInterface <IGroupsModule>();
            m_assetService = m_rootScene.AssetService;
        }
Esempio n. 2
0
        public ArchiveReadRequest(Scene scene, string loadPath, bool merge, bool skipAssets, int offsetX, int offsetY, int offsetZ, bool flipX, bool flipY)
        {
            m_offsetX = offsetX;
            m_offsetY = offsetY;
            m_offsetZ = offsetZ;
            m_flipX   = flipX;
            m_flipY   = flipY;
            m_scene   = scene;

            try
            {
                m_loadStream = new GZipStream(ArchiveHelpers.GetStream(loadPath), CompressionMode.Decompress);
            }
            catch (EntryPointNotFoundException e)
            {
                m_log.ErrorFormat(
                    "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
                    + "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
                m_log.Error(e);
            }

            m_errorMessage = String.Empty;
            m_merge        = merge;
            m_skipAssets   = skipAssets;
        }
Esempio n. 3
0
        /// <summary>
        /// Searches through the files in the archive for the control file, and reads it.
        /// We must read the control file first, in order to know which regions are available.
        /// </summary>
        /// <remarks>
        /// In most cases the control file *is* first, since that's how we create archives. However,
        /// it's possible that someone rewrote the archive externally so we can't rely on this fact.
        /// </remarks>
        /// <param name="archive"></param>
        /// <param name="dearchivedScenes"></param>
        private void FindAndLoadControlFile(out TarArchiveReader archive, out DearchiveScenesInfo dearchivedScenes)
        {
            archive = new TarArchiveReader(m_loadStream);
            dearchivedScenes = new DearchiveScenesInfo();

            string filePath;
            byte[] data;
            TarArchiveReader.TarEntryType entryType;
            bool firstFile = true;

            while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
            {
                if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType)
                    continue;
                    
                if (filePath == ArchiveConstants.CONTROL_FILE_PATH)
                {
                    LoadControlFile(filePath, data, dearchivedScenes);

                    // Find which scenes are available in the simulator
                    ArchiveScenesGroup simulatorScenes = new ArchiveScenesGroup();
                    SceneManager.Instance.ForEachScene(delegate(Scene scene2)
                    {
                        simulatorScenes.AddScene(scene2);
                    });
                    simulatorScenes.CalcSceneLocations();
                    dearchivedScenes.SetSimulatorScenes(m_rootScene, simulatorScenes);

                    // If the control file wasn't the first file then reset the read pointer
                    if (!firstFile)
                    {
                        m_log.Warn("Control file wasn't the first file in the archive");
                        if (m_loadStream.CanSeek)
                        {
                            m_loadStream.Seek(0, SeekOrigin.Begin);
                        }
                        else if (m_loadPath != null)
                        {
                            archive.Close();
                            archive = null;
                            m_loadStream.Close();
                            m_loadStream = null;
                            m_loadStream = new GZipStream(ArchiveHelpers.GetStream(m_loadPath), CompressionMode.Decompress);
                            archive = new TarArchiveReader(m_loadStream);
                        }
                        else
                        {
                            // There isn't currently a scenario where this happens, but it's best to add a check just in case
                            throw new Exception("Error reading archive: control file wasn't the first file, and the input stream doesn't allow seeking");
                        }
                    }

                    return;
                }

                firstFile = false;
            }

            throw new Exception("Control file not found");
        }
Esempio n. 4
0
        protected internal void Save(ICollection <UUID> assetsFoundUuids, ICollection <UUID> assetsNotFoundUuids)
        {
            foreach (UUID uuid in assetsNotFoundUuids)
            {
                m_log.DebugFormat("[ARCHIVER]: Could not find asset {0}", uuid);
            }

//            m_log.InfoFormat(
//                "[ARCHIVER]: Received {0} of {1} assets requested",
//                assetsFoundUuids.Count, assetsFoundUuids.Count + assetsNotFoundUuids.Count);

            m_log.InfoFormat("[ARCHIVER]: Creating archive file.  This may take some time.");

            // Write out control file
            m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile());
            m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");

            // Write out region settings
            string settingsPath
                = String.Format("{0}{1}.xml", ArchiveConstants.SETTINGS_PATH, m_scene.RegionInfo.RegionName);

            m_archiveWriter.WriteFile(settingsPath, RegionSettingsSerializer.Serialize(m_scene.RegionInfo.RegionSettings));

            m_log.InfoFormat("[ARCHIVER]: Added region settings to archive.");

            // Write out land data (aka parcel) settings
            List <ILandObject> landObjects = m_scene.LandChannel.AllParcels();

            foreach (ILandObject lo in landObjects)
            {
                LandData landData     = lo.LandData;
                string   landDataPath = String.Format("{0}{1}.xml", ArchiveConstants.LANDDATA_PATH,
                                                      landData.GlobalID.ToString());
                m_archiveWriter.WriteFile(landDataPath, LandDataSerializer.Serialize(landData));
            }
            m_log.InfoFormat("[ARCHIVER]: Added parcel settings to archive.");

            // Write out terrain
            string terrainPath
                = String.Format("{0}{1}.r32", ArchiveConstants.TERRAINS_PATH, m_scene.RegionInfo.RegionName);

            MemoryStream ms = new MemoryStream();

            m_terrainModule.SaveToStream(terrainPath, ms);
            m_archiveWriter.WriteFile(terrainPath, ms.ToArray());
            ms.Close();

            m_log.InfoFormat("[ARCHIVER]: Added terrain information to archive.");

            // Write out scene object metadata
            foreach (SceneObjectGroup sceneObject in m_sceneObjects)
            {
                //m_log.DebugFormat("[ARCHIVER]: Saving {0} {1}, {2}", entity.Name, entity.UUID, entity.GetType());

                string serializedObject = m_serialiser.SerializeGroupToXml2(sceneObject);
                m_archiveWriter.WriteFile(ArchiveHelpers.CreateObjectPath(sceneObject), serializedObject);
            }

            m_log.InfoFormat("[ARCHIVER]: Added scene objects to archive.");
        }
        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);
            }
        }
Esempio n. 6
0
        public ArchiveReadRequest(Scene scene, string loadPath, Guid requestId, Dictionary <string, object> options)
        {
            m_rootScene = scene;

            if (options.ContainsKey("default-user"))
            {
                m_defaultUser = (UUID)options["default-user"];
                m_log.InfoFormat("Using User {0} as default user", m_defaultUser.ToString());
            }
            else
            {
                m_defaultUser = scene.RegionInfo.EstateSettings.EstateOwner;
            }

            m_loadPath = loadPath;
            try
            {
                m_loadStream = new GZipStream(ArchiveHelpers.GetStream(loadPath), CompressionMode.Decompress);
            }
            catch (EntryPointNotFoundException e)
            {
                m_log.ErrorFormat(
                    "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
                    + "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
                m_log.Error(e);
            }

            m_errorMessage = String.Empty;
            m_merge        = options.ContainsKey("merge");
            m_forceTerrain = options.ContainsKey("force-terrain");
            m_forceParcels = options.ContainsKey("force-parcels");
            m_persistuuids = options.ContainsKey("persist-uuids");
            if (m_persistuuids)
            {
                m_merge = false;
            }
            m_noObjects      = options.ContainsKey("no-objects");
            m_skipAssets     = options.ContainsKey("skipAssets");
            m_requestId      = requestId;
            m_displacement   = options.ContainsKey("displacement") ? (Vector3)options["displacement"] : Vector3.Zero;
            m_rotation       = options.ContainsKey("rotation") ? (float)options["rotation"] : 0f;
            m_rotationCenter = options.ContainsKey("rotation-center") ? (Vector3)options["rotation-center"]
                                : new Vector3(scene.RegionInfo.RegionSizeX / 2f, scene.RegionInfo.RegionSizeY / 2f, 0f);

            // Zero can never be a valid user or group id
            m_validUserUuids[UUID.Zero]  = false;
            m_validGroupUuids[UUID.Zero] = false;

            m_groupsModule = m_rootScene.RequestModuleInterface <IGroupsModule>();
            m_assetService = m_rootScene.AssetService;
        }