/// <summary> /// 获取加载信息 /// </summary> /// <param name="assetName"></param> /// <param name="assetBelongBundleName"></param> /// <param name="assetInBundle"></param> /// <param name="isAsyncLoad"></param> /// <returns></returns> private AssetRequestInfo GetPendingAssetRequestInfo(string assetName, string assetBelongBundleName, AssetBundle assetInBundle) { BundleInfoResource cachedBundleInfo = cache[assetBelongBundleName]; if (cachedBundleInfo != null) { AssetInfo cachedAssetInfo = cachedBundleInfo[assetName]; if (cachedAssetInfo != null && cachedAssetInfo.AssetValid) { AssetRequestInfo requestInfo = new AssetRequestInfo(assetName, cachedAssetInfo.Asset); return(requestInfo); } else { AssetRequestInfo requestInfo = new AssetRequestInfo(assetName, assetInBundle); return(requestInfo); } } else { AssetRequestInfo requestInfo = new AssetRequestInfo(assetName, assetInBundle); return(requestInfo); } }
public AssetBase GetAsset(UUID assetID, AssetRequestInfo reqInfo) { // This function returns true if it's cached as a null and not expired. if (IsNegativeCached(assetID)) { return(null); } // Else, we need to fetch the asset. reqInfo.AssetId = assetID; AssetBase asset = m_assetServer.RequestAssetSync(assetID); if (asset == null) { StampNegativeCache(assetID); } if (this.IsAssetRetrievalAllowed(asset, reqInfo)) { StatsManager.SimExtraStats.AddAssetRequestTime((long)reqInfo.RequestDuration); return(asset); } return(null); }
private AssetRequestInfo NewRequest(string path /*, StackFrame sf*/) { AssetRequestInfo reqInfo = new AssetRequestInfo(); reqInfo.resourcePath = path; return(reqInfo); }
private void TrackRequestWithObject(AssetRequestInfo req, UnityEngine.Object obj) { if (obj == null || !_enableTracking || !PrepareWriter()) { return; } try { req.RecordObject(obj); string info = req.ToString(); if (_logWriter != null && !string.IsNullOrEmpty(info)) { _logWriter.WriteLine(info); } _lastWriteTime = DateTime.Now; } catch (Exception ex) { UnityEngine.Debug.LogErrorFormat("[ResourceTracker.TrackRequestWithObject] error: {0} \n {1} \n {2}", ex.Message, req != null ? req.ToString() : "", ex.StackTrace); } }
public MeshingResult CreateMeshFromPrimMesher(string primName, PrimitiveBaseShape primShape, OpenMetaverse.Vector3 size, float lod, ShapeType desiredShape, bool preScale) { Vector3 szvec = new Vector3(size.X, size.Y, size.Z); ulong meshKey = primShape.GetMeshKey(szvec, lod); try { if (primShape.SculptEntry && ((primShape.SculptData == null) || (primShape.SculptData.Length == 0))) { //preload the sculpt/mesh data AssetBase asset = _assetCache.GetAsset(primShape.SculptTexture, AssetRequestInfo.InternalRequest()); if (asset == null) { return(null); } primShape.SculptData = asset.Data; } if (primShape.SculptEntry == false || (primShape.SculptEntry == true && (SculptType)primShape.SculptType != SculptType.Mesh)) { return(ExtractTrimeshFromPrimOrSculpt(primName, primShape, ref size, lod, preScale, meshKey)); } else //mesh { return(ExtractMeshingResultFromMesh(primName, primShape, ref size, lod, preScale, desiredShape, meshKey)); } } finally { //we dont need the sculpt data around anymore primShape.SculptData = null; } }
private void TrackRequestWithObject(AssetRequestInfo req, Object obj) { if (Object.op_Equality(obj, (Object)null) || !this._enableTracking || !this.PrepareWriter()) { return; } if (!((Behaviour)LoadingStats.Instance).get_enabled()) { return; } try { req.RecordObject(obj); string str = req.ToString(); if (this._logWriter != null && !string.IsNullOrEmpty(str) && req.duration >= 1.0) { this._logWriter.WriteLine(str); } this._lastWriteTime = DateTime.Now; } catch (Exception ex) { Debug.LogErrorFormat("[ResourceTracker.TrackRequestWithObject] error: {0} \n {1} \n {2}", new object[3] { (object)ex.Message, req == null ? (object)string.Empty : (object)req.ToString(), (object)ex.StackTrace }); } }
private bool IsAssetRetrievalAllowed(AssetBase asset, AssetRequestInfo requestInfo) { if (asset == null) { return(true); } //do not pass back object assets to the net if (asset.Type == (sbyte)AssetType.Object && requestInfo.Origin == AssetRequestInfo.RequestOrigin.SRC_NET) { m_log.WarnFormat("Not allowing access to OBJECT asset {0} from SRC_NET", requestInfo.AssetId); return(false); } //dont pass back full script text via LLSTS_ASSET if ((asset.Type == (sbyte)AssetType.LSLText || asset.Type == (sbyte)AssetType.Notecard) && requestInfo.Origin == AssetRequestInfo.RequestOrigin.SRC_NET && (requestInfo.NetSource != AssetRequestInfo.NetSourceType.LLTST_SIM_INV_ITEM && requestInfo.NetSource != AssetRequestInfo.NetSourceType.LLTST_SIM_ESTATE)) { m_log.WarnFormat("Not allowing access to LSLText or asset {0} from SRC_NET and LLTST_ASSET", requestInfo.AssetId); return(false); } return(true); }
internal void Update() { #if DEBUG_BUNDLE_CACHE Profiler.BeginSample("GOEAssetBundleCacheManager.Update"); #endif while (assetLoading.Count < MaximalLoadingAssetBundles && pendingBundle.Count > 0) { var info = pendingBundle.Dequeue(); StartLoadAssets(info); } for (int i = 0; i < assetLoading.Count; i++) { AssetBundleAssetLoadingInfo info = assetLoading[i]; if (info.AllDone) { #if DEBUG_BUNDLE_CACHE ResourceMgr.Instance().SampleLoadEvent(info.BundleName, 6); #endif GOEBundleResource res = new GOEBundleResource(); res.AssetBundle = info.AssetBundle; res.BundleInfo = ResourceMgr.Instance().GetBundle(info.BundleName); cache.CacheAssetBundle(res); bool isAsync = info.IsAsync; for (int j = 0; j < info.Requests.Count; j++) { AssetRequestInfo req = info.Requests[j]; UnityEngine.Object obj = isAsync ? req.Request.asset : req.Asset; if (obj) { string assetName = req.AssetName; var asset = OnGotAsset(assetName, obj, info.BundleName); res.AddAsset(assetName, asset); InvokeAssetLoaded(asset); } } InvokeBundleLoaded(info); MarkBundleDependency(res); assetLoading.RemoveAt(i); #if DEBUG_BUNDLE_CACHE ResourceMgr.Instance().SampleLoadEvent(info.BundleName, 7); Profiler.EndSample(); #endif return;//一个Update只删除一个已完成Bundle } } //不在加载资源时GC bool hasLoading = assetLoading.Count > 0 || pendingBundle.Count > 0; if (!hasLoading) { cache.DoGC(); } #if DEBUG_BUNDLE_CACHE Profiler.EndSample(); #endif }
/// <summary> /// Load an asset /// </summary> /// <param name="assetFilename"></param> /// <param name="data"></param> /// <returns>true if asset was successfully loaded, false otherwise</returns> private bool LoadAsset(string assetPath, byte[] data) { // Right now we're nastily obtaining the UUID from the filename string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length); int i = filename.LastIndexOf(ArchiveConstants.ASSET_EXTENSION_SEPARATOR); if (i == -1) { m_log.ErrorFormat( "[ARCHIVER]: Could not find extension information in asset path {0} since it's missing the separator {1}. Skipping", assetPath, ArchiveConstants.ASSET_EXTENSION_SEPARATOR); return(false); } string extension = filename.Substring(i); string uuid = filename.Remove(filename.Length - extension.Length); if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension)) { sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; //m_log.DebugFormat("[ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); AssetBase asset = new AssetBase(new UUID(uuid), String.Empty); asset.Type = assetType; asset.Data = data; try { m_scene.CommsManager.AssetCache.AddAsset(asset, AssetRequestInfo.InternalRequest()); } catch (AssetServerException e) { m_log.ErrorFormat("[ARCHIVER] Uploading asset {0} failed: {1}", uuid, e); } /** * Create layers on decode for image assets. This is likely to significantly increase the time to load archives so * it might be best done when dearchive takes place on a separate thread * if (asset.Type=AssetType.Texture) * { * IJ2KDecoder cacheLayerDecode = scene.RequestModuleInterface<IJ2KDecoder>(); * if (cacheLayerDecode != null) * cacheLayerDecode.syncdecode(asset.FullID, asset.Data); * } */ return(true); } else { m_log.ErrorFormat( "[ARCHIVER]: Tried to dearchive data with path {0} with an unknown type extension {1}", assetPath, extension); return(false); } }
public void run(object o) { for (int i = 0; i < arrassets.Length; i++) { AssetBase ab = sn.CommsManager.AssetCache.GetAsset(arrassets[i], AssetRequestInfo.InternalRequest()); if (ab != null && ab.Data != null) { j2kdecode.Decode(arrassets[i], ab.Data); } } ThreadTracker.Remove(thisthread); }
public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest) { AssetRequestInfo reqInfo = new AssetRequestInfo(transferRequest, userInfo); reqInfo.Callback = delegate(UUID assetId, AssetBase asset) { this.ProcessDirectAssetRequest(userInfo, asset, reqInfo); }; m_assetServer.RequestAsset(reqInfo.AssetId, reqInfo); }
public void TrackLuaRequest(string path, int bytes, bool loadFromCache) { if (!this._enableTracking) { return; } LoadingStats.Instance.LogLua(path, bytes, loadFromCache); AssetRequestInfo req = this.NewRequest(path); req.requestType = ResourceRequestType.Ordinary; this.TrackRequestWithObject(req, (Object)this._luaAsset); }
public void TrackResourcesDotLoad(Object loaded, string path) { if (!this._enableTracking) { return; } double num = this.TrackSyncStopTiming(path); AssetRequestInfo req = this.NewRequest(path); req.duration = num; req.requestType = ResourceRequestType.Ordinary; this.TrackRequestWithObject(req, loaded); }
public void GetAsset(UUID assetId, AssetRequestCallback callback, AssetRequestInfo requestInfo) { requestInfo.AssetId = assetId; requestInfo.Callback = callback; if (IsNegativeCached(assetId)) { callback(assetId, null); } else { m_assetServer.RequestAsset(assetId, requestInfo); } }
/// <summary> /// Load an asset /// </summary> /// <param name="assetFilename"></param> /// <param name="data"></param> /// <returns>true if asset was successfully loaded, false otherwise</returns> private bool LoadAsset(string assetPath, byte[] data) { //IRegionSerializer serializer = scene.RequestModuleInterface<IRegionSerializer>(); // Right now we're nastily obtaining the UUID from the filename string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length); int i = filename.LastIndexOf(ArchiveConstants.ASSET_EXTENSION_SEPARATOR); if (i == -1) { m_log.ErrorFormat( "[INVENTORY ARCHIVER]: Could not find extension information in asset path {0} since it's missing the separator {1}. Skipping", assetPath, ArchiveConstants.ASSET_EXTENSION_SEPARATOR); return(false); } string extension = filename.Substring(i); string uuid = filename.Remove(filename.Length - extension.Length); if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension)) { sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); AssetBase asset = new AssetBase(new UUID(uuid), "RandomName"); asset.Type = assetType; asset.Data = data; try { m_commsManager.AssetCache.AddAsset(asset, AssetRequestInfo.InternalRequest()); } catch (AssetServerException) { } return(true); } else { m_log.ErrorFormat( "[INVENTORY ARCHIVER]: Tried to dearchive data with path {0} with an unknown type extension {1}", assetPath, extension); return(false); } }
protected internal void Execute() { m_log.DebugFormat("[ARCHIVER]: AssetsRequest executed looking for {0} assets", m_repliesRequired); // We can stop here if there are no assets to fetch if (m_repliesRequired == 0) { m_assetsRequestCallback(m_foundAssetUuids, m_notFoundAssetUuids); } foreach (UUID uuid in m_uuids) { m_assetCache.GetAsset(uuid, AssetRequestCallback, AssetRequestInfo.InternalRequest()); } }
public bool RequestUpdateTaskInventoryItem( IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item) { AssetXferUploader uploader = GetTransactionUploader(transactionID); if (uploader == null) { m_log.WarnFormat("[ASSET TRANSACTIONS]: Transaction {0} NOT FOUND (duplicate removed?) for inventory item update {1}", transactionID, item.Name); return(false); } // This may complete now if upload complete, or later when the upload completes. uploader.TriggerWhenUploadComplete(delegate(AssetBase asset) { // This upload transaction is complete. XferUploaders.Remove(transactionID); if (asset == null) { return; // UpdateItem() not called } m_log.DebugFormat( "[ASSET TRANSACTIONS]: Updating task item {0} in {1} with asset in transaction {2}", item.Name, part.Name, transactionID); asset.Name = item.Name; asset.Description = item.Description; asset.Type = (sbyte)item.Type; try { Manager.MyScene.CommsManager.AssetCache.AddAsset(asset, AssetRequestInfo.GenericNetRequest()); if (part.Inventory.UpdateTaskInventoryItemAsset(part.UUID, item.ItemID, asset.FullID)) { part.GetProperties(remoteClient); } } catch (AssetServerException e) { remoteClient.SendAgentAlertMessage("Unable to upload asset. Please try again later.", false); m_log.ErrorFormat("[ASSET TRANSACTIONS] Unable to update task item due to asset server error {0}", e); } }); // We at least found an uploader with that transaction ID. return(true); }
void StartLoadAssets(AssetBundleAssetLoadingInfo info) { try { BundleIndexItemInfo assetBundleInfo = info.BundleIndexInfo; var bundle = info.AssetBundle; if (!bundle) { DebugUtil.LogError(string.Format("AssetBundle {0} is null", info.BundleName)); return; } info.Requests = new List <AssetRequestInfo>(); bool shouldAsync = true; info.IsAsync = shouldAsync; BundleInfoResource cachedBundleInfo = cache[info.BundleName]; //是否全部加载 if (bundleLoadedCallbacks.ContainsKey(info.BundleName) || info.IsLoadAllAsset) { AssetRequestInfo bundleAllAssetsRequest = new AssetRequestInfo(info.BundleIndexInfo.BundleAssetsArray, info.AssetBundle); bundleAllAssetsRequest.RequestLoadAsset(info.IsAsync); info.Requests.Add(bundleAllAssetsRequest); } else { HashSet <string> pendingBundleAssets = null; if (this.m_pendingAssetIndexDict.TryGetValue(info.BundleName, out pendingBundleAssets)) { foreach (string pendingAsset in pendingBundleAssets) { AssetRequestInfo requestInfo = GetPendingAssetRequestInfo(pendingAsset, info.BundleName, info.AssetBundle); requestInfo.RequestLoadAsset(info.IsAsync); info.Requests.Add(requestInfo); } this.m_pendingAssetIndexDict[info.BundleName].Clear(); } } assetLoading.Add(info); } catch { DebugUtil.LogError("Cannot load assetbundle:" + info.BundleName); } }
public Hashtable ProcessGetMesh(Hashtable request, UUID AgentId, Caps cap) { Hashtable responsedata = new Hashtable(); responsedata["int_response_code"] = 400; //501; //410; //404; responsedata["content_type"] = "text/plain"; responsedata["keepalive"] = false; responsedata["str_response_string"] = "Request wasn't what was expected"; UUID meshID = UUID.Zero; if ((request.ContainsKey("mesh_id")) && (UUID.TryParse(request["mesh_id"].ToString(), out meshID))) { if (m_AssetCache == null) { responsedata["int_response_code"] = 404; //501; //410; //404; responsedata["str_response_string"] = "The asset service is unavailable. So is your mesh."; return(responsedata); } AssetBase mesh = m_AssetCache.GetAsset(meshID, AssetRequestInfo.GenericNetRequest()); if (mesh != null) { if (mesh.Type == (SByte)AssetType.Mesh) { responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data); responsedata["content_type"] = "application/vnd.ll.mesh"; responsedata["int_response_code"] = 200; } // Optionally add additional mesh types here else { responsedata["int_response_code"] = 404; //501; //410; //404; responsedata["str_response_string"] = "Unfortunately, this asset isn't a mesh."; return(responsedata); } } else { responsedata["int_response_code"] = 404; //501; //410; //404; responsedata["str_response_string"] = "Your Mesh wasn't found. Sorry!"; return(responsedata); } } return(responsedata); }
private bool IsAssetStorageAllowed(AssetBase asset, AssetRequestInfo requestInfo) { if (asset == null) { return(false); } //do not accept object assets from the net if (asset.Type == (sbyte)AssetType.Object && requestInfo.Origin == AssetRequestInfo.RequestOrigin.SRC_NET) { return(false); } return(true); }
/// <summary> /// Handle raw uploaded baked texture data. /// </summary> /// <param name="data"></param> /// <param name="path"></param> /// <param name="param"></param> /// <returns></returns> public string BakedTextureUploaded(byte[] data, string path, string param) { String result; bool decodeFailed = false; UUID newAssetID = UUID.Random(); if (data.Length <= 0) { m_log.ErrorFormat("[CAPS]: Invalid length {0} on UploadBakeRequestPut for {1}", data.Length, path); decodeFailed = true; } else if (m_layerDecoder != null) { decodeFailed = (m_layerDecoder.Decode(newAssetID, data) == false); } if (decodeFailed) { Hashtable badReply = new Hashtable(); badReply["state"] = "error"; badReply["new_asset"] = UUID.Zero; result = LLSDHelpers.SerializeLLSDReply(badReply); } else { AssetBase asset = new AssetBase(newAssetID, "Baked Texture", (sbyte)AssetType.Texture, m_Caps.AgentID.ToString()); asset.Data = data; //Persist baked textures as we will use them in the baked texture cache //asset.Temporary = true; asset.Local = true; m_assetCache.AddAsset(asset, AssetRequestInfo.GenericNetRequest()); LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); uploadComplete.new_asset = newAssetID.ToString(); uploadComplete.new_inventory_item = UUID.Zero; uploadComplete.state = "complete"; result = LLSDHelpers.SerializeLLSDReply(uploadComplete); // m_log.DebugFormat("[BAKED TEXTURE UPLOADER]: baked texture upload completed for {0}", newAssetID); } m_Caps.HttpListener.RemoveStreamHandler("POST", m_uploaderPath); return(result); }
public void RequestAsset(OpenMetaverse.UUID assetID, AssetRequestInfo args) { try { _readWhipServer.GetAssetAsync(assetID.ToString(), delegate(Asset asset, AssetServerError e) { if (e == null) { //no error, pass asset to caller _receiver.AssetReceived(WhipAssetToOpensim(asset), args); } else { string errorString = e.ToString(); if (!errorString.Contains("not found")) { //there is an error, log it, and then tell the caller we have no asset to give _log.ErrorFormat( "[WHIP.AssetClient]: Failure fetching asset {0}" + Environment.NewLine + errorString + Environment.NewLine, assetID); } _receiver.AssetNotFound(assetID, args); } } ); } catch (AssetServerError e) { //there is an error, log it, and then tell the caller we have no asset to give string errorString = e.ToString(); if (!errorString.Contains("not found")) { _log.ErrorFormat( "[WHIP.AssetClient]: Failure fetching asset {0}" + Environment.NewLine + errorString + Environment.NewLine, assetID); } _receiver.AssetNotFound(assetID, args); } }
public void HandleAssetCallback(OpenMetaverse.UUID assetID, AssetRequestInfo data, Exception error) { //if not found and this is the first try, try the second server if (_secondReadServer != null && data.ServerNumber == 0) { data.ServerNumber++; _secondReadServer.RequestAsset(assetID, data); } else { if (error == null) { _assetReceiver.AssetNotFound(assetID, data); } else { _assetReceiver.AssetError(assetID, error, data); } } }
private void HandleAssetReceived(UUID assetId, AssetBase asset, AssetRequestInfo reqInfo) { // This must be done before the IsAssetRetrievalAllowed check which can turn it to null. if (asset == null) { this.StampNegativeCache(reqInfo.AssetId); } else { this.RemoveFromNegativeCache(reqInfo.AssetId); } if (this.IsAssetRetrievalAllowed(asset, reqInfo)) { reqInfo.Callback(assetId, asset); } else { reqInfo.Callback(assetId, null); } }
/// <summary> /// Get an asset synchronously, potentially using an asynchronous callback. If the /// asynchronous callback is used, we will wait for it to complete. /// </summary> /// <param name="uuid"></param> /// <returns></returns> protected AssetBase GetAsset(UUID uuid) { m_waitingForObjectAsset = true; m_assetCache.GetAsset(uuid, AssetRequestCallback, AssetRequestInfo.InternalRequest()); // The asset cache callback can either // // 1. Complete on the same thread (if the asset is already in the cache) or // 2. Come in via a different thread (if we need to go fetch it). // // The code below handles both these alternatives. lock (this) { if (m_waitingForObjectAsset) { Monitor.Wait(this); m_waitingForObjectAsset = false; } } return(m_requestedObjectAsset); }
/// <summary> /// Requests and asset and responds asynchronously /// </summary> /// <param name="assetID"></param> /// <param name="args"></param> public void RequestAsset(OpenMetaverse.UUID assetID, AssetRequestInfo args) { _threadPool.QueueWorkItem(() => { try { AssetBase asset = GetAssetInternal(assetID); if (asset != null) { _receiver.AssetReceived(asset, args); } else { _receiver.AssetNotFound(assetID, args); } } catch (Exception e) { _receiver.AssetError(assetID, e, args); } }); }
// This fetches the texture from the asset server synchroneously. That should be ok, as we // call map-creation only in those places: // - on start: We can wait here until the asset server returns the texture // TODO (- on "map" command: We are in the command-line thread, we will wait for completion anyway) // TODO (- on "automatic" update after some change: We are called from the mapUpdateTimer here and // will wait anyway) private Bitmap fetchTexture(UUID id) { AssetBase asset = m_scene.CommsManager.AssetCache.GetAsset(id, AssetRequestInfo.InternalRequest()); m_log.DebugFormat("Fetched texture {0}, found: {1}", id, asset != null); if (asset == null) { return(null); } ManagedImage managedImage; Image image; try { if (OpenJPEG.DecodeToImage(asset.Data, out managedImage, out image)) { return(new Bitmap(image)); } else { return(null); } } catch (DllNotFoundException) { m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg is not installed correctly on this system. Asset Data is empty for {0}", id); } catch (IndexOutOfRangeException) { m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id); } catch (Exception) { m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id); } return(null); }
void StartLoadAssets(AssetBundleAssetLoadingInfo info) { try { GOEBundle gBundle = ResourceMgr.Instance().GetBundle(info.BundleName); var bundle = info.AssetBundle; if (!bundle) { Debug.LogError(string.Format("AssetBundle {0} is null", gBundle.mName)); return; } info.Requests = new List <AssetRequestInfo>(); bool shouldAsync = true; info.IsAsync = shouldAsync; #if DEBUG_BUNDLE_CACHE ResourceMgr.Instance().SampleLoadEvent(info.BundleName, 5); #endif foreach (string str in gBundle.Files) { AssetRequestInfo ar = new AssetRequestInfo(); ar.AssetName = str; if (shouldAsync) { ar.Request = bundle.LoadAssetAsync(str); } else { ar.Asset = bundle.LoadAsset(str); } info.Requests.Add(ar); } assetLoading.Add(info); } catch { Debug.LogError("Cannot load assetbundle:" + info.BundleName); } }
/// <summary> /// Resolve a new piece of asset data against stored metadata /// </summary> /// <param name="assetFilename"></param> /// <param name="data"></param> protected void ResolveAssetData(string assetPath, byte[] data) { // Right now we're nastily obtaining the UUID from the filename string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length); if (m_metadata.ContainsKey(filename)) { AssetMetadata metadata = m_metadata[filename]; if (ArchiveConstants.ASSET_TYPE_TO_EXTENSION.ContainsKey(metadata.AssetType)) { string extension = ArchiveConstants.ASSET_TYPE_TO_EXTENSION[metadata.AssetType]; filename = filename.Remove(filename.Length - extension.Length); } m_log.DebugFormat("[ARCHIVER]: Importing asset {0}", filename); AssetBase asset = new AssetBase(new UUID(filename), metadata.Name); asset.Description = metadata.Description; asset.Type = metadata.AssetType; asset.Data = data; try { m_cache.AddAsset(asset, AssetRequestInfo.InternalRequest()); } catch (AssetServerException e) { m_log.ErrorFormat("[ARCHIVER] Uploading asset {0} failed: {1}", filename, e); } } else { m_log.ErrorFormat( "[DEARCHIVER]: Tried to dearchive data with filename {0} without any corresponding metadata", assetPath); } }
public void AddAsset(AssetBase asset, AssetRequestInfo requestInfo) { requestInfo.AssetId = asset.FullID; if (this.IsAssetStorageAllowed(asset, requestInfo)) { ulong startTime = Util.GetLongTickCount(); try { RemoveFromNegativeCache(asset.FullID); m_assetServer.StoreAsset(asset); } catch (AssetAlreadyExistsException e) { //Don't rethrow this exception. AssetServerExceptions thrown from here // Let's not report this as a warning since this isn't a problem. // m_log.WarnFormat("[ASSET CACHE] Not storing asset that already exists: {0}", e.Message); } StatsManager.SimExtraStats.AddAssetWriteTime((long)(Util.GetLongTickCount() - startTime)); } else { throw new NotSupportedException(String.Format("Not allowing asset storage ID:{0} Type:{1} Source:{2}", asset.ID, asset.Type, requestInfo.Origin)); } //we will save the local asset issue for later as its confusing as hell and even LL isnt //very clear on it. It looks like baked textures, possibly body parts, etc are all //marked as local. from what I can gather this means that the asset is stored locally //on this server, but, and this makes no sense, can be requested by other servers. //on this case why not put it on the asset cluster since it's central anyways? //i could see bakes getting stored locally and regenerated for every sim corssing (i guess) //but this isnt even the case. so im leaving this for now and everything is going to //the asset server }