Exemplo n.º 1
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);
            }
        }