<commit_before>'strict'
importScripts("tool.js");
importScripts("polygoat.js");
postMessage("init");
var aria2
onmessage = function(e) {
	if (aria2 == undefined){
		connect(e.data[0]);
		postMessage("connect");
	};
	/*aria2.tellActive(["gid"]).then((info) => {
		postMessage(["badge", info.length]);
		if(info.length == 0) {
			aria2.close();
			close();
		}
	});*/
	
}

function connect(options) {
	aria2 = new Aria2(options);
	aria2.onclose = function () {
		aria2 = null;
	}
	aria2.open();
	aria2.onDownloadComplete = function(d) {
		aria2.getFiles(d.gid).then((info) => {
			postMessage(["complete", info[0].path]);
		});
		aria2.tellActive(["gid"]).then((info) => {
			postMessage(["badge", info.length]);
			if(info.length == 0) {
				aria2.close();
				close();
			}
		});
	};
	aria2.onDownloadPause = aria2.onDownloadStop = function(d) {
		aria2.tellActive(["gid"]).then((info) => {
			postMessage(["badge", info.length]);
			if(info.length == 0) {
				aria2.close();
				close();
			}
		});
	};
	aria2.onDownloadError = function(d) {
		aria2.getUris(d.gid).then((info) => {
			postMessage(["error", info[0].uri]);
		});
		aria2.tellActive(["gid"]).then((info) => {
			postMessage(["badge", info.length]);
			if(info.length == 0) {
				aria2.close();
				close();
			}
		});
	};
}<commit_msg>fix an issue of monitor<commit_after>'strict'
importScripts("tool.js");
importScripts("polygoat.js");
postMessage("init");
var aria2
onmessage = function(e) {
	if (aria2 == undefined){
		connect(e.data[0]);
		postMessage("connect");
	};
	/*aria2.tellActive(["gid"]).then((info) => {
		postMessage(["badge", info.length]);
		if(info.length == 0) {
			aria2.close();
			close();
		}
	});*/
	
}

function connect(options) {
	aria2 = new Aria2(options);
	aria2.onclose = function () {
		aria2 = null;
	}
	aria2.onDownloadStart = function(d) {
		aria2.tellActive(["gid"]).then((info) => {
			postMessage(["badge", info.length]);
			if(info.length == 0) {
				aria2.close();
				postMessage("close");
				close();
			}
		});
	};
	aria2.onDownloadComplete = function(d) {
		aria2.getFiles(d.gid).then((info) => {
			postMessage(["complete", info[0].path]);
		});
		aria2.tellActive(["gid"]).then((info) => {
			postMessage(["badge", info.length]);
			if(info.length == 0) {
				aria2.close();
				postMessage("close");
				close();
			}
		});
	};
	aria2.onDownloadPause = aria2.onDownloadStop = function(d) {
		aria2.tellActive(["gid"]).then((info) => {
			postMessage(["badge", info.length]);
			if(info.length == 0) {
				aria2.close();
				postMessage("close");
				close();
			}
		});
	};
	aria2.onDownloadError = function(d) {
		aria2.getUris(d.gid).then((info) => {
			postMessage(["error", info[0].uri]);
		});
		aria2.tellActive(["gid"]).then((info) => {
			postMessage(["badge", info.length]);
			if(info.length == 0) {
				aria2.close();
				postMessage("close");
				close();
			}
		});
	};
	aria2.open().then(() => {
		aria2.tellActive(["gid"]).then((info) => {
		postMessage(["badge", info.length]);
		if(info.length == 0) {
			aria2.close();
			postMessage("close");
			close();
		}
		});
	});
}
{'fraction_non_alphanumeric': 0.23372018052869117, 'fraction_numerical': 0.020309477756286266, 'mean_word_length': 3.7812018489984593, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1728268', 'n_tokens_mistral': 1373, 'n_tokens_neox': 1178, 'n_words': 153}