<commit_before>﻿using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System.Net;
using System.IO;
using System;
using System.Reflection;
using System.Xml.Serialization;

namespace Igor
{
	public class JenkinsFTP : IgorModuleBase
	{
		public static string UploadToFTPNoEnvFlag = "jenkinsuploadftpalways";
		public static string UploadToFTPEnvToggleFlag = "jenkinsuploadftpenvtoggle";
		public static string UploadToFTPFlag = "jenkinsuploadftpfilename";

		public static StepID UploadToFTPStep = new StepID("Jenkins Upload To FTP", 1100);

		public override string GetModuleName()
		{
			return "Distribution.JenkinsFTP";
		}

		public override void RegisterModule()
		{
			IgorCore.RegisterNewModule(this);
		}

		public override void ProcessArgs(IIgorStepHandler StepHandler)
		{
			if(IgorJobConfig.GetStringParam(UploadToFTPFlag) != "" &&
				(IgorJobConfig.IsBoolParamSet(UploadToFTPNoEnvFlag) ||
					(IgorJobConfig.GetStringParam(UploadToFTPEnvToggleFlag) != "" && IgorUtils.GetEnvVariable(IgorJobConfig.GetStringParam(UploadToFTPEnvToggleFlag)) != "")))
			{
				IgorCore.SetModuleActiveForJob(this);
				StepHandler.RegisterJobStep(IgorBuildCommon.PreBuildCleanupStep, this, Cleanup);
				StepHandler.RegisterJobStep(UploadToFTPStep, this, UploadToFTP);
			}
		}

		public override string DrawJobInspectorAndGetEnabledParams(string CurrentParams)
		{
			string EnabledParams = CurrentParams;

			DrawBoolParam(ref EnabledParams, "Always Upload", UploadToFTPNoEnvFlag);
			DrawStringParam(ref EnabledParams, "FTP Filename", UploadToFTPFlag);
			DrawStringParam(ref EnabledParams, "Environment Variable Toggle", UploadToFTPEnvToggleFlag);

			return EnabledParams;
		}

		public virtual bool Cleanup()
		{
			string DestinationFile = IgorJobConfig.GetStringParam(UploadToFTPFlag);

			if(File.Exists(DestinationFile))
			{
				IgorUtils.DeleteFile(DestinationFile);
			}

			return true;<commit_msg>Fixes for the conditional FTP uploading module.<commit_after>﻿using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System.Net;
using System.IO;
using System;
using System.Reflection;
using System.Xml.Serialization;

namespace Igor
{
	public class JenkinsFTP : IgorModuleBase
	{
		public static string UploadToFTPNoEnvFlag = "jenkinsuploadftpalways";
		public static string UploadToFTPEnvToggleFlag = "jenkinsuploadftpenvtoggle";
		public static string UploadToFTPFlag = "jenkinsuploadftpfilename";

		public static StepID UploadToFTPStep = new StepID("Jenkins Upload To FTP", 1100);

		public override string GetModuleName()
		{
			return "Distribution.JenkinsFTP";
		}

		public override void RegisterModule()
		{
			IgorCore.RegisterNewModule(this);
		}

		public override void ProcessArgs(IIgorStepHandler StepHandler)
		{
			bool bStepRegistered = false;

			if(IgorJobConfig.GetStringParam(UploadToFTPFlag) != "" &&
				(IgorJobConfig.IsBoolParamSet(UploadToFTPNoEnvFlag) ||
					(IgorJobConfig.GetStringParam(UploadToFTPEnvToggleFlag) != "" && IgorUtils.GetEnvVariable(IgorJobConfig.GetStringParam(UploadToFTPEnvToggleFlag)) == "true")))
			{
				StepHandler.RegisterJobStep(UploadToFTPStep, this, UploadToFTP);

				bStepRegistered = true;
			}

			if(IgorJobConfig.IsBoolParamSet(UploadToFTPNoEnvFlag) || IgorJobConfig.GetStringParam(UploadToFTPEnvToggleFlag) != "")
			{
				StepHandler.RegisterJobStep(IgorBuildCommon.PreBuildCleanupStep, this, Cleanup);

				bStepRegistered = true;
			}

			if(bStepRegistered)
			{
				IgorCore.SetModuleActiveForJob(this);
			}
		}

		public override string DrawJobInspectorAndGetEnabledParams(string CurrentParams)
		{
			string EnabledParams = CurrentParams;

			DrawBoolParam(ref EnabledParams, "Always Upload", UploadToFTPNoEnvFlag);
			DrawStringParam(ref EnabledParams, "FTP Filename", UploadToFTPFlag);
			DrawStringParam(ref EnabledParams, "Environment Variable Toggle", UploadToFTPEnvToggleFlag);

			return EnabledParams;
		}

		public virtual bool Cleanup()
		{
			string DestinationFile = IgorJobConfig.GetStringParam(UploadToFTPFlag);

			if(File.Exists(DestinationFile))
			{
				IgorUtils.DeleteFile(DestinationFile);
			}

			return true;
{'fraction_non_alphanumeric': 0.08676016163536962, 'fraction_numerical': 0.0019015925837889231, 'mean_word_length': 5.658227848101266, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3944959', 'n_tokens_mistral': 1485, 'n_tokens_neox': 1298, 'n_words': 242}