Exemplo n.º 1
0
        /// <summary>
        /// Adds the asset uuid for inspection during the gathering process.
        /// </summary>
        /// <returns><c>true</c>, if for inspection was added, <c>false</c> otherwise.</returns>
        /// <param name="uuid">UUID.</param>
        public bool AddForInspection(UUID uuid)
        {
            if (uuid == UUID.Zero)
            {
                return(false);
            }

            if (FailedUUIDs.Contains(uuid))
            {
                if (UncertainAssetsUUIDs.Contains(uuid))
                {
                    possibleNotAssetCount++;
                }
                else
                {
                    ErrorCount++;
                }
                return(false);
            }
            if (GatheredUuids.ContainsKey(uuid))
            {
                return(false);
            }
            if (m_assetUuidsToInspect.Contains(uuid))
            {
                return(false);
            }

//            m_log.DebugFormat("[UUID GATHERER]: Adding asset {0} for inspection", uuid);

            m_assetUuidsToInspect.Enqueue(uuid);
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Record the asset uuids embedded within the given text (e.g. a script).
        /// </summary>
        /// <param name="textAsset"></param>
        private void RecordTextEmbeddedAssetUuids(AssetBase textAsset)
        {
            //            m_log.DebugFormat("[ASSET GATHERER]: Getting assets for uuid references in asset {0}", embeddingAssetId);

            string text = Utils.BytesToString(textAsset.Data);
//            m_log.DebugFormat("[UUID GATHERER]: Text {0}", text);
            MatchCollection uuidMatches = Util.PermissiveUUIDPattern.Matches(text);

//            m_log.DebugFormat("[UUID GATHERER]: Found {0} matches in text", uuidMatches.Count);

            foreach (Match uuidMatch in uuidMatches)
            {
                UUID uuid = new UUID(uuidMatch.Value);
                if (uuid == UUID.Zero)
                {
                    continue;
                }
//                m_log.DebugFormat("[UUID GATHERER]: Recording {0} in text", uuid);
                if (!UncertainAssetsUUIDs.Contains(uuid))
                {
                    UncertainAssetsUUIDs.Add(uuid);
                }
                AddForInspection(uuid);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Record the asset uuids embedded within the given text (e.g. a script).
        /// </summary>
        /// <param name="textAsset"></param>
        private void RecordEmbeddedAssetDataUuids(AssetBase textAsset)
        {
            // m_log.DebugFormat("[ASSET GATHERER]: Getting assets for uuid references in asset {0}", embeddingAssetId);

            if (textAsset.Data.Length < 36)
            {
                return;
            }

            List <UUID> ids = Util.GetUUIDsOnData(textAsset.Data, 0, textAsset.Data.Length);

            if (ids == null || ids.Count == 0)
            {
                return;
            }

            for (int i = 0; i < ids.Count; ++i)
            {
                if (ids[i] == UUID.Zero)
                {
                    continue;
                }
                if (!UncertainAssetsUUIDs.Contains(ids[i]))
                {
                    UncertainAssetsUUIDs.Add(ids[i]);
                }
                AddForInspection(ids[i]);
            }
        }
Exemplo n.º 4
0
        private void AddForInspection(UUID assetUuid, sbyte assetType)
        {
            if (assetUuid == UUID.Zero)
            {
                return;
            }

            // Here, we want to collect uuids which require further asset fetches but mark the others as gathered
            if (FailedUUIDs.Contains(assetUuid))
            {
                if (UncertainAssetsUUIDs.Contains(assetUuid))
                {
                    possibleNotAssetCount++;
                }
                else
                {
                    ErrorCount++;
                }
                return;
            }
            if (GatheredUuids.ContainsKey(assetUuid))
            {
                return;
            }
            try
            {
                if ((sbyte)AssetType.Bodypart == assetType ||
                    (sbyte)AssetType.Clothing == assetType ||
                    (sbyte)AssetType.Gesture == assetType ||
                    (sbyte)AssetType.Notecard == assetType ||
                    (sbyte)AssetType.LSLText == assetType ||
                    (sbyte)OpenSimAssetType.Material == assetType ||
                    (sbyte)AssetType.Object == assetType)
                {
                    AddForInspection(assetUuid);
                }
                else
                {
                    GatheredUuids[assetUuid] = assetType;
                }
            }
            catch (Exception)
            {
                m_log.ErrorFormat(
                    "[UUID GATHERER]: Failed to gather uuids for asset id {0}, type {1}",
                    assetUuid, assetType);
                throw;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Record the asset uuids embedded within the given text (e.g. a script).
        /// </summary>
        /// <param name="textAsset"></param>
        private void RecordTextEmbeddedAssetUuids(AssetBase textAsset)
        {
            string text = Utils.BytesToString(textAsset.Data);

            foreach (Match uuidMatch in Util.PermissiveUUIDPattern.Matches(text))
            {
                UUID uuid = new UUID(uuidMatch.Value);
                if (uuid == UUID.Zero)
                {
                    continue;
                }
                if (!UncertainAssetsUUIDs.Contains(uuid))
                {
                    UncertainAssetsUUIDs.Add(uuid);
                }
                AddForInspection(uuid);
            }
        }
Exemplo n.º 6
0
        private void RecordNoteCardEmbeddedAssetUuids(AssetBase textAsset)
        {
            List <UUID> ids = SLUtil.GetEmbeddedAssetIDs(textAsset.Data);

            if (ids == null || ids.Count == 0)
            {
                return;
            }

            for (int i = 0; i < ids.Count; ++i)
            {
                if (ids[i] == UUID.Zero)
                {
                    continue;
                }
                if (!UncertainAssetsUUIDs.Contains(ids[i]))
                {
                    UncertainAssetsUUIDs.Add(ids[i]);
                }
                AddForInspection(ids[i]);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Gather all the asset uuids associated with the asset referenced by a given uuid
        /// </summary>
        /// <remarks>
        /// This includes both those directly associated with
        /// it (e.g. face textures) and recursively, those of items within it's inventory (e.g. objects contained
        /// within this object).
        /// This method assumes that the asset type associated with this asset in persistent storage is correct (which
        /// should always be the case).  So with this method we always need to retrieve asset data even if the asset
        /// is of a type which is known not to reference any other assets
        /// </remarks>
        /// <param name="assetUuid">The uuid of the asset for which to gather referenced assets</param>
        private void GetAssetUuids(UUID assetUuid)
        {
            if (assetUuid == UUID.Zero)
            {
                return;
            }

            if (FailedUUIDs.Contains(assetUuid))
            {
                if (UncertainAssetsUUIDs.Contains(assetUuid))
                {
                    possibleNotAssetCount++;
                }
                else
                {
                    ErrorCount++;
                }
                return;
            }

            // avoid infinite loops
            if (GatheredUuids.ContainsKey(assetUuid))
            {
                return;
            }

            AssetBase assetBase;

            try
            {
                assetBase = GetAsset(assetUuid);
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[UUID GATHERER]: Failed to get asset {0} : {1}", assetUuid, e.Message);
                ErrorCount++;
                FailedUUIDs.Add(assetUuid);
                return;
            }

            if (assetBase == null)
            {
                FailedUUIDs.Add(assetUuid);
                if (UncertainAssetsUUIDs.Contains(assetUuid))
                {
                    possibleNotAssetCount++;
                }
                else
                {
                    ErrorCount++;
                }
                return;
            }

            if (UncertainAssetsUUIDs.Contains(assetUuid))
            {
                UncertainAssetsUUIDs.Remove(assetUuid);
            }

            sbyte assetType = assetBase.Type;

            if (assetBase.Data == null || assetBase.Data.Length == 0)
            {
                ErrorCount++;
                FailedUUIDs.Add(assetUuid);
                return;
            }

            GatheredUuids[assetUuid] = assetType;
            try
            {
                if ((sbyte)AssetType.Bodypart == assetType || (sbyte)AssetType.Clothing == assetType)
                {
                    RecordWearableAssetUuids(assetBase);
                }
                else if ((sbyte)AssetType.Gesture == assetType)
                {
                    RecordGestureAssetUuids(assetBase);
                }
                else if ((sbyte)AssetType.Notecard == assetType)
                {
                    RecordTextEmbeddedAssetUuids(assetBase);
                }
                else if ((sbyte)AssetType.LSLText == assetType)
                {
                    RecordTextEmbeddedAssetUuids(assetBase);
                }
                else if ((sbyte)OpenSimAssetType.Material == assetType)
                {
                    RecordMaterialAssetUuids(assetBase);
                }
                else if ((sbyte)AssetType.Object == assetType)
                {
                    RecordSceneObjectAssetUuids(assetBase);
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[UUID GATHERER]: Failed to gather uuids for asset with id {0} type {1}: {2}", assetUuid, assetType, e.Message);
                GatheredUuids.Remove(assetUuid);
                ErrorCount++;
                FailedUUIDs.Add(assetUuid);
            }
        }