private AssetData BuildUploadedAsset(AssetUploadTransaction t) => new AssetData { Data = BuildUploadedData(t), ID = t.AssetID, Type = t.AssetType, Temporary = t.IsTemporary, Local = t.IsLocal };
private void AssetUploadCompleted(AssetUploadTransaction transaction, UUID fromSceneID) { #if DEBUG m_Log.DebugFormat("AssetUploadCompleted(): transaction {0}", transaction); #endif var data = BuildUploadedAsset(transaction); bool success = true; try { #if DEBUG m_Log.DebugFormat("Storing asset {0} for {1} / Target={2}", data.ID, Owner.ToString(), transaction.Target.ToString()); #endif if (transaction.Target == AssetUploadTransaction.TargetAsset.Agent) { AssetService.Store(data); } else { Circuits[fromSceneID].Scene.AssetService.Store(data); } } catch (Exception e) { m_Log.ErrorFormat("Storing asset {0} for {1} failed {2}: {3}", data.ID, Owner.ToString(), e.GetType().FullName, e.Message); SendAlertMessage("Could not upload asset", fromSceneID); success = false; } if (success) { try { transaction.OnCompletion(); } catch { success = false; } } #if DEBUG m_Log.DebugFormat("AssetUploadCompleted(): Remove transaction XferID={0}", transaction.XferID); #endif m_AssetTransactions.Remove(transaction.XferID); var req = new AssetUploadComplete { AssetID = data.ID, AssetType = data.Type, Success = success }; SendMessageAlways(req, fromSceneID); }
internal void SetAssetUploadAsUpdateInventoryItem(UUID transactionID, InventoryItem item, UUID sceneID, UInt32 callbackID) { AssetUploadTransaction transaction; lock (m_AssetTransactionsAddLock) { if (!m_AssetTransactions.TryGetValue(transactionID, out transaction)) { UInt64 XferID = NextXferID; transaction = new AssetUploadTransaction { SceneID = sceneID }; transaction.Target = AssetUploadTransaction.TargetAsset.Agent; transaction.OnCompletionEvent += new UpdateInventoryItemHandler { SceneID = sceneID, Agent = this, CallbackID = callbackID, TransactionID = transactionID, Item = item }.OnCompletion; m_AssetTransactions.Add(transactionID, XferID, transaction); transaction.XferID = XferID; return; } } lock (transaction) { transaction.Target = AssetUploadTransaction.TargetAsset.Agent; transaction.OnCompletionEvent += new UpdateInventoryItemHandler { SceneID = sceneID, Agent = this, CallbackID = callbackID, TransactionID = transactionID, Item = item }.OnCompletion; if (transaction.IsCompleted) { #if DEBUG m_Log.DebugFormat("SetAssetUploadAsUpdateInventoryItem(): Completing transaction {0} for {1}", transactionID, Owner.ToString()); #endif AssetUploadCompleted(transaction, transaction.SceneID); } #if DEBUG else { m_Log.DebugFormat("SetAssetUploadAsUpdateInventoryItem(): Appended action to transaction {0} for {1}", transactionID, Owner.ToString()); } #endif } }
public override void SetAssetUploadAsCompletionAction(UUID transactionID, UUID sceneID, Action <UUID> action) { AssetUploadTransaction transaction; lock (m_AssetTransactionsAddLock) { if (!m_AssetTransactions.TryGetValue(transactionID, out transaction)) { UInt64 XferID = NextXferID; #if DEBUG m_Log.DebugFormat("SetAssetUploadAsCompletionAction(): Add transaction TransactionID={0} XferID={1}", transactionID, XferID); #endif transaction = new AssetUploadTransaction { SceneID = sceneID }; transaction.Target = AssetUploadTransaction.TargetAsset.Scene; transaction.OnCompletionEvent += action; m_AssetTransactions.Add(transactionID, XferID, transaction); transaction.XferID = XferID; return; } } lock (transaction) { transaction.Target = AssetUploadTransaction.TargetAsset.Scene; transaction.OnCompletionEvent += action; if (transaction.IsCompleted) { #if DEBUG m_Log.DebugFormat("SetAssetUploadAsCompletionAction(): Completing transaction {0} for {1}", transactionID, Owner.ToString()); #endif AssetUploadCompleted(transaction, transaction.SceneID); } #if DEBUG else { m_Log.DebugFormat("SetAssetUploadAsCompletionAction(): Appended action to transaction {0} for {1}", transactionID, Owner.ToString()); } #endif } }
private UUID AddAssetUploadTransaction(UUID transactionID, AssetUploadTransaction t, UUID fromSceneID) { #if DEBUG m_Log.DebugFormat("AddAssetUploadTransaction(): Added asset upload transaction {0} for {1}", transactionID, Owner.ToString()); #endif UInt64 XferID = NextXferID; m_AssetTransactions.Add(transactionID, XferID, t); t.XferID = XferID; var m = new RequestXfer { ID = t.XferID, VFileType = (short)t.AssetType, VFileID = t.AssetID, FilePath = 0, Filename = t.Filename }; SendMessageAlways(m, fromSceneID); return(transactionID); }
public void HandleAssetUploadRequest(Message m) { var req = (AssetUploadRequest)m; AssetUploadTransaction transaction; lock (m_AssetTransactionsAddLock) { if (!m_AssetTransactions.TryGetValue(req.TransactionID, out transaction)) { UInt64 XferID = NextXferID; #if DEBUG m_Log.DebugFormat("HandleAssetUploadRequest(): Add transaction TransactionID={0} XferID={1}", req.TransactionID, XferID); #endif transaction = new AssetUploadTransaction { SceneID = req.CircuitSceneID }; m_AssetTransactions.Add(req.TransactionID, XferID, transaction); transaction.XferID = XferID; } } UUID vfileID; /* what a crazy work-around in the protocol */ byte[] md5input = new byte[32]; req.TransactionID.ToBytes(md5input, 0); m_SecureSessionID.ToBytes(md5input, 16); using (MD5 md5 = MD5.Create()) { vfileID = new UUID(md5.ComputeHash(md5input), 0); } transaction.AssetID = vfileID; transaction.AssetType = req.AssetType; transaction.IsTemporary = req.IsTemporary; transaction.IsLocal = req.StoreLocal; transaction.Creator = Owner; if (req.AssetData.Length > 2) { #if DEBUG m_Log.DebugFormat("HandleAssetUploadRequest(): Added asset upload transaction {0} for {1}: Single packet", req.TransactionID, Owner.ToString()); #endif transaction.DataBlocks.Add(req.AssetData); lock (transaction) { if (transaction.HasActions) { AssetUploadCompleted(transaction, m.CircuitSceneID); } else { transaction.IsCompleted = true; } } } else { #if DEBUG m_Log.DebugFormat("AssetUploadRequest(): Added asset upload transaction {0} for {1}: Xfer packets", req.TransactionID, Owner.ToString()); #endif var reqxfer = new RequestXfer { ID = transaction.XferID, VFileType = (short)transaction.AssetType, VFileID = vfileID, FilePath = 0, Filename = string.Empty }; SendMessageAlways(reqxfer, m.CircuitSceneID); } }