private void Execute(ISender client, FileTransferCancel message) { if (_activeTransfers.ContainsKey(message.Id)) { RemoveFileTransfer(message.Id); client.Send(new FileTransferCancel { Id = message.Id, Reason = "Canceled" }); } }
public static void HandleDoDownloadFileCancel(FileTransferCancel command, Networking.Client client) { if (!CanceledFileTransfers.ContainsKey(command.Id)) { CanceledFileTransfers.Add(command.Id, "canceled"); client.Send(new FileTransferCancel { Id = command.Id, Reason = "Canceled" }); } }
private void Execute(ISender client, FileTransferCancel message) { FileTransfer transfer; lock (_syncLock) { transfer = _activeFileTransfers.FirstOrDefault(t => t.Id == message.Id); } if (transfer != null) { transfer.Status = message.Reason; OnFileTransferUpdated(transfer); RemoveFileTransfer(transfer.Id); // don't keep un-finished files if (transfer.Type == TransferType.Download) { File.Delete(transfer.LocalPath); } } }